Results 1 to 3 of 3

Thread: Third person transforms

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Location
    Centerville, VA
    Posts
    3

    Third person transforms

    I wonder if someone could help me with my transforms:

    I have a setup where the eye is just over and behind the player model (a tank, similar style to the arcade game Cybersled)

    I can strafe and move forward/backward with the tank, and the objects around me translate correctly...but if i move the player model away from the objects and rotate...they seem to stay in place and rotate around each other (around origin 0,0,0), not around the player position...

    My code looks like the following:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // setup initial camera view, slightly above and behind the player model
    gluLookAt(0, 80, -80,
    0, 20, 60,
    0.0, 1.0, 0.0);

    glTranslatef(-player->pos[0], 0, -player->pos[2]);
    glRotatef(-yrot,0.0f,1.0f,0.0f);

    // draw scene objects
    obj = glist;
    while (obj != NULL) {
    glPushMatrix();

    glTranslatef(obj->pos[0], obj->pos[1], obj->pos[2]);
    glCallList(obj->dlist);

    glPopMatrix();

    obj = obj->next;
    }

    // draw player model
    glRotatef(yrot, 0.0f, 1.0f, 0.0f);
    glTranslatef(player->pos[0], 0, player->pos[2]);
    glCallList(player->dlist);

    again, the code works in translating the objects, but rotations are not relative to the player position. any ideas?
    Does the corpse have a familiar face?

  2. #2
    Junior Member Newbie
    Join Date
    May 2001
    Location
    Poland
    Posts
    5

    Re: Third person transforms

    I think, that you must reverse order of the transformations.
    For example:

    glRotate
    glTranslate

    This codeTRANSLATES first, while this code

    glTranslate
    glRotate

    ROTATES first!

  3. #3
    Junior Member Newbie
    Join Date
    May 2001
    Location
    Centerville, VA
    Posts
    3

    Re: Third person transforms

    You were right. Thanks a lot. That totally fixed it. now to code the rest of the game =)
    Does the corpse have a familiar face?

Similar Threads

  1. GLM order of transforms
    By Jubei in forum OpenGL: General
    Replies: 3
    Last Post: 03-31-2012, 07:03 AM
  2. ? View Matrix: 1st person to 3rd person ?
    By Z-Knight in forum OpenGL: Basic Coding
    Replies: 23
    Last Post: 01-12-2009, 10:38 AM
  3. Transforms
    By imported_Shweta in forum OpenGL: General
    Replies: 2
    Last Post: 05-01-2005, 06:43 AM
  4. transforms
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-19-2001, 06:44 AM
  5. Transforms
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-15-2001, 12:37 PM

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