Module org.dyn4j

Package org.dyn4j.world

Package containing the dynamics engine.

The dynamics engine is an impulse based rigid body physics simulator. The simulation by default uses SI (m/kg/s) units. This can be changed, but all settings within the Settings singleton must be set to the new units. Instead its recommended to use the UnitConversion class to convert all values to MKS.

A constraint based approach is used to solving contacts and joints.

Create a World object to gain access the dynamics engine. Create Bodys and add them to the World. Add the AbstractPhysicsWorld.update(double) method to your game loop (notice the AbstractPhysicsWorld.update(double) method requires the elapsed time to be in seconds).

Upon creating a World a Bounds object may be supplied. The Bounds will determine when Bodys go out of bounds and deactivate them. Using the World() constructor will create a world that has no bounds, in which case the AbstractCollisionWorld.getBounds() method will return null.

A World object also contains a number listeners that can be used to respond to events that happen within the world, contact for instance.

Please read the respective documentation on each listener. Certain operations on the World object may not be allowed inside the listener methods.

The gravity of the World object can be changed, and can be in any direction via the AbstractPhysicsWorld.setGravity(org.dyn4j.geometry.Vector2) method.

The dynamics engine may require some configuration. The defaults should cover most applications, however, they can be changed using the Settings class on the World. Any setting can be changed at runtime so that no source code modification is needed. Refer to the source of Settings and the Sandbox for details on what each individual setting controls.

Since:
4.0.0
Version:
4.0.0
Author:
William Bittle