Skip to main content
GameDev.net gamedev.net
🔒 Locked

Separate model and view matrices

Started by pasman Aug 8, 2005 at 4:06 AM 1 replies 1.3k views
dimebolt
dimebolt
Quote:
Original post by pasman
Hi, how can I separate the View and the Model matrices from ModelView matrix? I need this for my shading system so I can pass them to some shaders. Thank you


You can't use OpenGL to do that for you. I keep track of these myself. I don't know how the design of your application is, so I can't comment on your case. However, I can explain what I do. I have (scene graph) objects for all entities involved: camera's and geometrical shapes. In the rendering stage a 'model' matrix (i.e. a matrix that transforms the vertices of the object from object coordinate system to global coordinate system) has been calculated for each object. To pass both view and model matrix to the shader of a specific object, I need to use that objects model matrix (obviously) and the inverse of the camera's model matrix as view matrix. Alternatively, if you don't have camera objects like this, to get the viewmatrix you can just readout the matrix from the stack after calling gluLookAt (or whatever functions you use to setup the viewing). You'll still need to keep track of the model matrices yourself, though.

Tom
blizzard999
blizzard999
Yes...GL does not use 'world' and 'view' matrices but only one MODELVIEW.
If you need separate matrices you have to implement your own and pass them to GL

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.