I am trying to make a simple airplane flight sim type of game. I am getting stuck with multiple rotations. I have tried many things over the last two weeks and always end up at the same place. Basically once I make one rotation around an axis/vector, it changes the up/right/forward vectors. I cannot get a second rotation around the new axis to work, it always wants to rotate around the original axis. My plan is to draw my airplane, then push the matrix, rotate for pitch, rotate for roll, and draw the land/sky. I have setup touchscreen "buttons" to control the plane with up = pitch up, down = pitch down, right = roll right, left = roll left.
Here are some ways I have tried:
Using glRotatef -
glRotatef(pitch, 0,0,1)
glRotatef(roll, 1,0,0)
This doesn't work because the first rotate changes the axis and the second rotation is incorrect. Swapping the order does not help because the second rotation is always on an incorrect axis.
Using matrices -
1st try - I built 3 rotation matrices for rotation around X,Y,Z axis. This results in the same as above because they are really the same matrices.
2nd try - I built one rotation matrix that premultiplies all 3 matrices. Same result.
3rd try -
I setup an initial Orientation matrix (which is actually the same as the identity). In the first frame I call glMultiMatrix(mOrientation, 0).
At the end of the drawing I add an increment of pitch & roll if user inputs up/down/left right.
I built a Rotation matrix for rotation around and arbitrary axis. First I get a rotation matrix for rotation of "pitch" degrees around mOrientation[0], mOrientation[1], mOrientation[2]. (This outputs a new matrix I call mArbRot) I tested this and it works fine as a single rotation around whatever axis I desire.
This is a rotation about the right vector, and the resulting matrix should have updated the up & forward vectors in column 2 & 3 respectively. So I call the arbitrary rotation around the new vectors. I rotate "roll" degrees about the new forward vector mArbRot[8], mArbRot[9], mArbRot[10]. Then I make mOrientation = mArbRot. The next frame should be rotating correctly around the right vectors when I call glMultiMatrix(mOrientation, 0).
But I get the same result. The axis for the second rotation is always incorrect. Hopefully someone has been through this and can give me a little direction. I'd be happy to post some code if it will help.
Thanks.


