I have matrix that stores the tire rotation and translation

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

This happens

When I move forward the wheel rotates fine but when I turn it turns as shown in the image. Can anyone help please.

有帮助吗?

解决方案

I'm just making a guess on how you setup the rest of your code (such as whether the tire is part of the car or its own model, etc). This is one of many ways to do what you are trying to do. A car tire will only have to rotate along two axes: the axle of the car and the normal axis of the car. So to do a forward rotation you'll have to do something like this. (this is assuming your tire is part of the car mesh and has its own bone)

tireMatrix *= Matrix.CreateRotationX(roll); //or whichever axis your axle is on

And then to rotate your tire along the normal axis:

tireMatrix *= Matrix.CreateRotationY(turnangle);

If the tire is its own model (which is what your image looks like), then try:

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

Also see here for more help on animating

其他提示

It looks to me like you apply several rotations in sequence, without considering the change of the axis that occurs in each transformation.

In your first transformation you steer to the right and turn your tire accordingly. But then it is turned slightly to the right, and then what was previously the rolling motion will create this 'tumbling' movement.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top