??help about the D3DXMatrixMultiply

Started by
0 comments, last by GameDev.net 18 years, 4 months ago
this's my code. and it don't work as my wish.why? i want to move the object by walk_front and RotationY and D3DXMatrixMultiply(&matWorld1, &matWorld1, &matWorld2); D3DXMatrixMultiply(&matWorld1, &matWorld2, &matWorld1); is different,why? float angle=0.0f; float r=1.0f; D3DXMATRIXA16 matWorld1; D3DXMATRIXA16 matWorld2; D3DXMatrixTranslation( &matWorld1, sinf(angle)*r,0.0f,cosf(angle)*r); D3DXMatrixRotationY(&matWorld2, angle+D3DX_PI); D3DXMatrixMultiply(&matWorld1, &matWorld2, &matWorld1); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld1 ); . . . . case VK_LEFT: angle-=D3DX_PI/12; if(angle<0) angle+=2*D3DX_PI; break; case VK_RIGHT: angle+=D3DX_PI/12; if(angle>(2*D3DX_PI)) angle=angle-2*D3DX_PI; break; case VK_UP: r+=0.2f; break;
Advertisement
RotationMat * TranslationMat is different from TranslationMat * RotationMat.

Think those transformations are applied in sequence. For example:

Suppose a translation in x direction and a rotation of 30 degrees around y axis. Consider your object is initially on the origin.

1) RotationMat * TranslationMat will place the object on the x axis.

2) TranslationMat * RotationMat will not place the object on the x axis (but on a direction at 30 degrees from the x axis).

This topic is closed to new replies.

Advertisement