I'm trying to get the rotation of an object from the btTransform parameter in the setWorldTransform method of a motion state.
Currently I'm using this code:
Code: Select all
void MyMotionState::setWorldTransform(const btTransform &worldTrans)
{
btQuaternion rotation = worldTrans.getRotation();
MyQuaternion orientation(rotation.x(), rotation.y(), rotation.z(), rotation.w());
...
}
When using worldTrans.getOpenGLMatrix() everything works fine, but I need to seperate the rotation from the translation, so this is not a possibilty.
Do I have to somehow apply the worldTrans.getRotation() quaternion with the worldTransform.getBasis() matrix?
What could be the cause for the incorrect rotations?
Just for clarity:
MyQuaternion is a simple class with no functionality and just stores 4 floats. I then create a glm::quat with it (by simply passing x, y, z and w) and then pass it to the glm::mat4_cast() function when rendering.
Greetings