#### Archived

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

# 3D rotation

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

## Recommended Posts

rotate the object in objectspace and _then_ transform it to worldspace.

##### Share on other sites
I'm not quite sure how to do that though. How do you make your rotations in object space?

##### Share on other sites
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 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 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 on other sites
never mind, I figured out what i needed to do, thanx to for the help though.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009389
• ### Who's Online (See full list)

There are no registered users currently online

×