Jump to content
  • Advertisement
Sign in to follow this  
tinu

A small question

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

Hi, I want to translate the object along X and Y direction. For that I construct a translation matrix and Multiply It to World Matrix. D3DXMatrixTranslation(&matTrans, xDist, yDist, 0); D3DXMatrixMultiply (&matWorld, &matWorld, &matTrans); This works fine. Next,I want to rotate by object around world origin along Z direction. For that I construct a Rotation matrix and Multiply It to World Matrix. D3DXMatrixRotationZ(&matRotZ, zAngle*0.0174); D3DXMatrixMultiply (&matWorld, &matWorld, &matRotZ); This rotates the object and its axes also. Next I want to translate again. This causes the translation to happen along the direction of rotated X,Y axes caused due to the previous rotation. But I want the object to always translate along the World's X and Y direction not to translate along the object's axes. What should I do for this? Can Any one help? Expecting help. [Edited by - tinu on June 15, 2007 10:48:02 PM]

Share this post


Link to post
Share on other sites
Advertisement
The order of the transformations is important. Do the rotations first, and translate after the rotations. This way, you move the already rotated object in world XYZ.

Share this post


Link to post
Share on other sites
But if Change the order of rotation the rotation around world origin does not happen.

It changes into rotation about object's origin

Share this post


Link to post
Share on other sites
By your last post, I thought you wanted to rotate first, and then translate.

Anyhow, if you want to combine an "orbital" rotation and and ordinary rotation, do the following:

-First rotate the object around its own center (which is the world center also).
-Then translate the object to the orbit.
-Finally, rotate the object around the world center.

All of these steps can be combined into one matrix by multiplying them together in the above order.

Share this post


Link to post
Share on other sites
Basically, I wanted to develop an application which on pressing particular keys should rotate around the world origin and translate whenever the corresponding keys are pressed.

Share this post


Link to post
Share on other sites
All that matters is that the transforms are in correct order, no matter what result you want.

Think about what each individual transform actually does. Remember that the object coordinate system does not get transformed; rather, the object vertices themselves are transformed with regard to the object's origin, which can be thought as always being at [0,0,0].

Share this post


Link to post
Share on other sites
To rotate the object around its own center,I use

D3DXMatrixRotationZ(&matRotZ, zAngle*0.0174);
D3DXMatrixMultiply (&matWorld, &matWorld, &matRotZ);

How to rotate the object around the world center when the object centre and the world centre are not the same?

Share this post


Link to post
Share on other sites
It's "Question", not "Doubt"!

A "Doubt" is something about yourself only.
A "Question" is something you ask others.

You need to rebuild the desired matrix again from scratch every time by rotating and multiplying by the respactive cumulative amounts.

Share this post


Link to post
Share on other sites
If I first Rotate and then translate, the consecutive rotation happens around the objects origin and not the world origin and the translation happens fine.

If I first translate and then rotate,the consecutive translation happens along the rotated axes and the rotation happens fine around the world origin.

So What should I do to combine both the effects of rotation around world origin along Z direction and Translate along the World X,Y directions?

Can any one help?

[Edited by - tinu on June 16, 2007 5:46:13 AM]

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!