Original Post
As stated in the Red Book:
Example 3-4 draws an automobile, assuming the existence of routines that draw the car body, a wheel, and a bolt.
Example 3-4 : Pushing and Popping the Matrix
draw_wheel_and_bolts()
{
long i;
draw_wheel();
for(i=0;i<5;i++){
glPushMatrix();
glRotatef(72.0*i,0.0,0.0,1.0);
glTranslatef(3.0,0.0,0.0);
draw_bolt();
glPopMatrix();
}
}
draw_body_and_wheel_and_bolts()
{
draw_car_body();
glPushMatrix();
glTranslatef(40,0,30); /*move to first wheel position*/
draw_wheel_and_bolts();
glPopMatrix();
glPushMatrix();
glTranslatef(40,0,-30); /*move to 2nd wheel position*/
draw_wheel_and_bolts();
glPopMatrix();
... /*draw last two wheels similarly*/
}
This code assumes the wheel and bolt axes are coincident with the z-axis...
How would you make the wheel and bolt axes coincident with the z-axis? Using glLoadIdentity()? Not too sure about that one, because wouldn''t glLoadIdentity() simply move back to the point 0,0 making the wheel completely out of place? Thanx.