I have made a compound shape
Code: Select all
compound = new btCompoundShape();
Code: Select all
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);
Code: Select all
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:
Code: Select all
compound->getChildTransform(1).getOpenGLMatrix(mturret);
Now, for the wheels I can do this:
Code: Select all
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(mwheel);
Code: Select all
m_vehicle->getChassisWorldTransform().getOpenGLMatrix(mchassis);
Please note that where I need this information I have access to both the compound and the turretShape (the actual btCollisionShape).
EDIT:
I found the answer. Here's what I did:
Code: Select all
btTransform chassisMatrix = m_vehicle->getChassisWorldTransform();
btTransform turretMatrix = compound->getChildTransform(1);
turretMatrix *= chassisMatrix;
turretMatrix.getOpenGLMatrix(mturret);