A small question
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]
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.
But if Change the order of rotation the rotation around world origin does not happen.
It changes into rotation about object's origin
It changes into rotation about object's origin
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.
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.
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].
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?
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?
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.
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.
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement