PDA

View Full Version : setting GL_PROJECTION_MATRIX ?



Indra
05-08-2003, 04:52 AM
Hello,

I want to set the "camera" of opengl, the GL_PROJECTION_MATRIX, just the same way as my real camera is viewing the scene. I use gluperspective to set the internal parameters, and discovered already the meaning of this and the way to set it explicitely.
But then is the translation and rotation. I know those transformation according to the main axis, and to set a model on a position it is then first setting the translation with gltranslate and then multiply this with the rotation matrix. But what do I have to do to set the GL_PROJECTION coorect? does the rotation has to come before the translation, or is an inverse, transpose of the matrix necessary.

shinpaughp
05-08-2003, 09:36 AM
This is beginner question. Please ask there, not here. Thank you.

dorbie
05-08-2003, 09:50 AM
You must load the camera translation and rotation onto the modelview matrix, and only the perspective projection onto the projection matrix.

Because you're moving the model around with the same matrix as you view, you actually load what might seem as the inverse transform of the camera position as the viewing matrix onto the modelview matrix to move the camera.

So to move the eye to (+10, +5, -6) in your world you would actually load a translate matrix of (-10, -5, +6) onto the modelview matrix.