Jump to content
  • Advertisement

Archived

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

Floru

Rotating objects

This topic is 6728 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 previously asked about rotating object in Direct3d and I also got some answers which said that should do my matrix calculations in right order... I tried but... Well I didn''t manage to do it... So could somebody please give a simple code example of rotating object (a triangle for example) in different locations. And so that the object rotates around it''s own origo not around the world origo which is my problem. Any help would be appreciated. Floru

Share this post


Link to post
Share on other sites
Advertisement

D3DXMATRIX T,Rx,Ry,Rz;


D3DXMatrixRotationZ(&Rz, Roll);
D3DXMatrixRotationX(&Rx, Pitch);
D3DXMatrixRotationY(&Ry, Yaw);
D3DXMatrixTranslation(&T, Pos.x, Pos.y, Pos.z);


D3DXMATRIX Transform;
D3DXMatrixMultiplication(&Transform, &Rz, &Rx);
D3DXMatrixMultiplication(&Transform, &Transform, &Ry);
D3DXMatrixMultiplication(&Transform, &Transform, &T);


And there you have it

Of course, if you're really lazy then you can use D3DXMatrixRotationYawPitchRoll() instead of above rotation matrices. It's also a good optimization, although you will probably not notice much difference unless you compute the transformmatrix lots and lots of time during each frame.




Edited by - Spellbound on 3/17/00 6:43:41 AM

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.

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!