Help me identify these matrices created by...
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]
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:
Hope that helps!
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 matrixglClear(...)glMatrixMode(GL_MODELVIEW);glLoadIdentity();// set your "view" transformation firstcamera.applyView();// orgluLookAt(...);// render objectsglTranslatef(...);glRotatef(...);object.draw();
Hope that helps!
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]
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]
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:
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?
// clear the buffers and reset modelview matrixglClear(...)glMatrixMode(GL_MODELVIEW);glLoadIdentity();float viewMatrix[16];// set your "view" transformation firstcamera.applyView();glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);// clear it againglLoadIdentity();// set your "world" matrix transformationsglTranslatef(...)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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement