Page 1 of 1

Cylinder

Posted: Tue Sep 04, 2012 4:59 pm
by DanStory
I'm probably doing this all wrong :P

So I created a model, with mesh groups (body, bodycollision, wheel_frontdriver, etc)

When creating the physics entity for the wheel(s) I use the Cylinder shape (just like in the car demo) with a calculated height and radius from the wheel mesh's bounding box.

The problem is the Cylinder shape height is Y and radius is on Z, while the model's wheel height (actual width) is X and radius is Y (if that makes any sense)

So I rotate the shape (like the car demo) using:

Code: Select all

this.Entity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, MathHelper.PiOver2);
but then the graphic render of the model also rotates, causing it to be the wrong orientation.

What's the proper/better way of doing this?

Re: Cylinder

Posted: Tue Sep 04, 2012 6:17 pm
by Norbo
A local transform should be applied to the graphical model that brings it into alignment with the entity in its local space. Because the graphic then matches the entity in local space, the world transformed entity and graphic will match.

In other words:

Code: Select all

graphicWorldTransform = localTransform * entity.WorldTransform;
where localTransform is whatever transform is needed to pull the graphical model to match the entity's local space.