Sign in to follow this  
wpyax

??help about the D3DXMatrixMultiply

Recommended Posts

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;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this