C# XNA如何旋转汽车轮胎?

C# XNA如何旋转汽车轮胎?,c#,matrix,xna,rotation,quaternions,C#,Matrix,Xna,Rotation,Quaternions,我有存储轮胎旋转和平移的矩阵 tireMatrix = Matrix.CreateFromYawPitchRoll(yaw, pitch, roll); 当我向前移动时,车轮转动良好,但当我转动时,车轮转动,如图所示。谁能帮忙吗 在我看来,您可以按顺序应用多个旋转,而不考虑每次变换中发生的轴的变化 在第一次变换中,您向右转向,并相应地转动轮胎。但是它稍微向右旋转,然后之前的滚动运动会产生这种“翻滚”运动 我只是在猜测您如何设置其余代码(例如轮胎是汽车的一部分还是它自己的车型,等等)。这是做你

我有存储轮胎旋转和平移的矩阵

tireMatrix = Matrix.CreateFromYawPitchRoll(yaw, pitch, roll);


当我向前移动时,车轮转动良好,但当我转动时,车轮转动,如图所示。谁能帮忙吗

在我看来,您可以按顺序应用多个旋转,而不考虑每次变换中发生的轴的变化


在第一次变换中,您向右转向,并相应地转动轮胎。但是它稍微向右旋转,然后之前的滚动运动会产生这种“翻滚”运动

我只是在猜测您如何设置其余代码(例如轮胎是汽车的一部分还是它自己的车型,等等)。这是做你想做的事情的许多方法之一。汽车轮胎只需沿两条轴旋转:汽车轴和汽车法向轴。所以要做向前旋转,你必须做这样的事情。(这是假设您的轮胎是汽车网的一部分,并且有自己的骨骼)

然后沿法线轴旋转轮胎:

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); 
有关设置动画的更多帮助,请参见

//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);