SimplePhysics resides in Rendering2D for it does not depend on any actual physics classes but can be an efficient replacement if real physics is not needed anyway.

For both 2D and 3D, the structure of inheritance is like this:



Hence the split between HierarchyEntities and DrawableEntities is gone, making the former a subcategory of the latter given that both of them are pretty much based on positioning.

A split that still remains so far is between 2D and 3D, epecially since the ways of applying a rotation to 2D or 3D elements are quite different.
Not sure yet how to unify that without sacrificing efficiency as would result from constantly recalculating Quaternions.


Delta engine provides unified way to support Physics simulation, most code is quite unified for both 2D and 3D simulation. It uses the way in which most physics engine works, this means that you need first to create the physics simulation body and then attach one or more shapes.

Delta engine supports running only one 2D or 3D simulation engine at time, if you need to merge both of them you need to subclass the PhysicsManager with your own physics manager and implement both 2D and 3D stuff. This class is used for creation of every single body with its respective shape, it also manages whether given feature is supported by given physics module implementation, you can check whether given shape is supported, whether given joint is supported and so on. This class also keeps whole collection of the bodies created during simulation so you can easily access later for modification and rest of the stuff, you can also pause simulation and retrieve simulation info (like number or bodies, number of shapes, number of dynamic and static bodies).

For previewing debug info like drawing of debug shapes you need to set the DebugEnabled property value to what you need, Delta engine provides automatic way of drawing debug shapes for both 2D and 3D stuff.

Note: PhysicsManager automatically updates simulation and there is no need to automatically update any single simulation into your application runing.


Delta engine comes with implementation of Farseer physics engine.

Farseer Farseer Physics Engine is a 2D collision detection system with realistic physics responses. This means you can create a game or robotic simulation easily using the engine and the associated tools. Everything from simple hobby games to complex simulation systems is possible with Farseer Physics Engine.

Delta engine uses the latest Farseer 3.2 version its embedded as external dll and can easily be updated by user without need to made lot of changes but only to match the data types of Delta engine.

Check also the documentation of the physics engine out.

Data types mapping to Delta engine

Vector2 - Point Vector3 - Vector

Missing MathUtils methods like Clamp can be performed using the MathHelper class of the engine.



The 3D part is responsible for handling our physics world. It is in charge of the simulation controlling how the objects react when colliding or some forces are applied, we use a list of objects for that purpose. Inside there is logic which dictate how objects should interact each other, which primitives has collision and how do we update the position of each non-static object. It is the main reference to work with the physics3D where you can see all the current available features, and is constructed in an easy-way to use, through a friendly interface we provide everything the user requires without letting know complicated details about physics. Everything is pretty well commented so it makes easier to understand each function, parameter or variable we are using. In case of being interested about the work-flow process or how do we do it, the module is plenty of explanation.

The physics engine comes with a stuff like Joints and basically they are mapped through different physics engines. For report on different joint support check just below.

Delta engine comes with both implementation of JigLibX and Jitter, both of them are well supported, but in some way Jitter seams to be faster than JigLibX and support more shapes (like cone, cylinder and even 3D compound shapes). Both of the supports Windows 7 and of course Xbox 360 support. Good overview of physic engines and ones that work in .NET: http://www.digitalrune.com/Support/Blog/tabid/719/EntryId/30/Physics-Engines-List.aspx

More info about JigLibX can be found at: JigLibX on Codeplex and JigLibX wiki

About Jitter you can see here: Jitter homepage


Supported Shapes by each physics engine:


Circle = Farseer Rectangle = Farseer Ellipse = Farseer Polygon = Farseer Compound = Farseer Gear = Farseer

Box = Jitter, JigLib Sphere = Jitter, JigLib Plane = Jitter, JigLib Capsule = Jitter, JigLib Triangle = Jitter, JigLib Terrain = Jitter, JigLib Cone = Jitter Cylinder = Jitter

Supported Joint by each physics engine:

Angle = Farseer FixedAngle = Jitter PointOnLine = Jitter, JigLib PointOnPoint = Jitter, JigLib PointPointDistance = Jitter SingleBodyPointOnLine = Jitter Hinge = Jitter Prismatic = Jitter


Delta engine requires first to have Body created with its shape attached. To avoid annoying code and faster way there are some "goodies" to PhysicsManager to create body with single shape.

1
PhysicsBody body = PhysicsManager.CreateCircle(3.0f,2.0f);

This is the same as doing.

1
2
PhysicsShape circle = PhysicsManager.CreateCircleShape(3.0f,2.0f);
PhysicsBody body = PhysicsManager.Create2DBody(circle);

When creating some body there is the possibility to set the position too.
1
PhysicsBody body = PhysicsManager.CreateCircle(new Point(.5f,.5f),3.0f,2.0f);


To avoid writing twice same code, Delta engine physics implementation provided unified way on setting position and rotation too. PhysicsBody has property called Position which is expressed as Vector, which for 3D simulation is right, but for 2D simulation you need only to worry about X and Y component of it. If you instead need to set rotation into 2D simulation you need to call:
1
PhysicsBody.Rotation = 0.4f;

For 3D simulation you need to set the rotation matrix, so just call:
1
PhysicsBody.RotationMatrix = Matrix.CreateRotationZ(0.4f);


1
PhysicsBody.IsStatic = true;
This will arrange whole stuff on setting property whether given shape is dynamic or not for both 2D and 3D simulation.


Debug rendering into Delta engine is quite straight, just call:
1
PhysicsManager.DebugEnabled = true;

Our system automatically handles drawing of whole 2D shapes like Circle,Rectangle etc for 2D physics engine and 3D shapes like Box, Sphere, Plane etc.


Delta engine physics system provides method for checking whether given feature is supported by module implementation. To check for example whether physics controller are supported you can just do:
1
bool isSupported = PhysicsManager.IsFeatureSupported(FeatureSupport.Controller);
It allows also to check whether given shape or joint is supported, as always just do:
1
bool isSupported = PhysicsManager.IsShapeSupported(ShapeType.Capsule);
Or for joint.
1
bool isSupported = PhysicsManager.IsJointSupported(JointType.Angle);


1
2
3
4
// Controllers are hocked up to input events!
controller.Move += Input.MoveEvents;
controller.Jump += Input.JumpEvent;
controller.Rotate += Input.RotateEvents;


As stated the PhysicsManager is responsible for high-level handling of physics functions. It acts as an template and states which common functions or properties should be implemented. 

The provided properties:

  • Gravity: represents the acceleration at which objects fall to the center. It is possible to change its direction and strength, into 2D physics module only the and Y component are handled.

The provided functions:

  • Shape creation: 2D: circle, rectangle, ellipse, polygon, compound, gear; 3D: box, sphere, capsule, plane, cone, cylinder, triangle (constructed from mesh).
  • Collision, it detects any collision between objects and reacts by following Newton laws
  • Forces, you can release some forces 

Shape creation

Each 3D primitive has its own class which is implemented to provide all needed properties in a uncomplicated way as we want to keep to the user irrelevant physics calculation totally transparent so no one have to handle with it. Through our interface we provide all required functions to allow maximum flexibility, it allows changing and tweaking physics behaviors as wish.


Collision detection 

  • A static test checks two stationary primitives and detects if the two primitives intersect. It is a Boolean test that is, it usually only returns true (intersection detected) or false (no intersection). More information may be available if there is an intersection, but in general, the test is primarily designed to return a Boolean result. This testing is not very accurate for dynamic objects since it doesn't provide the exact point in which the collision occur.
  • TODO: A dynamic test checks two moving primitives and detects if and when two primitives intersect. Usually the movement is expressed parametrically, and therefore, the result of such a test is not only a Boolean true/false result but also a time value (value of the parameter t) that indicates when the primitives intersect.

Collision response (forces and kinematics) 

We apply the three laws of Newton in which first of all we calculate all the involved forces in the process, gravity force, normal force and friction force. After it we calculate the direction which our object will head. Last step is updating kinematics. We simply apply the uniformly accelerated motion in which the velocity of an object changes proportional amounts among time. An example of an object having uniform a acceleration would be a ball rolling down a ramp. The object picks up velocity as it goes down the ramp with equal changes in time. The most frequently cited example of uniform acceleration however is that of an object in free fall