Physics System

The interface between Bepu and XNA Final Engine does not pretend to wrap the entire Bepu library, but instead, it gives to the user the basic tools to use Bepu in XNA Final Engine without need to take care of the physics-graphics world sync nor collision detection, these points are handled transparent by the interface.

Game objects that are under the control of physics are updated automatically by the engine and the collisions between them can be handled through attached scripts by implementing the corresponding methods (OnCollisionEnter, OnCollisionStay, OnCollisionExit). Also, there are available a couple of Raycast methods in the PhysicsManager that allows to do raycasting and get the hit game object in case of hit or null otherwise. In addition, you can control the physics simulation’s settings trough the PhysicsManager like gravity, solver iterations, etcetera. In the PhysicsManager you have access to the Bepu space through the Scene property.

Besides the interface is still a work in progress you can do a lot of things because you have access to Bepu and the Bepu space (PhysicsManager.Scene). There is great flexibility in this point, you can place joints, constraints, manage materials, etcetera. You can control a game object through physics attaching a RigidBody component which have any Bepu entity you want.

It’s worth to note that every entity or collidable created by the components RigidBody or StaticCollider stores a reference in the tag property to the game object it belongs.


XNA Final Engine implements two components related to physics by now, RigidBody and StaticCollider. The first one it's used for movable game objects (dynamic or kinematic) and the second one it's used to represent static objects like scene geometry or unmovable obstacles.

Rigid bodies can be dynamic or kinematic; it depends of the Bepu entity used. Kinematic rigid bodies don't respond to forces nor collides with other kinematic rigid bodies but can affect dynamic rigid bodies. You have to use the Transform component in order to move a game object that has attached a kinematic rigid body. In the case of game objects that have attached a dynamic rigid body you can't use the transform component to move or rotate them, you need to apply forces to the rigid body's entity instead.

Dynamic rigid bodies have the chance to set the game object’s center of mass through the CenterOfMass property.

Both, the RigidBody and StaticCollider provide methods to create the Bepu entity directly from the ModelFilter attached to the game object which the RigidBody or StaticCollider belongs.

Last edited Jan 27, 2013 at 9:51 PM by jischneider, version 2


No comments yet.