### Screen/World projection and conversion, in and outside Ogre

Posted:

**Wed Jul 03, 2013 3:40 pm**Hi!

I have a 3D point in world coordinates, lets say. I then project it onto the screen with
. Then the position on the screen is of course ((point_screen.x/2+0.5) * Width, (1-(point_screen.y/2+0.5)) * Height). The Z coordinate of the pixel I get when rendering the image as a depth map.

My question is how to do the reverse transformation: If I find a pixel on the screen I'm interested in, with coordinates (X,Y,Z), I then declare my Vector3 as
How do I get the corresponding point_world? Is it just this? :
I'm asking because I don't understand how it works in the first place that you have a Vector3, and you multiply it by 2 Matrix4's. I thought that in matrix algebra you can't multiply matrixes that don't have the corresponding "common" dimension equal. Is there something in the blender internals that eliminates a column and a row?

And, most importantly, I need to do these two operations (world point to screen point and reverse) outside blender. Assuming I can copy the two matrixes (viewmatrix and projection matrix), how do I use them in the equation to multiply them by a 3x1 Vector?

This is really important for my project so I thank in advance anyone willing to help.

I have a 3D point in world coordinates, lets say

Code: Select all

`Vector3 point_world; `

Code: Select all

` Vector3 point_screen = camera->getProjectionMatrix() * (camera->getViewMatrix() * point_world); `

My question is how to do the reverse transformation: If I find a pixel on the screen I'm interested in, with coordinates (X,Y,Z), I then declare my Vector3 as

Code: Select all

```
Vector3 point_screen;
point_screen.x = (X/Width-0.5)*2;
point_screen.y = ((1-(Y/Height))-0.5)*2;
point_screen.z = Z;
```

Code: Select all

`point_world = camera->getViewMatrix().inverse() * (camera->getProjectionMatrix().inverse() * point_screen) `

And, most importantly, I need to do these two operations (world point to screen point and reverse) outside blender. Assuming I can copy the two matrixes (viewmatrix and projection matrix), how do I use them in the equation to multiply them by a 3x1 Vector?

This is really important for my project so I thank in advance anyone willing to help.