我正在努力让我的物体在我的地形上旋转。现在这是我的问题,我可以旋转我的对象但不缩放它们或缩放但不旋转。这取决于我的代码行最后一行。例如,如果旋转代码最后一次,它将旋转但不会缩放。
这是我的代码
D3DXMatrixMultiply(¤tFrame->exCombinedTransformationMatrix, ¤tFrame->TransformationMatrix, parentMatrix);
D3DXMatrixScaling(¤tFrame->exCombinedTransformationMatrix, trans.Sx, trans.Sy, trans.Sz);
D3DXMatrixRotationX(¤tFrame->exCombinedTransformationMatrix, D3DXToRadian(trans.Rx));
我的一个伙伴,说我正在覆盖矩阵。
所以我试过这个
D3DXMatrixMultiply(¤tFrame->exCombinedTransformationMatrix, ¤tFrame->TransformationMatrix, parentMatrix);
D3DXMATRIX w;
D3DXMATRIX s;
D3DXMatrixScaling(&s, trans.Sx, trans.Sy, trans.Sz);
D3DXMatrixRotationX(&w, D3DXToRadian(trans.Rx));
D3DXMatrixMultiply(¤tFrame->exCombinedTransformationMatrix, &s, &w);
上面代码的结果现在无论如何都只会扩展。
答案 0 :(得分:1)
或者,您可以尝试使用D3DXMatrixTransformation或D3DXMatrixTransformation2D。这些功能似乎可以解决所有复杂问题(至少是2D问题)。
http://msdn.microsoft.com/en-us/library/windows/desktop/bb205365(v=vs.85).aspx 和 http://msdn.microsoft.com/en-us/library/windows/desktop/bb205366(v=vs.85).aspx