Rotations

Started by
1 comment, last by Xeno 23 years, 11 months ago
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"

------------------------------- Goblineye Entertainment------------------------------

Advertisement
hmmm.... somebody?

Thanks .

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

------------------------------- Goblineye Entertainment------------------------------

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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement