PDA

View Full Version : A camera question.



lgc_ustc
01-02-2004, 01:11 AM
Hello, fellas,

I have been brooding on the problem for three days, it's like:

I am using gluLookAt to position the camera in the world space, which will change the current model/view matrix, I think. Since I read some tutorials and they said so. In my notion, the position of camera is related to the model/view matrix and the fov/ration is related to the projection matrix. However, after I called the gluLookAt function, the projection matrix is changed but the model/view matrix remains unchanged! Well, this seems that the gluLookAt function uses the projection matrix to do all the camera things and has nothing to do with the model/view matrix. Another paper on the internet make me tend to believe this rather than my original thought: http://www.acm.jhu.edu/~upe/member_sites/duca/node6.html
Am I correct? If so, another way to control the camera seems easier to me: the reverse matrix of the camera position is constructed and then applied to the scene.

Thanks for any replies clarifying my confusions on camera control, and HAPPY NEW YEAR TO YOU ALL http://www.opengl.org/discussion_boards/ubb/smile.gif

Vlasko
01-02-2004, 01:34 AM
If I'm correct camera operations are done in projection matrix.You can do it also the other way it's up to you.Don't know if true but I red somewhere that camera operations are slower

01-02-2004, 02:15 AM
>> I red somewhere that camera operations are slower

Well, I don't think so. The projection matrix has a stack depth of only 2 most of the time. I believe it is the only difference.

True that the gluLookAt and other camera operations are done on the projection matrix. Use the modelview matrix to place objects.

Happy new year !

Deiussum
01-02-2004, 05:27 AM
The gluLookAt function will affect whatever matrix is the current matrix. So to use it in the MODELVIEW matrix like you should be doing, you will need to use glMatrixMode(GL_MODELVIEW);

It is correct that it should go onto the MODELVIEW matrix, and the only things that should be on the PROJECTION matrix are things that setup the shape of your viewing volume. If you ignore this advice, be prepared for messed up fog and light calculations!