Here’s my problem:
I want to follow a circle around the origin and look always at the origin, using gluLookAt…
My code is this:
What can I do to keep my object in the center of the screen instead of moving it around???
I don’t now why I move all the scene around instead of moving only the point of view!!
Any help will be very appreciated.
You can try this:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// R = radius
ex = Rcos(thetaDTOR); // DTOR = pi/180
ez = Rsin(thetaDTOR);
ey = 0.0f; // ?
gluLookAt(ex,ey,ez, // eye coords
cx,cy,cz, // centre coords
0,1,0 ); // up
} // end of Draw()
Make sure you put gluLookAt(…) first.
Then draw your object(s), and update your variables at the end of Draw() loop.
Hope that helps…
gluLookAt should NOT be put on the GL_PROJECTION matrix. It should be the first thing to be put on the GL_MODELVIEW matrix…
Also you are missing a glLoadIdentity. gluLookAt multiplies with the current matrix.
Thanks for your help !!!
I have done it but my object still going around the scene!
That’s right…The gluLookAt should not be in:
Nobody told me that before!!
thanks a lot.
Im back with another problem…now…
My gluLookAt is working very well if I have 1 object in my screen…but…
What should I do if I have more than 1 object??
It looks like im doing the translate wrong because my objects rotate all together in one point!!!