Jump to content


- - - - -

Extracting viewing direction..


6 replies to this topic

#1 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1050 posts

Posted 05 September 2005 - 02:20 PM

Hi! Does anybody know how to extract the viewing direction from an arbitaty camera matrix?

Thanks you!

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 05 September 2005 - 04:10 PM

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...)
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1050 posts

Posted 05 September 2005 - 05:46 PM

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.

#4 Axel

    Valued Member

  • Members
  • PipPipPip
  • 119 posts

Posted 05 September 2005 - 09:31 PM

This should work for any view matrix afaik.

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 06 September 2005 - 05:12 AM

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).
reedbeta.com - developer blog, OpenGL demos, and other projects

#6 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 06 September 2005 - 05:49 AM

The only other thing that would matter is row vs. collum major...
If Prolog is the answer, what is the question ?

#7 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1050 posts

Posted 06 September 2005 - 07:02 AM

Thanks to all of you! It actually works!!! *YAY*





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users