open gl coding, animating an object [Archive] - C Board

PDA

View Full Version : open gl coding, animating an object


chris285
11-18-2003, 08:25 AM
ok i have this assignment which involes creating a asteroid field using glut/open gl

our current task is to present randomly placed asteroids which are textured and light, however i would like to go a bit further than that. i want the asteroids that i have created to spin/rotate in the program, but i have no idea how to get them to spin.

this is how the asteroid is drawn in screen in the renderscene function.

lPushMatrix();
glTranslatef(location1.getnumber(),location2.getnu mber),location3.getnumber());
glScalef(0.5,0.5,0.5);
glCallList(asteroid4pt);
glPopMatrix();

how do i make them rotate to give them a better 3d feeling than just lighting and textures?

Jeremy G
11-18-2003, 10:51 AM
glRotate3f(float ammount, float x, float y, float z);
I dont remember if ammount is in degrees or radians.


make sure you call rotate in the pushed matrix, before any translation. if you call it after the translation the rotation is still done in relation to the origin and gives unwanted effect.