1
我目前正在使用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 ;
我不能讓汽車的旋轉正確。
請幫助我。
嗨,感謝你的ans.it working.i打勾它是正確的,但你可以告訴我任何我看到的地方,人們提取像我這樣做的方式,看,向上和向右的向量http:///www.toymaker.info/Games/html/camera.html – YAHOOOOO