C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-13-2002, 09:28 PM   #1
Registered User
 
Join Date: Nov 2001
Posts: 162
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!
Crossbow is offline   Reply With Quote
Old 06-14-2002, 03:12 PM   #2
Has a Masters in B.S.
 
Join Date: Aug 2001
Posts: 2,267
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...
__________________
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
no-one is offline   Reply With Quote
Old 06-14-2002, 09:53 PM   #3
Registered User
 
Join Date: Nov 2001
Posts: 162
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?
Crossbow is offline   Reply With Quote
Old 06-15-2002, 12:17 AM   #4
Has a Masters in B.S.
 
Join Date: Aug 2001
Posts: 2,267
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...
__________________
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
no-one is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 08:41 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22