get btCollisionShape current transform
Posted: Sun Nov 17, 2013 5:32 pm
Hey guys,
I have made a compound shape
Then I have a collision shape added to the compound:
The compund shape is then transformed into a rigid body and then added to a vehicle raycaster as a chassis:
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:
I always get the initial position of the turret, where it was first created.
Now, for the wheels I can do this:
And for the chassis I can do this:
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).
EDIT:
I found the answer. Here's what I did:
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);