# object space transformations

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

## Recommended Posts

I'm having trouble with object space transformations - I have a standard view/camera matrix that represents the orientation of the camera in world space formed by: [translation] * [X] * [Y] * [Z] where x,y and z are the rotation matrices and translation is the translation matrix with the negated position of the camera. I'm trying to convert this into an object's space, apply another transformation and then find the world space matrix of the camera. I know to get into object space you multiply the view matrix by the inverse of the object space matrix, then I apply the other transformation, but how do I now get the world matrix of the camera at this point?

##### Share on other sites
The View Matrix holds all the data that you might need - Up, Forward, and Left. Take a look at how the View Matrix is constructed when you use a funciton like gluLookAt:

http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/lookat.html

For directX, its very similar.

##### Share on other sites
but can you convert the view matrix to object space and then render the object?, I'm basicaly trying to render a scene through a portal, where the portal is defined by a polygon, a object space matrix and a transformation matrix, I need a way to attach the camera to the polygon then apply the transformation matrix so that the camera is transformed and I can render the scene through the other(transformed) portal side.

##### Share on other sites
The world matrix of a camera is just its inverse.

##### Share on other sites
I tried inverting the camera matrix after transforming it twice but it's not working, my code looks a bit like:

void renderPortal(Camera& camera){   matrix temp = camera.m_matrix;   camera.m_matrix *= portalASpace.getInverse();   camera.m_matrix *= portalTransform;   renderScene(camera);   camera.m_matrix = temp;   renderScene(camera);}

I've left out a lot of stuff like clipping but you can probaly see what I'm trying to do, portalASpace is the portals object space matrix
and the portalTransform is the transformation you want to see through the portal. I'm trying to get it so that the camera can rotate around it axis(and move position), render the scene, then move back to it's original position and orientation and render the scene again.

##### Share on other sites
What is camera.m_matrix? The view-matrix, or the camera's world-space matrix? The camera's world space matrix is equal to the inverse of it's view-space matrix. That, or you can just construct the world-space camera matrix using it's position/orientation.

What is "object space matrix"? There is no such matrix, object space is ... well, object space. Do you mean the inverse of the world matrix?

This is how I do my portal rendering (pseudo-code):
// world space camera matrixmatrix4 viewMatrix = camera.viewMatrix();matrix4 camMatrix = viewMatrix.inverse();camMatrix = portalA.worldMatrix().inverse() * camMatrix;camMatrix = portalB.worldMatrix() * camMatrix;camera.viewMatrix(camMatrix.inverse());renderScene(camera);// restore to old view matrixcamera.viewMatrix(viewMatrix);

Note that you'll want portal B to be rotated by 180 degrees since you want to come out of it's front, not back. Meaning, without rotating it 180 degrees, when you go through portal A, you'll end up behind portal B, instead of in front of it.

##### Share on other sites
Quote:
 What is camera.m_matrix?

(I think) it's the view matrix, what is the camera's world space matrix? I thought you only had one matrix for a camera representing its orientation in the world(the first 3x3 are the unit vectors representing the camera's orientation in world space and the vector at the bottom is the translation).

Quote:
 What is "object space matrix"?

I use a polygon for the portal and then transform it by a matrix - this is what I was referring to.

Quote:
 Do you mean the inverse of the world matrix?

yes.

[Edited by - staticVoid2 on May 29, 2008 5:23:40 PM]

##### Share on other sites
Quote:
Original post by staticVoid2
Quote:
 What is camera.m_matrix?

(I think) it's the view matrix, what is the camera's world space matrix? I thought you only had one matrix for a camera representing its orientation in the world(the first 3x3 are the unit vectors representing the camera's orientation in world space and the vector at the bottom is the translation).

No, the view-space matrix is the opposite (inverse) of the camera's world matrix. Multiplying a world-space point by the view matrix puts it in local eye-space (camera-space/view-space). Thus, to put it back into world space, you'd use the inverse of the view-matrix, i.e. the world-matrix for the camera.
Quote:

Quote:
 What is "object space matrix"?

I use a polygon for the portal and then transform it by a matrix - this is what I was referring to.

This would be your world-matrix for the portal polygon.
Quote:

Quote:
 Do you mean the inverse of the world matrix?

yes.

The inverse of the world matrix is what you'd use to get a world-space point into local object-space of an object. So it's not what you're talking about above. Did you try the (pseudo-)code I mentioned?

##### Share on other sites
Quote:
 Did you try the (pseudo-)code I mentioned?

I tried it but it's still not working. how would I get the position of the camera after these two transformations? the way I've done it is by getting the inverse of the view matrix and then getting the bottom translation vector. If this is right then when I rotate my camera the transformed position of the camera is changing, should that happen? I'm doing this to try and debug but I also need the position to create the new world space view frustum of the camera.

##### Share on other sites
Do we speak about column vectors (e.g. OpenGL) or row vectors (e.g. D3d)?

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×