D3DXMATRIX matRot;
D3DXMATRIX matCenter;
D3DXMATRIX matScale;
D3DXMATRIX posZUnitVec;
D3DXVECTOR3 vecTankForward;
D3DXMatrixRotationYawPitchRoll(&matRot, D3DXToRadian(tankRotX), D3DXToRadian(0.0f), D3DXToRadian(0.0f));
D3DXMatrixTranslation(&posZUnitVec, 0.0f, 0.0f, 1.0f); // matrix holding position of vector pointing to positive z
D3DXMATRIX m = posZUinitVec * matRot;
vecTankForward = D3DXVECTOR3(m._41,m._42,m._43); // Get vector from the matrix
// move the tank forward (speed is the speed you want to move the tank every time this function is called)
tankPosX += speed * vecTankForward.x;
tankPosZ += speed * vecTankForward.z;
D3DXMatrixTranslation(&matCenter, 0.0f, 0.0f, 0.0f); // *** Rotation point ***
D3DXMatrixTranslation(&matPos, tankPosX, -240.0f, tankPosZ);
D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f);
d3ddev->SetTransform(D3DTS_WORLD, &(matScale * matCenter * matRot * matPos));