2014-02-22 48 views
0

我有存储所述轮胎的旋转和平移XNA如何旋转汽车轮胎?

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

This happens

当我前进的轮旋转细,但是当我把它作为转动所示的图像矩阵。任何人都可以请帮忙。

回答

1

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

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更多的帮助在动画

+0

谢谢你的工作。 – user1281566

0

它看起来像我,你应用几次旋转的顺序,而不考虑在每个转换发生的轴的变化。

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