Sign in to follow this  
khdani

Rotation Help

Recommended Posts

khdani    120
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 this post


Link to post
Share on other sites
AverageJoeSSU    564


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 this post


Link to post
Share on other sites
LordOrion    174
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 this post


Link to post
Share on other sites
khdani    120
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this