Results 1 to 3 of 3

Thread: Up-Vector of gluLookAt( ... );

  1. #1
    Member Newbie
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    37

    Up-Vector of gluLookAt( ... );

    Please help me to resolve the following issue:

    Objective:
    Trying to make the camera follow an object in 3d space.

    For every DrawGLScene() frame, I'm calculating 6 positions w.r.t to the object's coords(x,y,z) for 6 Views of the object. i.e Top, Bottom, Left, Right, Front & Rear Views respectively.

    The user can "switch" ( i.e to say jump ) between different views.

    I'm trying to interpolate (linear) b/w these jumps so that Camera "softly" shifts b/w 2 camera postions.

    Problem is with the "Up-Vector", which I'm trying to calculate for every frame.

    Its a bit tilted and "attached" to the object's co-ordinate system.

    For TOP & BOTTOM VIEWS, UP-VECTOR = 1,0,0 ;
    For the Other 4 views, UP_VECTOR = 0,1,0 ;

    I'm performing the following operations for calculating the "Up-Vector" and passing it to gluLookA(...) function :-

    Vector Camera(cx,cy,cz);
    Vector Object(ox,oy,oz);

    // projection of the camera-location on
    // object plane ( || to X-Z plane)
    Vector Project(cx,oy,cz);

    Vector Look = Camera - Object;

    // This is from projected point
    // to the object.
    Vector Base = Project - Object;

    // This is from Camera to Projected point.
    Vector Height = Camera - Project;

    Now after calculating the vectors, I'm first calculating the right vector like this:
    ( '^' - overloaded for cross - product )
    Right = Height^Look;
    Up = Right^Look;
    Up.Normalize(); ---> Pass this (Up.x, Up.y, Up.z ) to gluLookAt.

    Thanks.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    145

    Re: Up-Vector of gluLookAt( ... );

    Have you looked at quaternions?

    P.S. Please don't cross post.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2004
    Posts
    13

    Re: Up-Vector of gluLookAt( ... );

    As it stands, your up-vector calculations fall apart when you are looking along the y-axis through the object, because you are always projecting onto the XZ plane... but I guess you already knew that.

    Switching to a different up-vector (1,0,0) as you indicated is the easiest solution. I would just linearly interpolate the up-vectors (from 1,0,0 to 0,1,0) in the same way that you interpolate the camera positions, rather than trying to determine the up-vector from the interpolated camera and object coordinates. Just make sure to normalize the interpolated up-vectors.

    Don.

Similar Threads

  1. gluLookAt up Vector cross product
    By macsam in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-10-2017, 09:27 AM
  2. Replies: 1
    Last Post: 10-01-2009, 06:04 PM
  3. Up-Vector of gluLookAt( ... );
    By OGL_PGR in forum OpenGL: General
    Replies: 0
    Last Post: 08-29-2005, 03:03 AM
  4. gluLookAt an' the Up vector
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-19-2004, 11:58 AM
  5. Replies: 2
    Last Post: 01-07-2004, 11:48 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