私は現在、DirectX の飛行機で簡単な車のシミュレーションに取り組んでいます。飛行機での車の向きに問題があります。
私がしているのはこれです...
D3DXMATRIX planeMat //matrix of the plane on which car is currently situated.
...
//calculating car rotation matrix (on XZ plane )
D3DXMATRIX carRot;
D3DXMatrixRotationY( &carRot , yaw );
//car up will same as plane
D3DXVECTOR3 carUp = D3DXVECTOR3( planeMat._12 , planeMat._22 , planeMat._32 );
//car lookat vector
D3DXVECTOR3 carLookat = D3DXVECTOR3( carRot._13 , carRot._23 , carRot._33 );
// calculating right vector
D3DXVec3Cross( &carRight , &carLookAt , &carUp );
D3DXVec3Normalize( &carRight , &carRight );
//calculating new lookat
D3DXVec3Cross( &carLookAt , &carRight , &carUp );
D3DXVec3Normalize( &carLookAt , &carLookAt );
//car matrix
D3DXMATRIX carMat; D3DXMatrixIdentity( &carMat );
carMat._11 = carRight.x ;carMat._21 = carRight.y ;carMat._31 = carRight.z ;
carMat._12 = carUp.x ;carMat._22 = carUp.y ;carMat._32 = carUp.z ;
carMat._13 = carLookAt.x ;carMat._23 = carLookAt.y ;carMat._33 = carLookAt.z ;
carMat._41 = carPos.x ;carMat._42 = carPos.y ;carMat._43 = carPos.z ;
車の回転が正しく取れません。
私を助けてください。