Advertisement Jump to content


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


Rotating objects

This topic is 6881 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


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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!