-
- All Implemented Interfaces:
public final class World
Class for creating a world with iterative solver structure.
-
-
Method Summary
Modifier and Type Method Description final ArrayList<TranslatableBody>
getBodies()
final Unit
setBodies(ArrayList<TranslatableBody> bodies)
final ArrayList<Arbiter>
getContacts()
final Unit
setContacts(ArrayList<Arbiter> contacts)
final Vec2
getGravity()
final Unit
setGravity(Vec2 gravity)
final <T extends Any> T
addBody(T b)
Adds a body to the world final Unit
removeBody(TranslatableBody b)
Removes a body from the world. final Joint
addJoint(Joint j)
Adds a joint to the world. final Unit
removeJoint(Joint j)
Removes a joint from the world. final Unit
step(Double dt)
The main time step method for the world to conduct an iteration of the current world call this method with a desired time step value. final Unit
clearWorld()
Clears all objects in the current world final Unit
gravityBetweenObj()
Applies gravitational forces between to objects (force applied to centre of body) -
-
Constructor Detail
-
World
World(Vec2 gravity)
- Parameters:
gravity
- The strength of gravity in the world.
-
-
Method Detail
-
getBodies
final ArrayList<TranslatableBody> getBodies()
-
setBodies
final Unit setBodies(ArrayList<TranslatableBody> bodies)
-
getContacts
final ArrayList<Arbiter> getContacts()
-
setContacts
final Unit setContacts(ArrayList<Arbiter> contacts)
-
getGravity
final Vec2 getGravity()
-
setGravity
final Unit setGravity(Vec2 gravity)
- Parameters:
gravity
- The strength of gravity in the world.
-
removeBody
final Unit removeBody(TranslatableBody b)
Removes a body from the world.
- Parameters:
b
- The body to remove from the world.
-
removeJoint
final Unit removeJoint(Joint j)
Removes a joint from the world.
- Parameters:
j
- The joint to remove from the world.
-
step
final Unit step(Double dt)
The main time step method for the world to conduct an iteration of the current world call this method with a desired time step value.
- Parameters:
dt
- Timestep
-
clearWorld
final Unit clearWorld()
Clears all objects in the current world
-
gravityBetweenObj
final Unit gravityBetweenObj()
Applies gravitational forces between to objects (force applied to centre of body)
-
-
-
-