Jump to content
  • Advertisement

Archived

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

Xeno

Rotations

This topic is 6931 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 ! these are some triangle vertices : D3DVECTOR Vec1( 0.0f, 0.0f, 0.0f); D3DVECTOR Vec2( 1.0f,-1.0f, 0.0f); D3DVECTOR Vec3(-1.0f,-1.0f, 0.0f); now , how can i avoid that when i rotate this triangle lets say , aroud the z -axis , the triangle will not rotate around the world origin?? i want it to be rotated around the local origin. why when i change Vec1 to D3DVECTOR Vec1( 0.0f, 1.0f, 0.0f); , it is rotated around the local origin? Thanks a lot!. Posted By Xeno. Kobe Bryant - "Just believe in yourself"

Share this post


Link to post
Share on other sites
Advertisement
hmmm.... somebody?

Thanks .

Posted By Xeno.
Kobe Bryant - "Just believe in yourself"

Share this post


Link to post
Share on other sites
When you set the world matrix to a rotation matrix your triangle is rotated around its origin, which just happens to coincide with the worlds origin since you don''t translate it.

If you change Vec1 to (0,1,0) the origin of the triangle is still (0,0,0).

But if what you wanted to ask is how to rotate the around its meanpoint, then you must first translate the triangle so that the meanpoint coincides with (0,0,0) then rotate it and finally translate it back to where it was before.

D3DMATRIX World = Translate(-MeanPoint)*Rotate(Angle)*Translate(MeanPoint);
pD3DDev->SetTransform(D3DTRANSFORMSTATE_WORLD, &World);

The function Translate() above returns a D3DMATRIX that are set as a translation matrix. Rotate() returns a rotationmatrix. You can do the same with D3DX functions or the functions found in the D3DFramework.


- WitchLord

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!