示例#1
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
const Math::Vector3
PhysicsActor::getTorque()
{
    Math::Vector3 velocity;
    NewtonBodyGetTorque(m_pActor, velocity.m_array);
    m_torque = velocity;
    return m_torque;
}
void dVehicleSingleBody::ApplyExternalForce()
{
	dVector force(0.0f);
	dVector torque;
	
	dComplementaritySolver::dBodyState* const chassisBody = GetBody();
	dComplementaritySolver::dBodyState* const groundBody = m_groundNode.GetBody();

	groundBody->SetForce(force);
	groundBody->SetTorque(force);

	NewtonBodyGetForce(m_newtonBody, &force[0]);
	chassisBody->SetForce(force);

	NewtonBodyGetTorque(m_newtonBody, &torque[0]);
	chassisBody->SetTorque(torque);
	
	m_gravity = force.Scale (chassisBody->GetInvMass());
	dVehicleInterface::ApplyExternalForce();
}
void dVehicleSingleBody::RigidBodyToStates()
{
	dVector vector;
	dMatrix matrix;
	dComplementaritySolver::dBodyState* const chassisBody = GetBody();

	// get data from engine rigid body and copied to the vehicle chassis body
	NewtonBodyGetMatrix(m_newtonBody, &matrix[0][0]);
	chassisBody->SetMatrix(matrix);

static int xxx;
xxx++;
if (xxx == 1500)
{
//	NewtonBodyGetVelocity(m_newtonBody, &vector[0]);
//	vector.m_x += 2.0f;
//	NewtonBodySetVelocity(m_newtonBody, &vector[0]);
}


	NewtonBodyGetVelocity(m_newtonBody, &vector[0]);
	chassisBody->SetVeloc(vector);

	NewtonBodyGetOmega(m_newtonBody, &vector[0]);
	chassisBody->SetOmega(vector);

	NewtonBodyGetForce(m_newtonBody, &vector[0]);
	chassisBody->SetForce(vector);

	NewtonBodyGetTorque(m_newtonBody, &vector[0]);
	chassisBody->SetTorque(vector);

	chassisBody->UpdateInertia();
	
	dVehicleInterface::RigidBodyToStates();
}