【发布时间】:2014-02-22 23:39:30
【问题描述】:
我有存储轮胎旋转和平移的矩阵
tireMatrix = Matrix.CreateFromYawPitchRoll(yaw, pitch, roll);
当我向前移动时,轮子旋转得很好,但是当我转动时,它会如图所示转动。任何人都可以帮忙吗?
【问题讨论】:
标签: c# matrix xna rotation quaternions
我有存储轮胎旋转和平移的矩阵
tireMatrix = Matrix.CreateFromYawPitchRoll(yaw, pitch, roll);
当我向前移动时,轮子旋转得很好,但是当我转动时,它会如图所示转动。任何人都可以帮忙吗?
【问题讨论】:
标签: c# matrix xna rotation quaternions
我只是在猜测您如何设置其余代码(例如轮胎是汽车的一部分还是它自己的型号等)。这是许多种方法来做你想做的事情之一。汽车轮胎只需沿两个轴旋转:汽车的轴和汽车的法线轴。因此,要进行正向旋转,您必须执行类似的操作。 (这是假设你的轮胎是汽车网的一部分并且有自己的骨头)
tireMatrix *= Matrix.CreateRotationX(roll); //or whichever axis your axle is on
然后沿法线轴旋转轮胎:
tireMatrix *= Matrix.CreateRotationY(turnangle);
如果轮胎是它自己的模型(这就是你的图像的样子),那么试试:
//rotate the tire along the right axis to make it spin
tireMatrix *= Matrix.CreateFromAxisAngle(tireMatrix.Right, theta);
//rotate the tire along its normal axis
tireMatrix *= Matrix.CreateFromAxisAngle(tireMatrix.Up, turntheta);
有关动画的更多帮助,另请参阅 here
【讨论】:
在我看来,您按顺序应用了几次旋转,而没有考虑每次变换中发生的轴变化。
在您的第一次转换中,您向右转向并相应地转动轮胎。但随后它稍微向右转,然后以前的滚动运动将产生这种“翻滚”运动。
【讨论】: