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 8 of 8

Thread: What is the definition of gluLookAt?

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    4

    What is the definition of gluLookAt?

    The description of the gluLookAt is as follows:
    Let
    F=centerX-eyeXcenterY-eyeYcenterZ-eyeZ
    Let UP be the vector upXupYupZ.
    Then normalize as follows:
    f=FF
    UP″=UPUP
    Finally, let s=fUP″, and u=sf.
    M is then constructed as follows:
    M=s⁡0s⁡1s⁡20u⁡0u⁡1u⁡20-f⁡0-f⁡1-f⁡200001 //??????
    gluLookAt is equivalent to
    glMultMatrixf(M);
    glTranslated(-eyex, -eyey, -eyez);



    Can you explain the description above?Especially the define of M,the line with ????.
    Thank you very much.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,101
    Have a read of this
    http://www.songho.ca/opengl/gl_transform.html

    gluLookAt is just a shorthand to create the view model matrix

  3. #3
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    4
    Thank you for your help,but I have to use gluLookAt in my program.Can you explain the function?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    He just linked you to a very detailed explanation of how transforms work and what it does.

    And no, you don't "have to use gluLookAt".

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    It would be interesting to know what exactly the OP doesn't get about the function. Any specific questions or are you just not understanding anything at all?

  6. #6
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,067
    I hope a concrete implementation (from MESA3D) would help
    Code C:
    gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx,
          GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy,
          GLdouble upz)
    {
        float forward[3], side[3], up[3];
        GLfloat m[4][4];
     
        forward[0] = centerx - eyex;
        forward[1] = centery - eyey;
        forward[2] = centerz - eyez;
     
        up[0] = upx;
        up[1] = upy;
        up[2] = upz;
     
        normalize(forward);
     
        /* Side = forward x up */
        cross(forward, up, side);
        normalize(side);
     
        /* Recompute up as: up = side x forward */
        cross(side, forward, up);
     
        __gluMakeIdentityf(&m[0][0]);
        m[0][0] = side[0];
        m[1][0] = side[1];
        m[2][0] = side[2];
     
        m[0][1] = up[0];
        m[1][1] = up[1];
        m[2][1] = up[2];
     
        m[0][2] = -forward[0];
        m[1][2] = -forward[1];
        m[2][2] = -forward[2];
     
        glMultMatrixf(&m[0][0]);
        glTranslated(-eyex, -eyey, -eyez);
    }

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    The thing is, Alfonse is right in saying you don't need to use gluLookAt, because if you get the math behind it, you can write up a function yourself. I suspect the OP doesn't have a sufficient mathematical basis.

  8. #8
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    4
    This is exactly what I need!!!Thank you so much!
    鄙视狗眼看人低。

Posting Permissions

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