Archived

This topic is now archived and is closed to further replies.

camera following object

This topic is 5018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am having problems of placing my camera to follow my object. i wanted to change views everytime i oush F1 does anybody has any idea?? I would really appriciate that. I am trying to make my camera to move along my object like that: if (mode==0) { glPushMatrix(); glLoadIdentity(); glTranslatef(0.0,0.0,-15.0); glTranslatef(xt,yt,zt); glutSolidSphere(0.2,20,2); glPopMatrix(); glFlush(); } else { glPushMatrix(); glLoadIdentity(); glMatrixMode( GL_MODELVIEW); gluLookAt(xt,yt,zt, 0,0,0, 0,0,0); glPopMatrix(); but there''s no answer to my problem everytime i push F1 my sphere disappears!! can anybody help me??? thanx

Share this post


Link to post
Share on other sites
It looks like your code doesn''t draw the sphere unless mode == 0 (there''s no drawing code of any kind in the other branch of the if/else). With OpenGL, if you want something to show up, you have to draw it every single frame (unless you put it in a display list, but then you still have to call that display list every single frame).

Share this post


Link to post
Share on other sites
and even if there was a sphere:
gluLookAt(xt,yt,zt, 0,0,0, 0,0,0);

please look up how to use gluLookAt instead of just passing _something_ as parameters.

Share this post


Link to post
Share on other sites
I have solved it out thanx anyways!!! and for those who still try to find the answer goes like:

glLoadIdentity();

if (mode)
glTranslatef(-xt,-yt,-zt - 2);
glPushMatrix();
glTranslatef(xt,yt,zt);
glutSolidSphere(0.2,20,2);
glPopMatrix();

Share this post


Link to post
Share on other sites