Thread: Does it matter what gluLookat's center value is?

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    Does it matter what gluLookat's center value is?

    Like when I'm just testing I change the

    Code:
        gluLookAt(0.0, 0.0, 10.0,
                  0.0, 0.0, -1.0,
                  0.0, 1.0, 0.0);
    to
    Code:
        gluLookAt(0.0, 0.0, 10.0,
                  0.0, 0.0, -100.0,
                  0.0, 1.0, 0.0);
    and it doesn't make a difference, at least when displaying simple shapes. Does the magnitude of the center vector matter, or is it like the up vector where it can be either negative, positive, or zero despite the magnitude.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm not familiar with the parameters to that function or I could tell you just from a pure '3D math' standpoint.

    Essentially the look at functions in both GL and D3DX build a RH or LH look at matrix. If you have a book on 3D graphics you will probably see this derived in the book at some point.
    You can also google for 'look-at matrix'

    I use the look at matrix in my space 'project' (not really a game yet per se) for flyby camera views. As the object moves I compute the new look at matrix each frame and set the view matrix to that matrix. Works like a charm.
    In order to offset the camera a bit to make the effect complete I set the viewpoint at some point along the object's velocity vector and randomize the offsets for up and right. This produces a viewpoint just ahead and above/below or right/left of the object as it flies by the camera.
    Last edited by VirtualAce; 04-07-2007 at 12:51 PM.

  3. #3
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    The center vector is the look at vector, and is normalized to a length of 1.0.

  4. #4
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    The definition of gluLookAt is:
    Code:
    gluLookAt(eyePosX, eyePosY,  eyePosZ,
                      viewDirX, viewDirY, viewDirZ,
                      upX, upY, upZ)
    Here you can see that the middle vector is actually made up of directions, and there's not difference between -1 and -100 (as for directions). Or, like jverkoey has said, the vector is normalized to 1

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Has anyone tried XP media center ed?
    By andyhunter in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 12-20-2004, 06:16 PM
  2. Stopwatch program (need help!)
    By modnar in forum C Programming
    Replies: 9
    Last Post: 03-22-2004, 12:42 AM
  3. display at the center of the screen
    By leinad079 in forum C Programming
    Replies: 2
    Last Post: 04-11-2003, 08:51 PM
  4. Neverending matter?
    By d00b in forum A Brief History of Cprogramming.com
    Replies: 41
    Last Post: 06-17-2002, 02:10 PM
  5. Center Text
    By Jperensky in forum C Programming
    Replies: 4
    Last Post: 03-31-2002, 07:40 AM