Exemplo n.º 1
0
//----------------------------------------------------------------------------
// TODO: add in enhancement data here
void NounShip::updateCharacter()
{
	PROFILE_FUNCTION();

	float m = mass();
	m *=  calculateModifier( MT_MASS );
	if ( m < 1.0f )
		m = 1.0f;

	m_Sensor = baseSensor();
	m_View = baseView();
	m_MaxDamage = baseDamage();
	m_MaxEnergy = baseEnergy();
	m_MaxVelocity = baseVelocity();
	m_MaxCargo = baseCargo();
	m_MaxThrust = baseThrust();

	for(int i=0;i<m_Gadgets.size();i++)
	{
		NounGadget * pGadget = m_Gadgets[i];

		m				+= pGadget->addMass();
		m_Sensor		+= pGadget->addSensor();
		m_MaxVelocity	+= pGadget->addMaxVelocity() * velocityModifier();
		m_MaxDamage		+= pGadget->addMaxDamage();
		m_MaxEnergy		+= pGadget->addMaxEnergy();
		m_MaxCargo		+= pGadget->addCargo();
		m_MaxThrust		+= pGadget->addThrust();
	}

	//calculate the acceleration by taking the thrust and dividing by the mass of the ship
	m_MaxAcceleration = m_MaxThrust / m;
	
	//calculate the turn rate (yaw) by taking the baseYaw(), dividing by the mass of the ship and adding a fraction of m_MaxAcceleration
	m_MaxYaw = (baseYaw() / m) + (m_MaxAcceleration / 10);

	//apply enhancements to ships, including gadget effects
	m_MaxVelocity *=  calculateModifier( MT_DRIVE_VELOCITY );
	m_MaxThrust	*= calculateModifier( MT_DRIVE_THRUST );
	m_MaxYaw *= calculateModifier( MT_TURNRATE );
	m_MaxEnergy *= calculateModifier( MT_SHIPENERGY );
}
void
MobileRootJoint::velocity(const Task& task, const Environment& environment,
                          const ContinousStateValueVector& continousState,
                          ChildLink& childLink) const
{
  Vector3 position = continousState[*mPositionStateInfo];
  Quaternion orientation = continousState[*mOrientationStateInfo];
  Vector6 velocity = continousState[*mVelocityStateInfo];

  childLink.setCoordinateSystem(CoordinateSystem(position, orientation));

  velocity = childLink.getCoordinateSystem().rotToReference(velocity);
  Vector3 angularBaseVelocity = environment.getAngularVelocity(task.getTime());
  Vector6 baseVelocity(angularMotionTo(position, angularBaseVelocity));
  childLink.setVelocity(velocity);
  childLink.setInertialVelocity(baseVelocity + velocity);

  childLink.setForce(Vector6::zeros());
  childLink.setInertia(SpatialInertia::zeros());
}