I'm integrating bullet into a game engine that uses euler XYZ rotation for it's objects..
What I'm trying to do, is write code that fetches the rotation from a bullet body in the world, to update the display object in the engine. And another bit of code, that can update the rotation of the bullet body, if the display object is changed directly.
Here's what I'm doing to fetch the rotation from the body...
Code: Select all
btTransform t=_rigidBody->getWorldTransform();
btMatrix3x3 m=btMatrix3x3(t.getRotation());
btScalar rot[3];
m.getEulerZYX(rot[0], rot[1], rot[2]);
return glm::vec3(glm::degrees(rot[2]), glm::degrees(rot[1]), glm::degrees(rot[0]));
Code: Select all
btTransform t;
_motionState->getWorldTransform(t);
t.setRotation(btQuaternion(glm::radians(z), glm::radians(y), glm::radians(x)));
_motionState->setWorldTransform(t);