I can obtain the turret transform and opengl matrix like this:
Code: Select all
// get chassis and turret transforms
btTransform chassisTransform = m_vehicle->getChassisWorldTransform();
btTransform turretTransform = compound->getChildTransform(1);
// multiply transforms to get updated turret transform
turretTransform *= chassisTransform;
// get turret matrix
btScalar turretMatrix[16];
turretTransform.getOpenGLMatrix(turretMatrix);
What I have tried is this:
Code: Select all
btVector3 turretForwardVector = btVector3(turretMatrix[2], turretMatrix[6], turretMatrix[9]);
Could someone please point out where exactly do I have to look for the vector in this matrix?
EDIT:
I managed to find this [link](http://www.opengl.org/discussion_boards ... ix-or-Quat). It explained where I would find the direction vector in the matrix (3rd column).
So I got the 8th, 9th and 10th matrix elemets and created the turretForwardMatrix from that like this:
Code: Select all
btVector3 turretForwardVector = btVector3(turretMatrix[8], turretMatrix[9], turretMatrix[10]);