Jump to content
  • Advertisement
Sign in to follow this  
khdani

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.

If you intended to correct an error in the post then please contact us.

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


Link to post
Share on other sites
Advertisement


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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!