Posted 22 June 2001 - 10:19 PM
I’m new to this, so please excuse me if this is a stupid question.
If an object has been rotated through its axis, how can I determine which way is forwards?
My object starts off with its X,Y and Z angles all at 0. So I consider forwards to be in the XZ plane, and depending on the rotation through the Y axis, I can work out how much to translate in X and Z.
However, if I then rotate the object through the X axis, say by 90 degrees, then forwards is now in the YX plane.
I have managed to get this working on 90 degree rotations, but the code is horrible – I keep track of the current forwards plane using an enumeration. Also, I want it to work for any amount of rotation.
Does anyone know of a formula that allows me to work this out based on the current rotations?
Hope that’s clear, maybe the code below will clarify what I want to achieve.
// x,y and z are all 0 initially
pObj->MoveForwards(10.0f); // will move along z axis
pObj->MoveForwards(10.0f); // will move along x axis
pObj->MoveForwards(10.0f); // will move along y axis
Thanks for reading!