Sign in to follow this  

Rotating multiple .x file objects

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

I am trying to place and rotate multiple .x file objects into a scene. I am able to place the objects where they need to go using: D3DXMATRIX Position; D3DXMatrixTranslation(&Position, 0, 0, 0); Device->SetTransform(D3DTS_WORLD, &Position); If I place this code before displaying each object it works fine, but when I try to rotate each object by placing this code before displaying each object: static float y = 0.0f; D3DXMATRIX yRot; D3DXMatrixRotationY(&yRot, y); y += timeDelta; D3DXMATRIX World = yRot; Device->SetTransform(D3DTS_WORLD, &World); It will rotate the whole scene, no matter how I place them. How can I rotate each object individually?

Share this post


Link to post
Share on other sites
Try this before each object:

//Put your position into a matrix (change your position for each object)
D3DXMATRIX Position;
D3DXMatrixTranslation(&Position, 0, 0, 0);

//Put your rotation into a matrix
static float y = 0.0f;
D3DXMATRIX yRot;
D3DXMatrixRotationY(&yRot, y);
y += timeDelta;

//now compile your matrix so you have your rotation and position in one
D3DXMATRIX compMat;
compMat=Position*yRot;

//now render with your compiled matrix
Device->SetTransform(D3DTS_WORLD, &compMat);


See how that works for you. As a note, see how I said to change the position of the matrix for each object? If all the objects are rotating at the same speed and are on the same spot as each other it will seem as though the entire world is rotating rather then the objects individually, but really what is happening is that those individual objects are rotating syncronized giving that effect. So if you move them to diffrent locations you'll see that they are rotating independently and the world isn't rotating.
~Wave

Share this post


Link to post
Share on other sites

This topic is 4843 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this