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

Thread: glulookat not working :-(

  1. #1

    glulookat not working :-(

    Could someone please please please tell me what in the world is wrong with this????
    Thanks,
    Jesse www.laeuchli.com/jesse/

    void GLEngine::turn(float x)
    {
    float tempx=lookDir.x-eye.x;
    float tempz=lookDir.z-eye.z;
    float rad=x*0.01745f;
    float newx=tempx*cos(rad) - tempz*sin(rad);
    float newz=tempz*cos(rad) + tempx*sin(rad);
    lookDir.x=newx+eye.x;
    lookDir.z=newz+eye.z;
    gluLookAt(lookDir.x, lookDir.y, lookDir.z,
    eye.x, eye.y, eye.z,
    0.0, 1.0, 0.0);
    }
    void GLEngine::move(float x)
    {
    lookDir.z+=x;
    gluLookAt(lookDir.x, lookDir.y, lookDir.z,
    eye.x, eye.y, eye.z,
    0.0, 1.0, 0.0);
    }

  2. #2
    Junior Member Newbie
    Join Date
    May 2000
    Location
    cologne/germany
    Posts
    23

    Re: glulookat not working :-(

    I think the first 3 parameters are the coords of the eye, the next 3 ones the reference point and than there comes the up vector...

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: glulookat not working :-(

    You don't load the identity matrix before each call to gluLookAt. gluLookAt doesn't load the matrix stack with the generated matrix, it multiplies it, and therefore you need to reset the matrix each time you generate a new look-at matrix.

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2000
    Location
    Turin
    Posts
    269

    Re: glulookat not working :-(

    gluLookAt( eye.x, eye.y,eye.z, target.x,target.y,target.z, vect.x,vect.y,vect.z);

    that's the way lookat works....

    C U

    rIO
    [rIO^sPINNING kIDS] - rio@nospam.spinningkids.org

    -/- This is a signature virus. Add it to your signature. Help it spreading! -/-

  5. #5

    Re: glulookat not working :-(

    so my code should look like this?
    void GLEngine::turn(float x)
    {
    float tempx=lookDir.x-eye.x;
    float tempz=lookDir.z-eye.z;
    float rad=x*0.01745f;
    float newx=tempx*cos(rad) - tempz*sin(rad);
    float newz=tempz*cos(rad) + tempx*sin(rad);
    lookDir.x=newx+eye.x;
    lookDir.z=newz+eye.z;
    gluLookAt(eye.x, eye.y, eye.z,
    lookDir.x, lookDir.y, lookDir.z,
    0.0, 1.0, 0.0);
    }
    void GLEngine::move(float x)
    {
    lookDir.z+=x;
    gluLookAt(eye.x, eye.y, eye.z,
    lookDir.x, lookDir.y, lookDir.z,
    0.0, 1.0, 0.0);
    }
    I tried that, but it still didn't work right....

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: glulookat not working :-(

    Still can't see any glLoadIdentity() before gluLookAt().

  7. #7

    Re: glulookat not working :-(

    sorry, I forgot to post them. I did put them in.

Posting Permissions

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