if i have View*Projection is there anyway to get View and Projection back from it?
D3DX matrices
Started by Anddos, Feb 28 2010 07:08 PM
7 replies to this topic
#1
Posted 28 February 2010 - 07:08 PM
#2
Posted 28 February 2010 - 07:28 PM
Only if you had the inverse of one of the matrices, otherwise they are stuck together.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.
#3
Posted 28 February 2010 - 07:31 PM
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.
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.
reedbeta.com - developer blog, OpenGL demos, and other projects
#4
Posted 28 February 2010 - 09:14 PM
That looks very complicated , would you be able to make a sample in D3D format etc
#5
Posted 28 February 2010 - 10:07 PM
No, I don't use D3D. Come on, I gave you the exact equations, just code it up.
reedbeta.com - developer blog, OpenGL demos, and other projects
#6
Posted 28 February 2010 - 11:09 PM
Thats amazing! I never would have thought that was possible, im a lamer.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.
#8
Posted 01 March 2010 - 02:04 AM
Heheh, I know, I'm pretty useless.
reedbeta.com - developer blog, OpenGL demos, and other projects
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












