Results 1 to 6 of 6

Thread: Camera problem!

  1. #1

    Camera problem!

    I create a camera using gluLookAt which works excellent. But the problems is that when I try to translate an ms3d model using glTranslatef (i do Push and pop the matrix and load the identity as normal), when I say glTranslatef(10,0,0) for example, it translates on the X axis -10! This doesnt happen when I translate on the Y axis or the Z axis. Im terribly sure that I am not transforming the Projection matrix, so it is ok. What may it be the problem? Currently, to solve this, I simply invert the X value.

    Ideas?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Camera problem!

    (i do Push and pop the matrix and load the identity as normal)
    Load the identity matrix? That doesn't sound normal at all. Do you mean like this?
    Code :
    glPushMatrix();
    glLoadIdentity();
    // translations here
    // draw model here
    glPopMatrix();
    That will effectively cancel any transformation done by gluLookAt.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: Camera problem!

    and remember, when translating your "camera", you are usually in modelview mode. when you want to move your "camera" 10 units to the left, you actually translate your geometry to the right.

    EDIT: are you doing this for a milkshape plugin? or are you writing a standalone renderer? using Win32 or glut? just curious...i had some problems with my plugin.

    jebus

    [This message has been edited by jebus (edited 11-01-2002).]

  4. #4

    Re: Camera problem!

    Ok, let me explain it better:

    I have a camera class which sets the projection matrix. The camera class has no problems, it works as it should work. I have made an ms3d renderer for my engine, which includes some setPosytion,rotation,etc methods. These methods update the pos,rot,scale Vec3 structures with the one supplied and I transform the object before rendering it like this:

    glPushMatrix();
    glLoadIdentity();
    ...transform, rotate, scale, etc
    ...render
    ...blah blah

    glPopMatrix();

    I do switch to modelview after setting up the pespective with gluPerspective, so that is not the case.

  5. #5
    Member Contributor
    Join Date
    Jul 2001
    Location
    Sherbrooke
    Posts
    95

    Re: Camera problem!

    As Bob said
    calling glLoadIdentity after your PushMatrix cancel all previous tranformations including the camera's tranformation
    And I think gluLookAt should be used in the ModelView matrix before any other transformation (that's what I do and it works)
    and again...no glLoadIdentity needed...

    ------------------------------------
    Evil-Dog
    *Let's have a funny day*
    Let's have a funny day

  6. #6
    Member Contributor
    Join Date
    Jul 2001
    Location
    Sherbrooke
    Posts
    95

    Re: Camera problem!

    I do like this

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(...);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(...);
    and then draw your object with thier own transformation
    ...
    glPushMatrix();
    glDoTranformations();
    Draw();
    glPopMatrix();
    ...

    ------------------------------------
    Evil-Dog
    *Let's have a funny day*
    Let's have a funny day

Similar Threads

  1. camera problem
    By cod999 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-04-2014, 11:27 AM
  2. Camera problem!
    By hannahbanana in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-25-2013, 06:26 PM
  3. camera problem
    By zoodoo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-24-2012, 12:25 AM
  4. The FPS Camera problem
    By kamimail in forum OpenGL: General
    Replies: 0
    Last Post: 05-10-2010, 07:12 AM
  5. Problem with Camera ?
    By Ngoc Sang in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-11-2008, 10:53 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