// add force and torque to rigid body void PhysicsSetTransform (const NewtonBody* body, const dFloat* matrix) { RenderPrimitive* primitive; // get the graphic object form the rigid body primitive = (RenderPrimitive*) NewtonBodyGetUserData (body); // set the transformation matrix for this rigid body dMatrix& mat = *((dMatrix*)matrix); primitive->SetMatrix (mat); }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ // set the transformation of a rigid body void PhysicsActor::TransformCallback(const NewtonBody* _body, const Zen::Math::Real* _matrix) { void* pBody = NewtonBodyGetUserData(_body); if (pBody != NULL) { PhysicsActor* pShape = static_cast<PhysicsActor*>(pBody); // Only use the transform callback if the state is active if (pShape->m_activationState != 0) { Math::Matrix4 transform; for(int x = 0; x < 16; x++) { transform.m_array[x] = _matrix[x]; } TransformEventData evenData(*pShape, transform); pShape->onTransformEvent(evenData); } } #if 0 // HACK Keep the object to a constant velocity Math::Vector3 velocity; NewtonBodyGetVelocity(_body, velocity.m_array); velocity.normalize(); velocity = velocity * 50; NewtonBodySetVelocity(_body, velocity.m_array); #endif //std::cout << "TransformCallback()" << std::endl; #if 0 RenderPrimitive* primitive; // get the graphic object form the rigid body primitive = (RenderPrimitive*) NewtonBodyGetUserData (body); // set the transformation matrix for this rigid body dMatrix& mat = *((dMatrix*)matrix); primitive->SetMatrix (mat); #endif }