3D rotation

Started by
4 comments, last by INVERSED 24 years, 7 months ago
rotate the object in objectspace and _then_ transform it to worldspace.

--
Sengir
Advertisement
I'm not quite sure how to do that though. How do you make your rotations in object space?
Write more poetry.http://www.Me-Zine.org
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


--
Sengir
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)

Write more poetry.http://www.Me-Zine.org
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.
Write more poetry.http://www.Me-Zine.org
never mind, I figured out what i needed to do, thanx to for the help though.
Write more poetry.http://www.Me-Zine.org

This topic is closed to new replies.

Advertisement