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

## 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 on other sites
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).

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 11
• 16
• 9
• 10
• 13
• ### Forum Statistics

• Total Topics
633003
• Total Posts
3009846
• ### Who's Online (See full list)

There are no registered users currently online

×