Cylinder

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
DanStory
Posts: 7
Joined: Tue Aug 07, 2012 8:38 pm

Cylinder

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Cylinder

Post 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.
Post Reply