How to get the ahead direction on a vehicle?

conquerors
Posts: 3
Joined: Sun May 20, 2007 1:26 pm
Location: China

How to get the ahead direction on a vehicle?

Post by conquerors »

btTransform chassisWorldTrans;
m_pPhyMotionState->getWorldTransform(chassisWorldTrans);

btMatrix3x3 CarMat=chassisWorldTrans.getBasis();

CarMat.getEuler(m_fHead ,m_fPitch,m_fBank);

is this right?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Code: Select all

int indexForwardAxis = vehicle->getForwardAxis();

const btTransform& chassisTrans = getChassisWorldTransform();

btVector3 forwardW (
		chassisTrans.getBasis()[0][indexForwardAxis],
		chassisTrans.getBasis()[1][indexForwardAxis],
		chassisTrans.getBasis()[2][indexForwardAxis]);
We can add a helper method in the btRaycastVehicle for this forward vector.

Hope this helps,
Erwin
conquerors
Posts: 3
Joined: Sun May 20, 2007 1:26 pm
Location: China

Post by conquerors »

thanks
I can synchronize view transform with car.