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

rotation in Direct3d

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

Hey I would like to have an object rotate around its center in directx 8. 1)How can I find the center? 2)What would the rotating function be? (I only want to rotate around the y-axis, not all 3-axis) Thanks for your help

Share this post

Link to post
Share on other sites
The best way is to use matrix''s... you know how you use SetTransform(&mymatrix) to draw something...Well each object has it''s own matrix. And of course if you want to draw the object in the middle of the world (0,0,0) with no rotation or scaling use the identity matrix. Well to rotate the object use D3DXMatrixRotate() function, you can specify on which axis to rotate by passing in a vector (in your case use the 0,1,0 vector to rotate around the y-axis) then do SetTransform(&newmatrix) to set that....

hope this helps in giving you some ideas.


"The thing I like about friends in my classes is that they can''t access my private members directly."
"When listening to some one tell about their problem (whether it''s code or not), don''t listen to what went right or wrong, but what they assumed....."

Share this post

Link to post
Share on other sites
Ok, here is the code that I have, but it isn''t turning at all

D3DXMATRIX CarRotationMatrix;
if (g_Keyboard.IsKeyDown(DIK_LEFT)) {

GetLocal() is a method of the frame class which g_Car is. It puts the local transformation matrix in CarRotationMatrix

What am I doing wrong?

Share this post

Link to post
Share on other sites