Archived

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

GameDev135

rotation in Direct3d

Recommended Posts

GameDev135    133
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
Pactuul    122
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.


Pactuul

"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
GameDev135    133
Ok, here is the code that I have, but it isn''t turning at all

D3DXMATRIX CarRotationMatrix;
if (g_Keyboard.IsKeyDown(DIK_LEFT)) {
g_Car.GetLocal(CarRotationMatrix);
D3DXMatrixRotationY(&CarRotationMatrix,-1.0f);
g_pDevice->SetTransform(D3DTS_VIEW,&CarRotationMatrix);
}

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
yanuart    162
D3DTS_VIEW won''t change anything, it''s just the representation of your camera view. It will work if you move your camera position in a circle path

Share this post


Link to post
Share on other sites