Results 1 to 5 of 5

Thread: help me NOT use gluLookAt()

  1. #1
    Member Newbie
    Join Date
    Jul 2002
    Posts
    42

    help me NOT use gluLookAt()

    I want to track an object and follow its orientations as well.

    So for translation I know -x, -y, -z is the same as moving the camera +x, +y, +z. And rotations are backwards as well?

    If I have the UP, FORWARD, RIGHT unit vectors of the object I want to follow and imitate its orientation, how do I use these vectors?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2002
    Location
    St. Louis, MO USA
    Posts
    177

    Re: help me NOT use gluLookAt()

    Remember that moving the camera in a direction is the same as moving everything in the world the opposite direction. You do the matrix transformation for the camera just like you would for your objects, except in reverse. Here is a little class I just made up to help solve the problem. It stores the orientation as a forward, up, and right vector. LookAt() just modifies the vectors. DoTransformation modifies the modelview matrix.

    class Camera
    {
    public:


    void LookAt(Point3D * point);
    void DoTransformation()

    //camera's origin
    Point3D m_origin;

    //orientation vectors
    Point3D m_right;
    Point3D m_up;
    Point3D m_forward;

    }

    void Camera::LookAt(Point3D * point)
    {

    m_forward = *point - morigin;
    m_forward.Normalize();

    m_up.Set(0,1,0);
    m_right = CrossProduct(m_up,m_forward);
    m_up = CrossProduct(m_forward, m_right);

    m_up.Normalize();
    m_right.Normalize();
    }

    void Camera: oTransformation()
    {
    //make a matrix with the 3x3 part being the //camera's 3 orientation vectors.
    Matrix viewtransform;

    //using some custom matrix functions
    viewtransform.MakeFromVectors(m_right, m_up, m_forward);

    viewtransform.Translate(m_origin.x, m_origin.y, morigin.z);

    glMultMatrixd(viewtransform.data);

    }

    [This message has been edited by ioquan (edited 07-19-2002).]

  3. #3
    Member Newbie
    Join Date
    Jul 2002
    Posts
    42

    Re: help me NOT use gluLookAt()

    That didn't work for some reason.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: help me NOT use gluLookAt()

    "that didn't work" doesn't describe the problem

    cheers,
    John

  5. #5
    Member Newbie
    Join Date
    Jul 2002
    Posts
    42

    Re: help me NOT use gluLookAt()

    yeah I know what you mean, but its hard to describe goofy rotations. I got a solution going on another thread that works. I think this approach will/should work and I might need it for some tracking stuff I'm doing, so I'll keep you posted if I get it working. On thing that won't work at least when I tried it is the combination of the translation into the matrix at the same time. I found that this translation for the camera has to come after the rotation for some reason. Other 3d world objects its fine to combine the translation and the rotation in the same matrix and I do that in practice.

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