Sign in to follow this  
mfolino

Maybe a dumb question....but.....

Recommended Posts

I need some help. It may sound quite dumb (although I hope not!). Im having trouble with multiple rotations on a single object. I need to rotate an object in both the x and y planes (ie. so its rotations are 'up and down' and 'side to side'). I can get one or the other to work, but not both. Basicially what I have is this: D3DXMatrixTranslation(&matTrans, pos.x, pos.y, pos.z); D3DXMatrixRotationY(&matRotate, D3DXToRadian(facing.y)); D3DXMatrixMultiply(&matTrans, &matRotate, &matTrans); and then the render call. If I add the D3DXMatrixRotationX(...) it just uses the one called last. Any help would be awesome.

Share this post


Link to post
Share on other sites
Hi, well not sure if this is the correct answer but as I remember the order in which the matrices are concatenated affect the final matrix, so you could try multiplying in a different order like:

D3DXMatrixTranslation(&matTrans, pos.x, pos.y, pos.z);
D3DXMatrixRotationY(&matRotate, D3DXToRadian(facing.y));
D3DXMatrixMultiply(&matTrans, &matTrans, &matRotate);

Or if you are using C++ you could simply use:
matTrans = matTrans * matRotate;

Hope this helps you,
Oscar

Share this post


Link to post
Share on other sites

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