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.