# Rotation Help

This topic is 3790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I've many objects, every object i draw this way: glPushMatrix(); glTranslatef(pos.x,pos.y,pos.z); glRotatef(angleX,1,0,0); glRotatef(angleY,0,1,0); glRotatef(angleZ,0,0,1); ....drawing... glPopMatrix(); this way every object is drawn in its position and rotated. The problem is that i need to rotate some object about another object, i would be very glad for any help, thank you

##### Share on other sites

I believe in order to do this you would multiply that objects matrix by the object you want to rotate it around.

you would do another push pop and multf

so you would do 2 matrix multiplies for that object.

##### Share on other sites
try this:

glPushMatrix();

glTranslatef(pos.x,pos.y,pos.z);
glRotatef(angleX,1,0,0);
glRotatef(angleY,0,1,0);
glRotatef(angleZ,0,0,1);

// Draw 1st object..

glPushMatrix();
glRotatef(second_angleX,1,0,0);
glRotatef(second_angleY,0,1,0);
glRotatef(second_angleZ,0,0,1);

// Draw 2nd object (rotates around the 1st)..

glPopMatrix();

glPopMatrix();

##### Share on other sites
i don't think it's the solution, speaking more specific:
the objects are drawn together first, then they move to a specific point
while rotating towards their movement direction.
the problems is that they need to move and rotate as one object.
there's like a leader object and all the rest need to rotate around him, but keeping the whole construction of objects constant.

1. 1
2. 2
3. 3
Rutin
24
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002226
×