moving camera around in opengl,
Members - Reputation: 122
Posted 28 November 2001 - 06:24 AM
Members - Reputation: 348
Posted 28 November 2001 - 06:31 AM
For example, to move the scene 100 units away from you on the z axis, you''d do glTranslatef(0.0, 0.0, -100.0f). Now, it is important to understand that the cursor has moved and not the camera. If you now do a glRotate, it is not the camera that rotates: instead the cursor rotates. That''s why, if you translate, rotate 180 degrees, and then draw an object, you can still see it: the object has rotated 180 degrees, not you.
Once you understand how transformation functions do their stuff, things should become clearer. The functions of immediate interest are the glRotate, glTranslate and glScale family of functions.
You also need to know about the matrices: glMatrixMode, glLoadIdentity and gluPerspective need to be used to set up the viewing and modelling matrices correctly.
Just Plain Wrong