Integrate BEPU with the skinnedmodelextensions example

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
cygnus
Posts: 2
Joined: Fri Feb 12, 2010 7:01 pm

Integrate BEPU with the skinnedmodelextensions example

Post by cygnus »

Hi all,

I've an implementation question for how to combine the Skinned Model Extensions example (from the XNA creators site): http://creators.xna.com/en-US/tutorial/ ... extensions. (press Enter to see the spheres)
I've succeeded in implementing BEPU with static models (fi bricks falling on the ground) but don't know how to begin for integrating this with animated bounding spheres. I looked at the charactercontoller class from the examples but can't see how to link those bounding spheres with the controller.

Can someone help me with some pointers in the right direction?

Kind regards,

Wim
jbosch
Posts: 43
Joined: Sat May 29, 2010 4:42 pm
Contact:

Re: Integrate BEPU with the skinnedmodelextensions example

Post by jbosch »

I think that a sample in the documentation section would be very useful. The skinned model extension is a very interesting topic.

PD: Sorry because I'm not answering your question, I'm sure "the boss" will do it soon.
Jesús Bosch
XNA BLOG: http://geeks.ms/blogs/jbosch
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Integrate BEPU with the skinnedmodelextensions example

Post by Norbo »

The character controller is designed for moving around and negotiating obstacles. It uses a very simple shape, like a cylinder, to check if it can climb up a step or if it's hitting a wall.

What is your goal for this system? Is it going to be used to check for bullets? Or are do you also want it to interact with the environment?

The first step is to get entities to follow the bounding spheres (or bones, more generally). Fortunately, the skinning sample updates the positions of the spheres for you each frame. You could use kinematic Sphere entities and set their centerPosition property appropriately so they are in the right spot. If you're looking to something involving non-continuous collision detection or just bullet tracing, this would be sufficient.

If you want your character to be able to kick stuff around as it moves properly, you'll need to compute the velocities of the shapes as well. You could probably get away with just computing the linear velocity, since, as spheres, they don't change when rotated. The linear velocity of an entity is the (newPosition - oldPosition) / dt, where dt is the time since the old position.

For other non-spherical shapes, you might need to compute angular velocity and set the orientation as well. This is a little trickier; one way to do it is to compute the quaternion orientation difference and convert it to an axis-angle representation. The 3d angular velocity required to cover that distance is then axis * (angle / dt).

If your model is moving, be sure to take into account that linear/angular velocity as well.

Once you attach kinematic entities to everything and they move according to the animation, you'll need to determine what they can collide with. As kinematic entities, they will push any dynamic entity out of the way, so if your spheres follow a model that follows a character controller, your character controller will ram its way through any dynamic shape. You may want to change the collision rules (http://www.bepu-games.com/BEPUphysics/d ... tation.pdf) such that the character controller's simple shape collides with most things, but ignores tiny inconsequential shapes on the ground. The bounding spheres attached to the character act in the opposite way- they ignore most collisions, but collide with the inconsequential shapes. That way, your character will realistically kick debris around, but you won't go through walls or push over skyscrapers.

Creating a more physical system where the attached entities are dynamic gets substantially trickier.
Post Reply