Share this post

Link to post

Share on other sites

glRotatef(angle, 1.0, 0, 0)the above rotation will multiply the proper rotation matrix automatically by the current matrix. The order in which you perform transformations will drastically vary in the final effect. Think about it. Say your program is only drawing a spere at the grand fixed origin, where the camera rests by default(0,0,0). In your display function, if you wanted to rotate a sphere and then translate it. you''d do this:

void display(void){

glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0);

glPushMatrix(); glTranslatef(-3.0, 0, 0); glRotatef((GLfloat) ???angle, 0, 1.0, 0); glutWireSphere(0.05f, 6, 4); glPopMatrix(); . . .[/CODE]^^^^^^^^^The above will first rotate an abstract local origin about the origin, thin will move it "-3" along the x. Done backwards, this would result in the sphere orbiting around the grand origin rather than rotating about it. The normal vectorfor rotation (0,1,0) just says to rotate around the y axis.if it had been(0,0,0), around what would it rotate?!?!?!*notice how rotate comes after translate, it''s because the Matrix multiplication order is backwards, somewhat.i.e. T(R*Sphere)for t = trans, r = rotation***very important to grasp!