Results 1 to 3 of 3

Thread: gluLookat

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Brazil
    Posts
    16

    gluLookat

    Hello,

    Ok, I'm having some real problem trying to make this work

    I figured, first three parameters (eye) are the position of the "camera", the next three (center) are the vector in wich the "camera" is looking, and the last three (up) is the vector that indicates the up direction.

    If I move only the eye coordinates, the camera "flips" direction when I cross the center vector. Thatīs predictable. So I have to move the center vector whenever I move the eye vector. Thatīs fine.

    But when I rotate, I move the center vector. So now, when I try to move the eye ahead, I can't just increse the z position of the eye vector, because I ain't really aligned to the world

    So far so good? So I have to move all three coordinates in eye vector to move forward, right? What are the equations to that? I did it once, but I guess I forgot how to do it...

    Thanks,
    Matheus Degiovani.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Re: gluLookat

    Put your code on the forum; only the draw routine.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    London
    Posts
    14

    Re: gluLookat

    If you want to you can use this procedure.

    GLvoid glRotation(GLfloat ox, GLfloat oy, GLfloat oz, GLfloat rx, GLfloat ry, GLfloat rz,
    GLfloat *nx, GLfloat *ny, GLfloat *nz)
    {
    GLfloat tx[2], ty[2], tz[2];
    tx[0] = ox;
    ty[0] = (oy*((GLfloat)cos(rx/(180/3.142))) - (oz*((GLfloat)sin(rx/(180/3.142)))));
    tz[0] = (oy*((GLfloat)sin(rx/(180/3.142))) + (oz*((GLfloat)cos(rx/(180/3.142)))));
    tx[1] = (tx[0]*((GLfloat)cos(ry/(180/3.142))) + (tz[0]*((GLfloat)sin(ry/(180/3.142)))));
    ty[1] = ty[0];
    tz[1] = -(tx[0]*((GLfloat)sin(ry/(180/3.142))) + (tz[0]*((GLfloat)cos(ry/(180/3.142)))));
    *nx = (tx[1]*((GLfloat)cos(rz/(180/3.142))) - (ty[1]*((GLfloat)sin(rz/(180/3.142)))));
    *ny = (tx[1]*((GLfloat)sin(rz/(180/3.142))) + (ty[1]*((GLfloat)cos(rz/(180/3.142)))));
    *nz = tz[1];
    }

    Let me explain the paramaters....

    ox, oy, oz what axis rotation takes place on. Must be 0, 0, 1 or 0, 0, -1;
    rx, ry, rz is the variables that are used to for the rotation.
    nx, ny, nz the result of the rotation. nx, ny, nz are going to be used as your velocity additions for the x, y, z.

    Example:

    glRotation(0, 0, -1, cam.rx, cam.ry, cam.rz, &cam.tx, &cam.ty, &cam.tz);

    I hope that this helps.

Similar Threads

  1. gluLookAt
    By CoolBeanJ in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-27-2011, 11:19 PM
  2. how to use gluLookAt()
    By vamsee kanth in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-13-2004, 02:43 AM
  3. gluLookAt
    By littledevore in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-22-2001, 10:46 AM
  4. gluLookat , where to use it ?
    By cartilago in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 05-24-2001, 02:32 PM
  5. gluLookAt
    By Lord Chaos in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 08-06-2000, 06:50 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
  •  
Proudly hosted by Digital Ocean