# Finding the up and the aim based on rotation on 3 axes

I’m using gluLookAt to translate/rotate everything so the camera is in the right place, looking the right way. And I’m trying to store the rotations of the camera on the 3 axes in 3 variables: xrot, yrot, and zrot (I’m treating the z axis as the up and down one and the y axis as the in and out one, so the camera’s local z axis sticks in it from top to bottom, its local y axis sticks in it from back to front, and its local x axis sticks in it from left to right). The problem is finding the x, y, and z for the aim and the up to put into gluLookAt. I know how to use sin and cos so finding x’es and y’es in 2d is easy, but when there’s 2 more axes added it makes things a little more complicated. What I want is if you press the up/down/right/left buttons, the screen rotates up/down/right/left respectively in relation to whatever angle its at. Er, like when I press up, it should rotate in whatever direction LOOKS up based on my current rotations… So could someone tell me how to do this please? Because 3 axis are 2 too many for me =).

Eh, as a side note, could you try to use nice small words that I can understand and explain without too much math jargon if possible. And if you use any functions other than sin, cos, and tan, could you explain them, please? I figure with people on this board who seem to all have like 1000 IQ the hard part won’t be figuring out how to solve my problem, but to word it so I can understand, so sorry about my lack of math knowledge, and thanks in advance. =)

Hey satan you wouldn’t happen to know how to solve my above problem would you?

Instead of storing the orientation as three angles around x, y and z, store it as a rotation matrix. Whenever you want to rotate the view, pre-multiply this matrix with a new rotation matrix for the appropiate axis (x or y).

Alternatively, you can extract the rotation axes (the cameras x and y axis) from your lookat parameters just as gluLookAt does. You can use these axes to modify the lookat parameters.

When there’s more than 2 axis, simply to the cross product of the 2 axis, and you’ll have the third one. This is simple mathematics.

Hrm. There again with the matrices. Since these matrices seem to be so important in OpenGL, it would probably be a good idea if I found out what they did, huh? =) Know of a link where I could learn about the OpenGL matrices? And thanks for the help yall.

Ah, nevermind. I found a great site that explains what the elements of the modelview matrix does really simply with a kind of example and no math jargon.