Jump to content
  • Advertisement
Sign in to follow this  
Endar

Matrix transformations

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

Quick question about matrix transformations. I currently have a scene node with a single matrix as a transformation node. I was wondering, when you end up with the final matrix for a transformation, and you have a matrix for rotation, translation and scaling, does it matter which you multiply and in which order? So, if I already had a transformation matrix and I decided I wanted to rotate it some more, can I do that? Eg. can you do rotation * translation * rotation * scaling * translation and still get a perfectly valid matrix that will get you the transformation you intended?

Share this post


Link to post
Share on other sites
Advertisement
Yes it does, but only in the case of using translation and rotation at the same time.

If you go:


D3DXMATRIXA16 world, translation, rotation;

D3DXMatrixIdentity( &world );
D3DXMatrixMultiply( &world, &world, &translation );
D3DXMatrixMultiply( &world, &world, &rotation);




The object will be shifted into position and then rotated on the spot.

However if you do this:


D3DXMATRIXA16 world, translation, rotation;

D3DXMatrixIdentity( &world );
D3DXMatrixMultiply( &world, &world, &rotation);
D3DXMatrixMultiply( &world, &world, &translation );






The object will be rotated and then translated into position.

All of the other tranformation types can happen anywhere and in any order, it is only the order if these two that alter the output of the transformation. Multiplying by rotation twice into the world matrix will just screw things around and shouldn't be done unless you know exactly why you are doing it.

Hope that helps.

ace

Share this post


Link to post
Share on other sites
So, if I wanted to make sure that everything went fine, would I have to keep 3 matrices in the tranformation scene node?

Like, one for rotation, one for scaling, and one for translations? So, if someone wanted to add a rotation, they could do that, and the rotation matrix would get multiplied, but, when the time to actually render the objects, I would have to do the three multiplications to get the final transformation matrix, and then the final multiplication to multiply by the world matrix.

Something like that?

Share this post


Link to post
Share on other sites
I guess you could, but im not expert on rendering engines and the like. I know about matrices though [smile].

Maybe someone else can help with that,

ace

Share this post


Link to post
Share on other sites
Sign in to follow this  

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