Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: gluLookAt up Vector cross product

  1. #1
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30

    gluLookAt up Vector cross product

    Hi,

    in the example for gluLookAt it has
    gluLookAt( 4.0,2.0, 1.0, 2.0, 4.0, -3.0, 2.0, 2.0, -1.0)

    The Up vector 2.0, 2.0, -1.0 is the cross product of 4.0,2.0, 1.0, and 2.0, 4.0, -3.0

    I get the cross product to be 10, 14, 12

    help!

    MacSam

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,167
    What are you trying to accomplish? What you're doing doesn't make sense.

    Check out the man page: gluLookAt

    Code cpp:
    void gluLookAt( GLdouble eyeX,  
                    GLdouble eyeY,
                    GLdouble eyeZ,
                    GLdouble centerX,
                    GLdouble centerY,
                    GLdouble centerZ,
                    GLdouble upX,
                    GLdouble upY,
                    GLdouble upZ );

    The first 3 parameters define a position (in WORLD space).
    The 2nd 3 parameters define a position (in WORLD space).
    The 3rd 3 parameters define a vector (in WORLD space).

    Take (center - eye), normalize it, and you've defined a unit vector pointing "forward" in EYE-SPACE (i.e. the direction your camera is looking). However, to define a coordinate space transform, this is unconstrained. You need to know what direction is "up" and what is "right". The "up" parameters give you the former, and the right-hand rule (the cross product you mention) implicitly gives you the latter.

    If you're determined to apply the cross product here, try:

    Code glsl:
    forward_vec = normalize( center - eye );     // This is the eye-space -Z axis (in WORLD space)
    up_vec      = normalize( up );               // This is the eye-space +Y axis (in WORLD space)
    right_vec   = cross( forward_vec, up_vec );  // This is the eye-space +X axis (in WORLD space)
    Last edited by Dark Photon; 06-10-2017 at 09:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •