| Package | org.MARS.simulation |
| Class | public class Simulation |
| Inheritance | Simulation flash.display.Sprite |
PhysicsEngine class.
Note: Simulation class is implemented as a Singleton, therefore at most one instance of this class can exist. Use Simulation.getInstance() to access this instance.
| Property | Defined by | ||
|---|---|---|---|
| engine : PhysicsEngine
[read-only]
| Simulation | ||
| focusObject : ISimulatable | Simulation | ||
| isRunning : Boolean [read-only]
| Simulation | ||
| renderer : IRenderer
[read-only]
| Simulation | ||
| scale : Number | Simulation | ||
| Method | Defined by | ||
|---|---|---|---|
|
constructor
| Simulation | ||
|
addElement(element:ISimulatable, collide:Boolean = true, render:Boolean = true, solver:IODESolver = null):void
Adds an element to the simulation
This will probably be the most used method- it handles a lot of the logic necessary to give the user a lot of control without worrying about dividing up the element to its respective places in the application. | Simulation | ||
|
addGlobalForceGenerator(forceGenerator:IForceGenerator, applyToExisting:Boolean = true):void
Adds a global force to the simulation
This force will be added to all future and current (as defined by applyToExisting) elements | Simulation | ||
|
addRenderable(renderable:Renderable):void
Adds a renderable element to the renderer
| Simulation | ||
|
[static]
Gets the instance of the singleton
| Simulation | ||
|
removeElement(element:*):void
Removes the element from the simulation
| Simulation | ||
|
removeGlobalForceGenerator(forceGenerator:IForceGenerator, remainInEffect:Boolean = false):void
Removes a global force from the simulation
This force will be removed from all elements its currently generating for depending on remainInEffect | Simulation | ||
|
start():void
Starts running the simulation
| Simulation | ||
|
stepForward(event:Event = null):void
Advances the simulation one step
| Simulation | ||
|
still():void
Starts and pauses the simulation
| Simulation | ||
|
stop():void
Stops the simulation
| Simulation | ||
|
useMouseDragger(value:Boolean):void
Depicts whether to use the MouseSpring on bodies or not
| Simulation | ||
|
zoom(amount:Number, focus:ISimulatable = null):void
Zooms on the selected object in the simulation
| Simulation | ||
| Constant | Defined by | ||
|---|---|---|---|
| DEFAULT_COARSE_COLLISION_DETECTOR : Class [static] offers a default ICoarseCollisionDetector class
| Simulation | ||
| DEFAULT_ODE_SOLVER : Class [static] offers a default solver class for differential equations
| Simulation | ||
| DEFAULT_RENDERER : Class [static] offers a default IRenderer class
| Simulation | ||
| FRICTION_MAGNITUDE : Number = 0.05 [static] offers a default amount of friction applied to every object
| Simulation | ||
| engine | property |
| focusObject | property |
focusObject:ISimulatable [read-write]Implementation
public function get focusObject():ISimulatable
public function set focusObject(value:ISimulatable):void
| isRunning | property |
isRunning:Boolean [read-only]Implementation
public function get isRunning():Boolean
| renderer | property |
| scale | property |
scale:Number [read-write]Implementation
public function get scale():Number
public function set scale(value:Number):void
| Simulation | () | constructor |
public function Simulation()constructor
| addElement | () | method |
public function addElement(element:ISimulatable, collide:Boolean = true, render:Boolean = true, solver:IODESolver = null):voidAdds an element to the simulation
This will probably be the most used method- it handles a lot of the logic necessary to give the user a lot of control without worrying about dividing up the element to its respective places in the application.
Parameterselement:ISimulatable — ISimulatable to add
|
|
collide:Boolean (default = true) — defines whether this element should be tested for collision during simulation
|
|
render:Boolean (default = true) — defines whether this element should be drawn
|
|
solver:IODESolver (default = null) — a unique object to be interpreted by your IFoamRenderer and associated with this element
|
See also
| addGlobalForceGenerator | () | method |
public function addGlobalForceGenerator(forceGenerator:IForceGenerator, applyToExisting:Boolean = true):voidAdds a global force to the simulation
This force will be added to all future and current (as defined by applyToExisting) elements
ParametersforceGenerator:IForceGenerator — IForceGenerator to add
|
|
applyToExisting:Boolean (default = true) — whether to add this force generator to all
elements already added to FOAM
|
See also
| addRenderable | () | method |
public function addRenderable(renderable:Renderable):voidAdds a renderable element to the renderer
Parametersrenderable:Renderable — Renderable to add
|
See also
| getInstance | () | method |
public static function getInstance():SimulationGets the instance of the singleton
ReturnsSimulation —
Simulation instance
|
| removeElement | () | method |
public function removeElement(element:*):voidRemoves the element from the simulation
Parameterselement:* — element to remove
|
| removeGlobalForceGenerator | () | method |
public function removeGlobalForceGenerator(forceGenerator:IForceGenerator, remainInEffect:Boolean = false):voidRemoves a global force from the simulation
This force will be removed from all elements its currently generating for depending on remainInEffect
ParametersforceGenerator:IForceGenerator — IForceGenerator to remove
|
|
remainInEffect:Boolean (default = false) — whether to allow it to keep generating, but remove
it from new additions to FOAM, or remove it from all affected ISimulatables
|
See also
| start | () | method |
public function start():voidStarts running the simulation
See also
| stepForward | () | method |
public function stepForward(event:Event = null):voidAdvances the simulation one step
Parametersevent:Event (default = null) |
| still | () | method |
| stop | () | method |
| useMouseDragger | () | method |
public function useMouseDragger(value:Boolean):voidDepicts whether to use the MouseSpring on bodies or not
Parametersvalue:Boolean — true to use the dragger, false otherwise
|
| zoom | () | method |
public function zoom(amount:Number, focus:ISimulatable = null):voidZooms on the selected object in the simulation
Parametersamount:Number — - zoom amount
|
|
focus:ISimulatable (default = null) — - object to center the screen at
|
| DEFAULT_COARSE_COLLISION_DETECTOR | constant |
public static const DEFAULT_COARSE_COLLISION_DETECTOR:Classoffers a default ICoarseCollisionDetector class
| DEFAULT_ODE_SOLVER | constant |
public static const DEFAULT_ODE_SOLVER:Classoffers a default solver class for differential equations
| DEFAULT_RENDERER | constant |
public static const DEFAULT_RENDERER:Classoffers a default IRenderer class
| FRICTION_MAGNITUDE | constant |
public static const FRICTION_MAGNITUDE:Number = 0.05offers a default amount of friction applied to every object