I am porting GLU gluUnproject method to the modern OpenGL.I generally understand the algorithm behind it, but my question is why do we need model-view matrix?Can it be just view matrix?We unproject screen coordinates into the world space, so why do I need to supply also some object's model matrix (as a part of model view)?Or maybe I misunderstand how to use the method?I never really used fixed pipeline.
Asked
Active
Viewed 486 times
0
-
Do you mean the projection matrix by view matrix? – Nobody moving away from SE Sep 19 '13 at 19:08
-
I mean that in the fixed pipeline example of gluUnproject usage, GL_MODELVIEW is queried .Does it contain also some 3d object's model matrix? – Michael IV Sep 19 '13 at 19:09
-
The modelview matrix contains the transformation of the model into the worldspace and from the worldspace into eye space, but not the projection. – Nobody moving away from SE Sep 19 '13 at 19:12
-
I know that it doesn't contain the projection.But if I don't reference any particular object,can the model part be just an identity? – Michael IV Sep 19 '13 at 19:14
-
I am not sure if I understood you correctly, but I will answer to what I think you asked: The Model matrix can be an identity matrix, which means that the model and world space are the same. – Nobody moving away from SE Sep 19 '13 at 19:16
1 Answers
1
gluUnproject is usually described as transfroming coordinates from screen space (back) to object space. However, you can always use any matrices you like to get into some other space, so just using the view matrix here would give get you the world space values you seem to care about. The fixed function pipeline of GL never did use a world space explicitely, and always worked directly on the comopsition of the model and the view matrix.

derhass
- 43,833
- 2
- 57
- 78
-
So,based on what you said, I can discard model part if it is world's default (identity)? – Michael IV Sep 19 '13 at 19:10
-
@MichaelIV: yes. the inverse of identity is still identity, so it does not matter if you use use V alone or assume M=I and use V*M as the modelview matrix. – derhass Sep 19 '13 at 19:18
-
Ok,now I get you.It is probably essential if the unprojection is happening in different spaces than the world.Thanks for the clarification. – Michael IV Sep 19 '13 at 19:32