Archived

This topic is now archived and is closed to further replies.

3D rotation

This topic is 6676 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

each of your objects should have its own origin. so if you rotate the object, it rotates around its origin, not around the world origin. after rotation you translate the objects into worldspace, which means you move them to the right coordinates.
you can perform all this in one transformation step through matrices, and you _must_ du that with openGL.

Sengir

Share this post


Link to post
Share on other sites
Let me see if I have this right then. First I rotate my objects normally with matrices as such

mx[0] = 1;mx[4] = 0;mx[8] = 0;mx[12] = 0;
mx[1]=0;mx[5]=cos(x);mx[9] = sin(x);mx[13]=0;
mx[2]=0;mx[6]=-sin(x);mx[10]=cos(x);mx[14]=0;
mx[3]=0;mx[7]=0;mx[11]=0;mx[15] = 1;
glMultMatrixd(mx);

mx[0]=cos(y);mx[4]=0;mx[8]=-sin(y);mx[12]=0;
mx[1]=0;mx[5]=1;mx[9]=0;mx[13]=0;
mx[2]=sin(y);mx[6]=0;mx[10]=cos(y);mx[14]=0;
mx[3]=0;mx[7]=0;mx[11]=0;mx[15]=1;
glMultMatrixd(mx);

mx[0]=cos(z);mx[4]=sin(z);mx[8]=0;mx[12]=0;
mx[1]=-sin(z);mx[5]=cos(z);mx[9]=0;mx[13]=0;
mx[2]=0;mx[6]=0;mx[10]=1;mx[14]=0;
mx[3]=0;mx[7]=0;mx[11]=0;mx[15]=1;
glMultMatrixd(mx);

and then just call glTranslated to move it to where I want it to be. Or do I have to do they rotations with out calling glMultMatrix, and multiply the vertices by the rotation matrix by hand? If no, I guess my next question, is how do I know how much the object needs to be translated by.
thanx for all the help, I'm a little new to 3d (can u tell)

Share this post


Link to post
Share on other sites
I've been working on a 3D modeler, and I was wondering how to do rotations without having the object move all over the screen, i.e., How to rotate around locale coords instead of world. I'm using OpenGL. I'd perfer to just be pointed in the direction of a site with an article on the subject. thanx all for the help.

Share this post


Link to post
Share on other sites