D3DX matrices

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 28, 2010 at 19:08

if i have View*Projection is there anyway to get View and Projection back from it?

7 Replies

Please log in or register to post a reply.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Feb 28, 2010 at 19:28

Only if you had the inverse of one of the matrices, otherwise they are stuck together.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Feb 28, 2010 at 19:31

Yes, invert the matrix, then IIRC you can extract the view axes and position as follows:.

XAxis = Homogenize(Point(1, 0, 0, 1) * InverseViewProjection) - Homogenize(Point(0, 0, 0, 1) * InverseViewProjection)
YAxis = Homogenize(Point(0, 1, 0, 1) * InverseViewProjection) - Homogenize(Point(0, 0, 0, 1) * InverseViewProjection)
ZAxis = Homogenize(Point(0, 0, 1, 1) * InverseViewProjection) - Homogenize(Point(0, 0, 0, 1) * InverseViewProjection)
CameraPos = Homogenize(Point(0, 0, -1, 0) * InverseViewProjection)

Here “Homogenize” means convert from a 4D point back to a 3D one by dividing by w. These equations may be able to be simplified a bit; I’m not sure. Also be wary of the LHS/RHS conversion, there may be a sign change needed someplace with respect to the Z axis. Anyway, once you have the camera position and axes you can easily reconstruct the view matrix, then Inverse(View) * ViewProjection gets you the projection.

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Feb 28, 2010 at 21:14

That looks very complicated , would you be able to make a sample in D3D format etc

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Feb 28, 2010 at 22:07

No, I don’t use D3D. Come on, I gave you the exact equations, just code it up.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Feb 28, 2010 at 23:09

Thats amazing! I never would have thought that was possible, im a lamer.

Fe8a5d0ee91f9db7f5b82b8fd4a4e1e6
0
JarkkoL 102 Mar 01, 2010 at 00:07

Oh come on Reedbeta, what kind of staff member you think you are that you don’t code stuff for people in their preferred environment and language, huh?! ;)

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Mar 01, 2010 at 02:04

Heheh, I know, I’m pretty useless. ;)