Archived

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

world rotation problem... any help?

This topic is 5561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
anyone? i''d really like to know how to get around this..

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

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 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.