How to rotate a btCollisionShape?
Posted: Mon Nov 18, 2013 10:40 pm
I have created a bullet vehicle with a compound as the chassis and the compound is formed of 2 bodies, a chassis and a turret.
I can obtain the turret transform and opengl matrix like this:
The turretTransform is the transform of a btCollisionShape object (turretShape).
I am now trying to rotate this turret around it's Y axis.
I have tried this:
Where angle is a float, but nothing happens.
I'm definitely missing something, but do not fully understand how these rotations work.
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);
I am now trying to rotate this turret around it's Y axis.
I have tried this:
Code: Select all
turretTransform.setRotation(btQuaternion(btVector3(0, 1, 0), angle));
I'm definitely missing something, but do not fully understand how these rotations work.