Fier

04-05-2004, 06:20 AM

Hello everyone,

I am currently has a problem cannot be solved. Really hope you guys can help me out.

I have a object(say a sphere at point 3,3,3) rotating around a point(say origin) in an arbitrary direction. These are the code.

//start at origin of world space

glLoadIdentity();

glPushMatrix();

//rotating ang1 around y-ax, so cursor will be at z=3 position

glRotatef(ang1, 0,1,0);

//rotating ang2 around z-ax, so cursor will be at y=3 position

glRotatef(ang2, 0,0,1);

//rotating the object coordinate around its a axis, this changes the rotational path the object can rotate around the origiin.

glRotatef(rotPathDegree, 1,0,0);

//rotate around object's z axis, so it can rotate 'rotDegree" degrees around the origin on the direction path.

glRotatef(rotDegree, 0,0,1);

//move alone the object's new x-axis, it will reach 3,3,3

glTranslatef(3, 0,0);

drawTheSphereFunction();

glPopMatrix();

Ok, I know this sounds complicated, but this is what I have to do to make an object rotate around a point in ANY path. Now the question is, How do I keep track of the object (sphere)'s coordinate after all this rotation and tranformation?

Any help would be very very thankful, thank you a lot.

I am currently has a problem cannot be solved. Really hope you guys can help me out.

I have a object(say a sphere at point 3,3,3) rotating around a point(say origin) in an arbitrary direction. These are the code.

//start at origin of world space

glLoadIdentity();

glPushMatrix();

//rotating ang1 around y-ax, so cursor will be at z=3 position

glRotatef(ang1, 0,1,0);

//rotating ang2 around z-ax, so cursor will be at y=3 position

glRotatef(ang2, 0,0,1);

//rotating the object coordinate around its a axis, this changes the rotational path the object can rotate around the origiin.

glRotatef(rotPathDegree, 1,0,0);

//rotate around object's z axis, so it can rotate 'rotDegree" degrees around the origin on the direction path.

glRotatef(rotDegree, 0,0,1);

//move alone the object's new x-axis, it will reach 3,3,3

glTranslatef(3, 0,0);

drawTheSphereFunction();

glPopMatrix();

Ok, I know this sounds complicated, but this is what I have to do to make an object rotate around a point in ANY path. Now the question is, How do I keep track of the object (sphere)'s coordinate after all this rotation and tranformation?

Any help would be very very thankful, thank you a lot.