Best method for separating rendering from physics engine?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
mattbettcher
Posts: 7
Joined: Sun Mar 08, 2009 12:51 am

Best method for separating rendering from physics engine?

Post by mattbettcher »

My question is basically very simple. Should I use the same polygon meshes as my models for the physics engine or create lower res versions.

Also, I want to use skinned models and attach bone to a body, aka ragdoll physics, but I want be able to control the animation manually until a certain condition is met and then enable that part of the models bodies to create a partial ragdoll effect.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Best method for separating rendering from physics engine?

Post by Norbo »

Generally speaking, you'll want to use a separate representation for the graphics and physics. For fairly simple geometry it's less of an issue. It's good to stick to the simplest possible geometry for the physics side, so a Box entity might be used for a crate rather than a ConvexHull generated from the vertices of a crate model. In many cases, it will be possible to use a simple shape like ConvexHull even in replacement of concave objects that could otherwise be represented using CompoundBodies. If you encounter a case where you can only get the desired result while using CompoundBodies, try to make the subbodies relatively simple rather than using every triangle of the model. The collision system is technically fast enough to handle even this worst case of a fully triangulated complex CompoundBody, but it introduces more complications than it is worth usually (objects shoving themselves inside the triangulated skin and getting stuck is one possibility).

For the character, you'll need to compute the linear and angular velocity of the bone at a position where the physics object for that bone will be placed. This allows a smooth transition. To maintain a connection to the rest of the body (which may still be kinematic), a kinematic entity (one with infinite mass basically, created either by using the entity constructor with no specified mass or by using Entity.makeNonDynamic()) could be placed at the parent joint and controlled by the animation. A constraint would then connect this parent kinematic object to the newly dynamic ragdoll child.

One way to do this would be to have the entire skeleton set up as kinematic entities that are updated each frame (position and velocity). Since they wouldn’t necessarily have to collide with anything yet, setting their Entity.isTangible flag to false would help out. They can be turned into physical objects using the Entity.makePhysical(mass) method which would then collide with the environment.

This is actually something I’m working on myself for a part of a sub-project. I’m not sure when/if I’ll be able to release it, though. One thing that needs to be added to BEPUphysics itself for better ragdolls is joint limits which I hope to get to in the next few versions.
mattbettcher
Posts: 7
Joined: Sun Mar 08, 2009 12:51 am

Re: Best method for separating rendering from physics engine?

Post by mattbettcher »

Thanks for the outstanding response. I'm definitely gonna use your engine in the future. Expect some questions and possibly some sample code of my own when I get some of my ideas working.
Post Reply