Jump to content
  • Advertisement


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

world rotation problem... any help?

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

well i finally did it -- i learned how to do D3D i feel good :D now i'm having a bit of a problem. here's the rotation code for my game:
D3DXMatrixMultiply(&matLocal, &matRotateX, &matRotateY);
D3DXMatrixMultiply(&matLocal, &matLocal,   &matRotateZ);
BTW, matLocal is the matrix of the object, and matRotateX/Y/Z are rotation matrices built from the object's angles. looks like normal code, right? well the problem is that the object rotates on its local X and Y axes, but on the world Z axis. and if i change it like this:
D3DXMatrixMultiply(&matLocal, &matRotateZ, &matRotateY);
D3DXMatrixMultiply(&matLocal, &matLocal,   &matRotateX);
notice the X and Z are switched. now it rotates on its local Y and Z axes, and on the world X axis! it seems whichever matrix is multiplied in last is based upon the world axis. anyone have a solution for this? i'm sure there is. [edited by - Drakex on December 1, 2002 6:18:55 PM]

Share this post

Link to post
Share on other sites
Try this:


D3DXMATRIX matLocal;
D3DXRotationZ( &matLocal, /*put here you Z angle*/ );

D3DXMatrixRotationX( &matTemp, /*put here your X angle*/ );
D3DXMatrixMultiply(&matLocal, &matLocal, &matTemp);
D3DXMatrixRotationY( &matTemp, /*put here your Y angle*/
D3DXMatrixMultiply(&matLocal, &matLocal, &matTemp);

p_D3Ddevice->SetTransform( D3DTS_WORLD, &matLocal );

Don''t change the positions of the code-lines or you''ll mess
it up...

With the way it is you can get an easy way to rotate your object.

Sorry about my engilsh...
I hope it helps


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!