Rotate object Up/Down/Left/Right in any orientation
- by George Duckett
I'm rendering model at the origin with a fixed camera looking at it positioned on the z axis.
I want to be able to rotate the model up/down and left/right. Currently I have 2 variables, HorizontalRotation and VerticalRotation. When calculating the world matrix I rotate about the Y axis by HorizontalRotation and about the X axis by VerticalRotation.
The ..Rotation variables are controlled by pressing up/down/left/right arrow keys.
The problem I'm having is that the rotations are happening relative to the object.
Lets say it's a model of the world. Pressing Up a bit would let me look at the north pole.
Currently when i press right the earth spins infront of the camera on its axis; I'm still looking at the north pole.
How can i get it so that no matter what rotations are currently applied i can always rotate my model relative to the camera/world axis?