Skip to main content
gamedev.net
🔒 Locked

Rotation Help

Started by khdani Mar 3, 2008 at 10:48 AM 2 replies 600+ views
Original Post
khdani
khdani
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
AverageJoeSSU
AverageJoeSSU


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.

------------------------------ redwoodpixel.com
LordOrion
LordOrion
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();
Bye and Thanks!SiS.Professional Software Developer.
khdani
khdani
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.