Skip to main content
gamedev.net
🔒 Locked

Rotating objects

Started by Floru Mar 17, 2000 at 5:13 AM 0 replies 700+ views
Original Post
Floru
Floru
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
Spellbound
Spellbound

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.