Rotate object Up/Down/Left/Right in any orientation
Posted
by
George Duckett
on Game Development
See other posts from Game Development
or by George Duckett
Published on 2012-05-21T13:05:15Z
Indexed on
2012/11/12
23:15 UTC
Read the original article
Hit count: 227
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?
© Game Development or respective owner