I am simulating a ball rotate along an axis which is the tangent line of the ball to a box.
Here is the display code. The ball only rotates along its own axis. Please indicate how to modify. Thanks a lot.
glPushMatrix();
glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0);
glPushMatrix();
glScalef (2.0, 1.5, 1.3);
glutWireCube (1.2);
glPopMatrix();
glTranslatef (0.0, 1.5, 0.0);
glRotatef ((GLfloat) head, 0.0, 0.0, 1.0);
glutWireSphere(0.7, 10, 10);
glPopMatrix();
glutSwapBuffers();
I am simulating a ball rotate along an axis which is the tangent line of the ball to a box.
I am not sure of what you are trying to do here.
But If I understand, that you are trying to rotate the box about its own edge . Taken only the box for rotation . If you want to do this, following is the code.
int cube_dimension = 1.2;
for ( int i = 0 ; i < 360 ; i++)
{
glPushMatrix();
glRotatef ((GLfloat) i, 0.0, 0.0, 1.0);
glTranslatef( cube_dimension/2 ,
cube_dimension/2 ,
cube_dimension/2);
glutWireCube (cube_dimension );
glPopMatrix();
glFlush();
some_delay_function();
}
You can take pointers from the above and do for the sphere.
Hope this helps
-S