所有vector3's。向前是方向向量。
到目前为止,我有这个,但它没有按预期工作
D3DXVECTOR3 cross, cross1;
cross = kartposition - Lwheelposition;
cross1 = kartposition - Rwheelposition;
D3DXVec3Cross(&up, &cross, &cross1);
D3DXVec3Normalize(&up, &up);
D3DXVec3Cross(&right, &forward,&up);
D3DXVec3Normalize(&right, &right);
D3DXVec3Cross(&forward, &up,&right);
D3DXVec3Normalize(&forward, &forward);
D3DXMatrixLookAtLH(&localtransform[0], &D3DXVECTOR3(0, 0, 0) ,&(forward), &up);
任何建议都会很棒。
我相信解决了。
将2行更改为
cross = Lwheelposition-kartposition; cross1 = Rwheelposition - kartposition;
并添加到最后
D3DXMatrixInverse(安培; localtransform [0],NULL,&安培; localtransform [0]);
反转看功能的动作。
答案 0 :(得分:0)
我已经修改并通过参考
解决了这个问题最终代码如下。
D3DXVECTOR3 cross, cross1;
cross = Lwheelposition - kartposition;
cross1 = Rwheelposition - kartposition;
D3DXVec3Cross(&up, &cross, &cross1);
D3DXVec3Normalize(&up, &up);
D3DXVec3Cross(&right, &up,&forward);
D3DXVec3Normalize(&right, &right);
D3DXVec3Cross(&kartforward, &right, &up);
localtransform[0]=D3DXMATRIX (right.x, right.y, right.z, 0.0f,
up.x, up.y, up.z, 0.0f,
kartforward.x, kartforward.y, kartforward.z, 0.0f,
kartposition.x, kartposition.y, kartposition.z, 1.0f);
希望这有用。