Advertisement

Help with modelview matrix!

Started by November 05, 2003 11:03 AM
4 comments, last by mits 21 years, 4 months ago
I have read the OpenGL red book but I still can''t understand exactly how the modelview matrix works. Generally (api independently) , I know these about transformations: We have the coords of an object in local space and with a matrix , let''s say it the world matrix , we transform them in world coordinates. Then with another matrix , let''s call it the view matrix , we transform them in camera space coords. And then the projection transform comes. Correct me if I''m wrong so far. So what the modelview matrix has to do with all these? I have read somewhere that the submatrix 3x3 of the modelview matrix contains the up,right and lookAt vector of camera. An explanation of how modelview matrix works , what it contains and to which coordinate space it refers woulb be very helpful. In DX things were more clarified but I have stuck in OpenGL. Thanks in advance.
The modelview matrix is simply the product of the world matrix and the view matrix. Since the two really have the same purpose (transforming geometry relative to the viewer) they''re rolled into one in OpenGL.


How appropriate. You fight like a cow.
Advertisement
You mean that if I use the modelview matrix in an object''s coordinates , I''ll get the camera space coords? And what about the camera vectors?
Thanks for the answer
When you transform object coordinates by the modelview transformation, you get eye-space coordinates--basically, the whole world, transformed so that the viewer is looking straight forwards from the origin.

http://www.opengl.org/developers/documentation/Specs/glspec1.1/node23.html


How appropriate. You fight like a cow.
Ok I understood that the object coordinates are transformed by the modelview matrix to the eye coordinates. But I still don''t know what exactly the modelview matrix contains. I''m a little bit confused about that. What does the 3x3 submatrix of the modelview matrix contain? The right , up and lookAt vector of the camera or something else? I have read that the fourth column is the position of the local origin.What is the local origin? Is it the position of the camera in world space?Or something else?
And if the modelview matrix is the product of world and view matrix , then how can I obtain the world or the view matrix?
Please I want specific answers. Thanks
In general, yes, it''ll contain the orthonormalized lookAt vectors. But this is not necessarily true, in particular, if a scaling operation has been performed.

Yes, the last column can be considered to be the position of the camera in the world.

You can''t extricate either the model matrix or the view matrix from the modelview matrix, because they go into the same pot. Essentially, you''re asking to multiply two matrices, and then from the result, extract the factors. But since you set the modelview matrix yourself directly, there should be no question as to what it contains.


How appropriate. You fight like a cow.

This topic is closed to new replies.

Advertisement