Lwjgl camera causing movement to be mirrored

Posted by pangaea on Game Development See other posts from Game Development or by pangaea
Published on 2013-06-26T00:49:18Z Indexed on 2013/06/26 4:29 UTC
Read the original article Hit count: 203

Filed under:
|
|

I'm having a problem in that everything is rendered and the movement is fine. However, everything seems to be mirrored. In the sense that the TriangleMob should move towards me, but it doesn't instead it mirrors my action. I move forward the TriangleMob moves backwards. I move left, it moves right. I move backwards, it moves forward.

The code works if I do this

glPushMatrix();
    glTranslatef(-position.x, -position.y, -position.z);
    glCallList(objectDisplayList);
glPopMatrix();

However, I'm scared this will cause a problem later on.

I suppose the code works. However, shouldn't the call be

    glPushMatrix();
        glTranslatef(position.x, position.y, position.z);
        glCallList(objectDisplayList);
    glPopMatrix();

I think the problem could be caused by how I'm doing the camera, which is this

    glLoadIdentity();
        glRotatef(player.getRotation().x, 1.0f, 0.0f, 0.0f);
        glRotatef(player.getRotation().y, 0.0f, 1.0f, 0.0f);
        glRotatef(player.getRotation().z, 0.0f, 0.0f, 1.0f);
    glTranslatef(player.getPosition().x, player.getPosition().y, player.getPosition().z);

© Game Development or respective owner

Related posts about java

Related posts about camera