🔒 Locked
A small question
Advertisement
Original Post
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]
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.
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.
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].
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].
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]
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]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement