world rotation problem... any help?

Started by
2 comments, last by Drakex 21 years, 4 months ago
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]
_______________________________________________________________________Hoo-rah.
Advertisement
anyone? i''d really like to know how to get around this..

till then, i''ll work on getting lights to work. hmm..
_______________________________________________________________________Hoo-rah.
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
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.
_______________________________________________________________________Hoo-rah.

This topic is closed to new replies.

Advertisement