I have made a compound shape compound = new btCompoundShape();
Then I have a collision shape added to the compound:
btCollisionShape* turretShape = new btBoxShape(btVector3(0.4f, 0.2f, 1.2f));
btTransform turretTrans;
turretTrans.setIdentity();
turretTrans.setOrigin(btVector3(0.0f, 2.2f, 0.0f));
compound->addChildShape(turretTrans, turretShape);
The compund shape is then transformed into a rigid body and then added to a vehicle raycaster as a chassis:
m_carChassis = CreateRigidBody(2000, tr, compound);
m_vehicle = new btRaycastVehicle(m_tuning, m_carChassis, m_vehicleRayCaster);
The vehicle is moving along, together with it's wheels, chassis and turret, but I cannot seem to get hold of the updated turret transform. Whenever I try something like this:
compound->getChildTransform(1).getOpenGLMatrix(mturret);
I always get the initial position of the turret, where it was first created.
Now, for the wheels I can do this:
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(mwheel);
And for the chassis I can do this:
m_vehicle->getChassisWorldTransform().getOpenGLMatrix(mchassis);
But I don't know how do I get hold of that turret collision shape updated transform?
Please note that where I need this information I have access to both the compound and the turretShape (the actual btCollisionShape).
I don't remember for sure now, but I think you have to multiply the matrices of the chasis world transform and childs (turrets) because getChildTransform() returns in parents reference frame. Can't find it in the docs though.