| Package | org.MARS.dynamics |
| Class | public class PhysicsEngine |
This should typically be accessed through the more user friendly interface
The simulation takes the form:
1. Let each IODESolver advance the state of their equations 2. Narrow down possible collisions with the coarse collision detector 3. Find actual collisions and generate points of contact 4. Resolve collisions on a pairwise basis 5. repeat 1 - 4 for as many iterations as is depicted in solverIterations
A notable separation is that of elements responsible for advancing the system and those involved in collision detection/response. This distinction is made in the vain of modularity - but it doesn't provide the nicest interface for the casual developer; this sort of situation is what Simulation class is for.
See also
| Property | Defined by | ||
|---|---|---|---|
| solverIterations : int [write-only]
Sets the number of times the timestep is subdivided and collision is checked
| PhysicsEngine | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new Physics Engine
This should be viewed as a work in progress. | PhysicsEngine | ||
|
addCollidable(collidable:Shape):void
Adds a collidable element to the engine.
| PhysicsEngine | ||
|
addODESolver(solver:IODESolver):void
Adds an IODESolver to the engine.
| PhysicsEngine | ||
|
Gets an IBody that collides with the given point, if any
| PhysicsEngine | ||
|
removeCollidable(collidable:Shape):void
Removes a collidable element from simulation
| PhysicsEngine | ||
|
removeODESolver(solver:IODESolver):void
Removes an IODESolver from the simulation
| PhysicsEngine | ||
|
setCoarseCollisionDetector(detector:ICoarseCollisionDetector):void
Sets the engine's coarse collision detector
| PhysicsEngine | ||
|
setCollisionFactory(factory:ICollisionFactory):void
Defines the collision factory used by the coarse detector to return IFineCollisionDetectors
| PhysicsEngine | ||
|
step(dt:Number = 1.0):void
This seemingly harmless little method is the heart of the physics simulation.
| PhysicsEngine | ||
| Constant | Defined by | ||
|---|---|---|---|
| DEFAULT_COARSE_COLLISION_DETECTOR : Class [static] offers a default ICoarseCollisionDetector class
| PhysicsEngine | ||
| SOLVER_ITERATIONS : int = 3 [static] offers a default number of iterations per frame
| PhysicsEngine | ||
| solverIterations | property |
solverIterations:int [write-only]Sets the number of times the timestep is subdivided and collision is checked
Implementation public function set solverIterations(value:int):void
See also
| PhysicsEngine | () | constructor |
public function PhysicsEngine()Creates a new Physics Engine
This should be viewed as a work in progress. It currently uses a less-than-desirable approach to contact resolution. All functionality is pretty well broken out and shouldn't affect the user even given radical changes in future releases
Instantiation is typically handled through the Foam interface.
See also
| addCollidable | () | method |
public function addCollidable(collidable:Shape):voidAdds a collidable element to the engine. Because the engine draws a distinction between solvers and collidable elements, collidable elements can be added without needing its state solved and vice versa.
Parameterscollidable:Shape — ISimulatable to add to collision list
|
See also
| addODESolver | () | method |
public function addODESolver(solver:IODESolver):voidAdds an IODESolver to the engine. Because the engine draws a distinction between solvers and collidable elements, IODESolvers can be added without being tested/solved for collision and vice versa.
Parameterssolver:IODESolver — IODESolver to add
|
See also
| getBodyUnderPoint | () | method |
public function getBodyUnderPoint(point:Vector):IBodyGets an IBody that collides with the given point, if any
Parameterspoint:Vector — Vector to check against all bodies
|
IBody |
See also
| removeCollidable | () | method |
public function removeCollidable(collidable:Shape):voidRemoves a collidable element from simulation
Parameterscollidable:Shape — element to remove
|
| removeODESolver | () | method |
public function removeODESolver(solver:IODESolver):voidRemoves an IODESolver from the simulation
Parameterssolver:IODESolver — IODESolver to remove
|
| setCoarseCollisionDetector | () | method |
public function setCoarseCollisionDetector(detector:ICoarseCollisionDetector):voidSets the engine's coarse collision detector
Parametersdetector:ICoarseCollisionDetector — ICoarseCollisionDetector to handle broad phase culling
|
| setCollisionFactory | () | method |
public function setCollisionFactory(factory:ICollisionFactory):voidDefines the collision factory used by the coarse detector to return IFineCollisionDetectors
Parametersfactory:ICollisionFactory — CollisionFactory
|
| step | () | method |
public function step(dt:Number = 1.0):voidThis seemingly harmless little method is the heart of the physics simulation.
It takes a stepsize over which to advance the state of the system.
The more discrete the time step (and resultant subdivided timesteps
based on _solverIterations) the more realistic the
simulation. Realism comes at the cost of performance.
dt:Number (default = 1.0) — timestep with which to advance the system
|
See also
| DEFAULT_COARSE_COLLISION_DETECTOR | constant |
public static const DEFAULT_COARSE_COLLISION_DETECTOR:Classoffers a default ICoarseCollisionDetector class
| SOLVER_ITERATIONS | constant |
public static const SOLVER_ITERATIONS:int = 3offers a default number of iterations per frame