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?

(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?

glPushMatrix();
glLoadIdentity();
// translations here
// draw model here
glPopMatrix();

That will effectively cancel any transformation done by gluLookAt.

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).]

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.

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

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