looking and moving up and down(pitch) using glRotate()

• 06-13-2002
Crossbow
looking and moving up and down(pitch) using glRotate()
I have a OpenGL program that is like a space simulator. I have the thing correctly turning and flying straight, but things start to get difficult when I try to look up and down. To look up and down, or pitch, I have the program increase pitch by one is down and decrease if up, when the up or down key is pressed. Then, in the draw function, I have the glRotatef function rotate on the x axis up and down according to pitch. Like:
Code:

`glRotatef(pitch,1.0f,0,0);`
And this works fine if I am facing along the x axis(0(360) or 180 degrees), but say I face 90 degrees on the z axis, the screen rotates around in a circle. I hope you follow me on this. I can't figure out how to fix this, so any suggestions would be great. Thanks!
• 06-14-2002
no-one
if i get what your saying correctly, it's because at 90 degrees you should be rotating on the z axis to go up and down... the way you are attempting to do this is fairly complicated,
you could try

Code:

``` void gluLookAt(   GLdouble eyex,        GLdouble eyey,        GLdouble eyez,        GLdouble centerx,    GLdouble centery,    GLdouble centerz,    GLdouble upx,        GLdouble upy,        GLdouble upz        ); eyex, eyey, eyez The position of the eye point. centerx, centery, centerz The position of the reference point. upx, upy, upz The direction of the up vector.```
and/or look into vector math and trigonomotry...
• 06-14-2002
Crossbow
Ok, I looked up that function and it will work, but there is one thing I don't know about it, and that is the up vector. When I change the values it doesn't seem to have any effect. What does it do?
• 06-15-2002
no-one
it specifies the up "Vector" technically its the up Axis

so if you use (0.0,1.0,0.0) then positive y is up
if you use (0.0,-1.0,0.0) negative y is up
if you us (1.0,0.0,0.0) positive x is up

get it?

using decimal points wont really change anything...