math & physics
mihail121 at September 5th, 2005 10:20 — #1
Hi! Does anybody know how to extract the viewing direction from an arbitaty camera matrix?
reedbeta at September 5th, 2005 12:10 — #2
If you are using OpenGL, the viewing direction is the negative of the 3rd row of the viewing matrix. (This is assuming your viewing transform uses only translations and rotations, not anything weird...)
mihail121 at September 5th, 2005 13:46 — #3
Well the problem is i need to be able to extract viewing directions from ALL kind of viewing matrices, not only from the OGL one or from UVN one, etc. I need a way to figure a viewing vector, only looking at the camera matrix.
axel at September 5th, 2005 17:31 — #4
This should work for any view matrix afaik.
reedbeta at September 6th, 2005 01:12 — #5
What I meant by saying "assuming you are using OpenGL" is that it depends on the eye space convention. OpenGL uses a right-handed eye space, so the -Z axis is in front of the eye; in D3D, the eye space is left-handed, so the +Z axis is in front (and in this case you would just take the third row rather than its negative).
anubis at September 6th, 2005 01:49 — #6
The only other thing that would matter is row vs. collum major...
mihail121 at September 6th, 2005 03:02 — #7
Thanks to all of you! It actually works!!! *YAY*