Jump to content
  • Advertisement

Archived

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

Drakex

world rotation problem... any help?

This topic is 5737 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
Advertisement
anyone? i''d really like to know how to get around this..

till then, i''ll work on getting lights to work. hmm..

Share this post


Link to post
Share on other sites
Try this:


  

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

D3DXMATRIX matTemp;
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

Kamikaze

Share this post


Link to post
Share on other sites
thanks come to think of it, i don''t really want to rotate the object on its own Y axis anyway so this is good.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!