11-14-2003, 01:11 AM

Hello,

It seames that Rotating and Translating is one of the toughest parts for a beginner in opengl.

I am Trying to attach the view to a model for quite a while now with now success. I have read quit alot of articles to but just can't get it figured out.

So in other words i have a view (camera) gluLookAt or just loading the identity (glLoadIdentity) and then translate and rotate the view along with the model.

the model(object like car, plane, first person etc..) is translating and rotating like i want it to. Pritty much with this simple formula:

x += sinf(direction)*speed;

y += cosf(direction)*speed;

and roateted correclty around it's origin axis.

now to make a more clear question. How can i let the camera rotate around the same point x,y,z as the model ?

i tried:

glLoadIdentity();

glRotatef(objroll, 0.0, 0.0, -1.0);

glRotatef(objpitch, -1.0, 0.0,0.0);

gluLookAt(x,y,z, lookx, looky, lookz, 0, 1, 0);

.

.

Rotate & Translate model

and:

glLoadIdentity();

glRotatef(objroll, 0.0, 0.0, -1.0);

glRotatef(objpitch, -1.0, 0.0,0.0);

glTranslatef(x,y,z);

gluLookAt(x,y,z, lookx, looky, lookz, 0, 1, 0);

.

.

Rotate & Translate model

But a soon as the model(object) has rotated to some degrees around the x or y axis the camra rotates either around a differen origin or rotates only correct around the z axis.

I hope my question is some what clear.

Thanks for any help on this.

Regards

Fagery

It seames that Rotating and Translating is one of the toughest parts for a beginner in opengl.

I am Trying to attach the view to a model for quite a while now with now success. I have read quit alot of articles to but just can't get it figured out.

So in other words i have a view (camera) gluLookAt or just loading the identity (glLoadIdentity) and then translate and rotate the view along with the model.

the model(object like car, plane, first person etc..) is translating and rotating like i want it to. Pritty much with this simple formula:

x += sinf(direction)*speed;

y += cosf(direction)*speed;

and roateted correclty around it's origin axis.

now to make a more clear question. How can i let the camera rotate around the same point x,y,z as the model ?

i tried:

glLoadIdentity();

glRotatef(objroll, 0.0, 0.0, -1.0);

glRotatef(objpitch, -1.0, 0.0,0.0);

gluLookAt(x,y,z, lookx, looky, lookz, 0, 1, 0);

.

.

Rotate & Translate model

and:

glLoadIdentity();

glRotatef(objroll, 0.0, 0.0, -1.0);

glRotatef(objpitch, -1.0, 0.0,0.0);

glTranslatef(x,y,z);

gluLookAt(x,y,z, lookx, looky, lookz, 0, 1, 0);

.

.

Rotate & Translate model

But a soon as the model(object) has rotated to some degrees around the x or y axis the camra rotates either around a differen origin or rotates only correct around the z axis.

I hope my question is some what clear.

Thanks for any help on this.

Regards

Fagery