THE total noob question

Post Reply
Brian Beuken
Posts: 46
Joined: Sat Jul 29, 2017 9:19 pm

THE total noob question

Post by Brian Beuken »

Ok after my mess up with rotations I have a real noob question to ask

I have my cars all nicely lined up, but I want to implement forward and back motion based on their orientation, but I don't seem to have any means to extract the orientation except as a quat?
How do I use that to create a forward and backward vector for movement in the facing direction?
Brian Beuken
Posts: 46
Joined: Sat Jul 29, 2017 9:19 pm

Re: THE total noob question

Post by Brian Beuken »

ok well I found it out... there are two ways

Code: Select all

	btQuaternion orient = this->MyPhysObj->GetRigidBody()->getOrientation();	
	Forward = btVector3(0, 0, 1);
	Forward = quatRotate(orient, Forward);
or

Code: Select all

	btMatrix3x3 rotationMatrix(orient);
	Forward = btVector3(rotationMatrix.getColumn(2)); // we will keep this its usefull for all sorts
1st is a little easier to get your head around and also to provide directions for the standard cardinal points, for the 2nd more tradition matrix extraction version if you need Right and Up, Right can be obtained from column 0 and Up from column 1.

Hope someone else just starting on Bullet finds this useful
Post Reply