Problem with wheel mesh rotation

# Problem with wheel mesh rotation

• 26 กันยายน 2554 15:24

Dear all,

I am working on simulating the Robotino robot in the MRDS VSE. To give you a rough idea, Robotino's circular wheel base is holonomic, consists of three wheels which are 120 degrees adjacent to each other; something like the mercedes logo.

Now I managed to orient the wheelentities in physics as follows:

```wheelLeftProp.LocalPose.Orientation = TypeConversion.FromXNA(xna.Quaternion.CreateFromAxisAngle(new xna.Vector3(0, 1, 0), -(float)(Math.PI / 6)));
wheelRightProp.LocalPose.Orientation = TypeConversion.FromXNA(xna.Quaternion.CreateFromAxisAngle(new xna.Vector3(0, 1, 0), (float)(Math.PI / 6)));
wheelRearProp.LocalPose.Orientation = TypeConversion.FromXNA(xna.Quaternion.CreateFromAxisAngle(new xna.Vector3(0, 1, 0), (float)(Math.PI / 2)));
```

Now when I try to orient my wheel meshes as follows:

```_wheelLeft.State.Assets.Mesh = "RobotinoWheel.obj";
_wheelLeft.MeshRotation = new Vector3(0, 30.0f, 0);
_wheelRight.State.Assets.Mesh = "RobotinoWheel.obj";
_wheelRight.MeshRotation = new Vector3(0, -30.0f, 0);
_wheelRear.State.Assets.Mesh = "RobotinoWheel.obj";
_wheelRear.MeshRotation = new Vector3(0, 0.0f, 0);

```

The orientation is fine when the simulation starts up but as soon as I rotate the wheels, axis of rotation of the physics wheel entity and the axis of rotation of the wheel meshes don't seem to be the same and it looks odd.

Maybe I'm missing something here? Any help would be appreciated. Thank you in advance.

Cheers,

Hozefa

### ตอบทั้งหมด

• 27 กันยายน 2554 12:39

Ok, problem solved! I created three RotatingWheelEntity classes for the three different wheels and overrode the Render function to render the wheel meshes accordingly.

Just one thing bothers me though. When I tried overriding the Update function (as mentioned in the Pro MRDS book), it didn't render as I wanted it to. So I tried overriding the Render function and it worked. Can someone check if this is a bug? Just wanted to put it out there.

The code for overriding the Render function for one of the RotatingWheelEntity classes is as follows:

```public override void Render(VisualEntity.RenderMode renderMode, MatrixTransforms transforms, CameraEntity currentCamera)
{
Wheel.State.LocalPose.Orientation = TypeConversion.FromXNA(
xna.Quaternion.CreateFromAxisAngle(
new xna.Vector3(0.86602540378f, 0, 0.5f), -(float)(Rotations * 2 * Math.PI)));
base.Render(renderMode, transforms, currentCamera);
}```

Cheers,

Hozefa

• ทำเครื่องหมายเป็นคำตอบโดย 27 กันยายน 2554 12:40
•