Results 1 to 2 of 2

Thread: How to get the direction of the camera?

  1. #1
    Senior Member Frequent Contributor ehsan2004's Avatar
    Join Date
    Jun 2004
    Location
    Iran
    Posts
    645

    How to get the direction of the camera?

    Hi
    How can i get the direction of the camera from the modelview matrix? Note that i'm using from the function gluLookAt()to move and rotate the camera.
    -Ehsan-

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: How to get the direction of the camera?

    In eye space it's always (0, 0, -1, 0).

    For a right-handed(!) camera system, back into model space you would need to transform that by the inverse of the modelview:

    MV * v = (0, 0, -1, 0)T;
    MV^-1 * MV * v = MV^-1 * (0, 0, -1, 0)T;
    v = MV^-1 * (0, 0, -1, 0)T;

    Only rotations are interesting, that gives MV^-1 == (MV)T and the matrix just needs to be 3x3.

    v = (MV)T * (0, 0, -1)T;

    The result of that is the negated first three comonents of the third row of the current modelview matrix.

Similar Threads

  1. Replies: 10
    Last Post: 10-16-2016, 01:53 PM
  2. move camera in the direction its looking
    By xorserq in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-01-2014, 08:42 PM
  3. Move the camera to the direction it points
    By deshan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-08-2011, 01:23 PM
  4. camera direction vector in shader?
    By devel in forum OpenGL: GLSL
    Replies: 1
    Last Post: 04-24-2007, 12:26 PM
  5. fly around program - camera direction
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-11-2004, 04:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean