OpenGl - Camera rotation

Started by
0 comments, last by pr0teus 23 years, 9 months ago
WHat I''m trying to do is have a model of the solar system. I have the 9 planets and they rotate around the sun. I now want to add camera movement so that I can move in and around the planets, and also so I can just rotate the view so that instead of looking at the planets straight on horizontally (so that they rotate around the y axis in front of me) to one where I am on top of the planets, looking down. Here is the rendering code, where would I put in the camera transformations? glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glLightfv(GL_LIGHT0,GL_POSITION,lightPos); // Sun glTranslatef(0.0f, 0.0f, -300.0f); glColor3ub(255, 255, 0); glutSolidSphere(15.0f, 25, 25); glLightfv(GL_LIGHT0,GL_POSITION,lightPos); for(lcv = 0; lcv < 9; ++lcv) { glPushMatrix(); glColor3ub(255, 0, 0); glRotatef(fPlanetRot[lcv], 0.0f, 1.0f, 0.0f); glTranslatef(fPlanetPos[lcv], 0.0f, 0.0f); glutSolidSphere(6.0f, 10, 10); glPopMatrix(); } for(lcv = 0; lcv < 9; ++lcv) { fPlanetRot[lcv] += fPlanetSpeed[lcv]; if(fPlanetRot[lcv] > 360.0f) fPlanetRot[lcv] = 0.0f; } glPopMatrix(); Thanks, Ben
Advertisement
after the glLoadIdentity
btw u should also do a push/pop on the sun as well

This topic is closed to new replies.

Advertisement