XNAnimation

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
diadem
Posts: 10
Joined: Sat Jan 17, 2009 4:19 am

XNAnimation

Post by diadem »

I finally got around to checking out XNAnimation and want to add skinned models to my game.

This creates a new problem - I can't just use a convexhull and be done with it. What's the best way to handle models that aren't static? Now both the physics engine and the graphics engine want to control movement during an animation, and I can't see this as a good thing.

I can obviously make a box around my character, let the physics engine move the box around, and have the graphics engine manipulate the limbs inside that box, but that seems like cheating. Is there a way to maintain the close collision detection I'd get with a convexhull when using XNAnimation to animate my models via their bones?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: XNAnimation

Post by Norbo »

It depends on the level of detail that you want.

If you want to use a traditional character controller in terms of hitting walls and walking around combined with precise collision detection based on individual bones for testing raycasts, you could get by with moving and rotating kinematic objects to the appropriate location determined by the animation each frame.

If you want these objects to collide and impart velocities on other objects in the world appropriately, things get a bit more tricky. The character controller body will no longer be responsible for pushing objects out of the way and you'll have to revise the way finding supports works. The individual bones will need to have their angular and linear velocities computed each frame based on the animation so that collisions with the entities causes a believable push. With kinematic objects you also need to consider that they have infinite mass, so they could push things out of the way that you really don't want to push if you're not careful. One way to cull out unwanted parts would be to analyze the collision pairs that are created with some outer body to determine if the outer body or the character limb should handle a collision. This way, the outer body would prevent the character from walking too close to walls or big objects, while low-mass objects would be pushed around by the character limbs.

The most complicated method is to make the bones a hybrid of kinematic and dynamic objects or just all dynamic. A hybrid approach requires switching in and out of dynamic simulation depending on if the bone/limb/body is undergoing some stress (such as a collision). These bones would be connected by joints and constraints to keep things from flying apart. The most complicated part would be bringing the dynamic character towards the animation after the stress has been alleviated. This could be done through trying to match the current pose by applying direct impulses each frame or some other approximation.
Post Reply