#### Archived

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

# rotation in Direct3d

This topic is 6015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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.

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 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)) {
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 on other sites
Try using SetTransform(D3DTS_WORLD, angleinradian), it will rotate the whole thing

##### Share on other sites
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 on other sites
G''day!

You might want to check out the tutorials on my site (www.drunkenhyena.com). There''s a tutorial on rotating objects. A lot of people seem to like the tutorials, so i think they''re pretty good.

Stay Casual,

Ken
Drunken Hyena

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×