View Full Version : camera directions...
06-05-2000, 12:16 AM
ok, I am relatively new to OpenGL (student didn't have the time between finals and APs).
Anyway, I drew some stuff in OpengGL and now I want to navigate through the environment being able to look up, down, left and right, instead of walking forward or sideways... I am using glTranslatef() to move the camera... is there a more efficent way to navigate through the world? or how about turning the camera 60 or 90 degrees w/o moving?!?
Any help will be appreciated.
06-05-2000, 12:22 AM
I JUST thought of this, but should I use glRotatef() to move the entire world around me, instead of the camera moving itself?!
Is this the best way to do it? (Is it even a way?). Again any comments would be appreciated.
[This message has been edited by ngill (edited 06-05-2000).]
There are no camera in OpenGL. Just a viewpoint located at the world origin.
When you move the "camera" forward, you are actually moving the world backwards. This is the only way to do it in OpenGL, aswell as in any API. Ok, some API's got functions that say you move the camera, but actually you are moving the world in the oposite direction.
You should either use glTranslate/glRotate OR gluLookAt (i recomend you use this one) to setup the viewpoint.
[glRotatef(anglez, 0.0, 0.0, 1.0);]
gluLookAt (xpos, ypos, zpos, xpos+lookx, ypos+looky, zpos+lookz, lookupx, lookupy, lookupz);
anglex: rotation round y-axis
angley: rotation round x-axis
[anglez: rotation round z-axis](if you need it)
Try this and you will be happy http://www.opengl.org/discussion_boards/ubb/smile.gif
06-05-2000, 02:16 PM
Thanks, I'll look into that. http://www.opengl.org/discussion_boards/ubb/smile.gif
06-05-2000, 03:50 PM
I used to use glRotate and glTranslate to do all my object and camera positioning. Then I ran into a problem when I wanted to render transparent polygons correctly. The only solution I could come up with was to largely abandon the use of glRotate and glTranslate, and do my own object->world->clip transforms so that I could have the depth info needed to sort the transparent polys. Just letting you know in case you run into the same problem.
[This message has been edited by DFrey (edited 06-05-2000).]
06-05-2000, 08:43 PM
Check out OpenGl SuperBible version 1.0 which I believe is free online. Has the code you need I forget where also I forget the URL but am sure you can find it. Is what I use and works perfectly.
A minor, but religious issue... opengl DOES have a camera. That thing set by glFrustum? or gluPerspective? that'll be opengl's camera model. http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.