Jump to content
  • Advertisement

Archived

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

DMonaghan

Translation and Rotation

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

I have a set of position and rotation data of a model and I need to rotate it 90 around the x axis. I have an understanding of the concepts of what i need to do. I need to translate to the origin, perform the rotation, and translate back to my position. I have working translate and rotate functions from a math lib and they are defined as follows, they work in similar fashion to glrotate and gltranslatef void mat4_Translate(float x, float y, float z, mat4_t m) void mat4_Rotate(float angle, float x, float y, float z, mat4_t m) My main problem is im not sure the sequence and usage of these functions I copy all of my data into a matrix, like so. m[0] = t.rot[0][0]; m[1] = t.rot[0][1]; m[2] = t.rot[0][2]; m[3] = 0; m[4] = t.rot[1][0]; m[5] = t.rot[1][1]; m[6] = t.rot[1][2]; m[7] = 0; m[8] = t.rot[2][0]; m[9] = t.rot[2][1]; m[10] = t.rot[2][2]; I assume in then simply use the functions in the following fashion // Translate to Origin mat4_Translate(t.pos[0]*-1, t.pos[1]*-1, t.pos[2]*-1, m); // Perform rotation along X axis mat4_Rotate(90, 1, 0, 0, m); // Translate back to orginal position mat4_Translate(t.pos[0], t.pos[1], t.pos[2], m); The result i'm getting however, is that the objects seem to swing along a wide arc. Which make me think that they are not in fact being rotated about the origin. So my problem is here // Translate to Origin mat4_Translate(t.pos[0], t.pos[1], t.pos[2], m); What is the correct usage of this, in order to translate back to the origin Thanks [edited by - DMonaghan on November 26, 2003 3:36:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
you need to multiply your matrices locally.

Share this post


Link to post
Share on other sites
I'm not sure i understand, in fact i am sure i do not understand 8)


I dont actually use at maxtrices, except of course in this instance, since i need to do the rotation,.

[edited by - DMonaghan on November 26, 2003 3:20:57 PM]

Share this post


Link to post
Share on other sites

  • 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!