Jump to content
  • Advertisement
Sign in to follow this  
pasman

Separate model and view matrices

This topic is 4853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!