Jump to content
  • Advertisement
Sign in to follow this  
D3DXVECTOR3

Help me identify these matrices created by...

This topic is 4417 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

gluPerspective = world matrix!? gluLookAt = view matrix!? GL_MODELVIEW_MATRIX = model*view!? if this all is true then why is my world*view != GL_MODELVIEW_MATRIX :( im comming from direct3d and i got my matrices with: pd3dDevice->GetTransform(D3DTS_WORLD, ...) pd3dDevice->GetTransform(D3DTS_VIEW, ...) pd3dDevice->GetTransform(D3DTS_PROJECTION, ...) edit: ehm... i just found that gluPerspective sets up a perspective projection matrix and not a world matix... now to find out how to create a world matrix... [Edited by - D3DXVECTOR3 on June 11, 2006 2:09:55 PM]

Share this post


Link to post
Share on other sites
Advertisement
The concept of modelview matrix in openGL combines the camera/view transformation, which you can create yourself or use gluLookAt, and the object/world transformation which is for rotating and positioning the objects in your scene, thus model + view.

Creating your "world matrix" would likely be any combination of glTranslatef and glRotatef to rotate and position your objects in the scene. To allow adjustable viewing in your scene with a camera, you'd apply the "view" matrix from your camera at the start of the render loop. Something like:


// clear the buffers and reset modelview matrix
glClear(...)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// set your "view" transformation first
camera.applyView();

// or

gluLookAt(...);

// render objects

glTranslatef(...);
glRotatef(...);

object.draw();


Hope that helps!

Share this post


Link to post
Share on other sites
thx for the reply, but my problems is that I need to have the view, model and proj matrix seperate to use with shaders.

if I have these 3 main matrices:World, View, Projection I can build any other matrices. inverse, transpose etc

[Edited by - D3DXVECTOR3 on June 13, 2006 12:02:51 AM]

Share this post


Link to post
Share on other sites
Then apply your view transformation (using a camera object, a combination of glTranslatef/glRotatef, or whatever else you choose), then retrieve and store the matrix:


// clear the buffers and reset modelview matrix
glClear(...)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

float viewMatrix[16];
// set your "view" transformation first
camera.applyView();
glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);

// clear it again
glLoadIdentity();

// set your "world" matrix transformations
glTranslatef(...)
glRotatef(...)
// whatever else...

float worldMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, worldMatrix);


As a side note, if you're using a camera object (I do), you'd probably already have the matrix stored somewhere, so retrieving it would be a matter of grabbing data from the class, but that's extra. :P

Is that how you wanted it?

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!