|
|
下面是我写的变换的部分。不知道哪里出了错。
哪位帮我看看咯~~
FLOAT fRoll, fPitch, fYaw;
fRoll = fPitch = 0.0f;
fYaw = CalculateAngle();
// Update rotation matrix
D3DXQUATERNION qR; //使用四元组实现
D3DXMATRIX matRot; //变换矩阵
D3DXQuaternionRotationYawPitchRoll (&qR, fYaw, fPitch, fRoll);
D3DXMatrixRotationQuaternion (&matRot, &qR);
D3DXMatrixMultiply (&g_pObject[0].matLocal, &matRot, &g_pObject[0].matLocal);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_pObject[0].matLocal);
//************************************************************
// camera stuff
//************************************************************
D3DXMATRIX matView;
D3DXMatrixIdentity( &matView );
matView._14 = g_pObject[0].matLocal._41;
matView._24 = g_pObject[0].matLocal._42;
matView._34 = g_pObject[0].matLocal._43;
// Update position and view matricies
D3DXMATRIX matR, matTemp;
D3DXQuaternionRotationYawPitchRoll (&qR, fYaw, fPitch, fRoll);
D3DXMatrixRotationQuaternion (&matR, &qR);
D3DXMatrixMultiply (&matView, &matR, &matView);
D3DXMatrixTranslation (&matTemp, vPos.x, vPos.y, vPos.z);
D3DXMatrixMultiply (&matView, &matTemp, &matView);
D3DXMatrixInverse (&matTemp, NULL, &matView);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matTemp );
|
|