Packageorg.generalrelativity.foam
Classpublic class Foam
InheritanceFoam Inheritance flash.display.Sprite



Public Properties
 PropertyDefined by
  defaultSolver : Class
[write-only]
Foam
  engine : PhysicsEngine
[read-only]
Foam
  simulatables : Array
[read-only]
Foam
  solverIterations : int
[write-only]
Foam
  timestep : Number
Foam
Public Methods
 MethodDefined by
  
Foam()
Creates a new FOAM interface This is most likely the first step in creating a physics simulation.
Foam
  
addElement(element:ISimulatable, collide:Boolean = true, render:Boolean = true, renderData:* = null, 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.

Foam
  
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

Foam
  
addRenderable(renderable:Renderable):void
Adds a renderable element to the renderer
Foam
  
Removes an element from the simulation

This removes the element from the renderer and the engine.

Foam
  
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

Foam
  
Sets the engine's coarse collision detector
Foam
  
Defines the collision factory used by the coarse detector to return IFineCollisionDetectors
Foam
  
setRenderer(renderer:IFoamRenderer):void
Sets the renderer
Foam
  
simulate():void
Starts running the simulation
Foam
  
stepBackward(event:Event = null):void
Foam
  
stepForward(event:Event = null):void
Foam
  
stop():void
Stops the simulation
Foam
  
Removes an element from collision consideration
Foam
  
stopDrawing(element:*):void
Stops an element from being rendered.
Foam
  
Stops an element from being simulated

Note that this does not stop an element from being rendered.

Foam
  
useMouseDragger(value:Boolean):void
Depicts whether to use the MouseSpring on bodies or not
Foam
Events
 EventSummaryDefined by
    Foam
Public Constants
 ConstantDefined by
  DEFAULT_ODE_SOLVER : Class
[static] offers a default solver class for differential equations
Foam
  STEP : String = "step"
[static] step event
Foam
Property detail
defaultSolverproperty
defaultSolver:Class  [write-only]Implementation
    public function set defaultSolver(value:Class):void
engineproperty 
engine:PhysicsEngine  [read-only]Implementation
    public function get engine():PhysicsEngine
simulatablesproperty 
simulatables:Array  [read-only]Implementation
    public function get simulatables():Array
solverIterationsproperty 
solverIterations:int  [write-only]Implementation
    public function set solverIterations(value:int):void
timestepproperty 
timestep:Number  [read-write]Implementation
    public function get timestep():Number
    public function set timestep(value:Number):void
Constructor detail
Foam()constructor
public function Foam()

Creates a new FOAM interface This is most likely the first step in creating a physics simulation.

Method detail
addElement()method
public function addElement(element:ISimulatable, collide:Boolean = true, render:Boolean = true, renderData:* = null, 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.

   //creates a new instance of Foam
   var foam:Foam = new Foam();
   //creates a triangle at x:100, y:100 with a mass of 100 (ShapeUtil.createSymmetricPolygon defaults to 3 vertices)
   var body:RigidBody = new RigidBody( 100, 100, 100, ShapeUtil.createSymmetricPolygon() );
   //adds the body to FOAM for simulation
   foam.addElement( body );
   
Parameters
element: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
 
renderData:* (default = null) — a unique object to be interpreted by your IFoamRenderer and associated with this element
 
solver:IODESolver (default = null) — IODESolver to use to advance the state of this element

See also

ISimulatable
RigidBody
IFoamRenderer
Renderable.data
IODESolver
addRenderable
addGlobalForceGenerator()method 
public function 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

Parameters
forceGenerator:IForceGenerator — IForceGenerator to add
 
applyToExisting:Boolean (default = true) — whether to add this force generator to all elements already added to FOAM

See also

ISimulatable.addForceGenerator
addRenderable()method 
public function addRenderable(renderable:Renderable):void

Adds a renderable element to the renderer

Parameters
renderable:Renderable — Renderable to add

See also

Renderable
IFoamRenderer
removeElement()method 
public function removeElement(element:ISimulatable):void

Removes an element from the simulation

This removes the element from the renderer and the engine.

Parameters
element:ISimulatable — ISimulatable to remove

See also

stopDrawing
stopSimulating
removeGlobalForceGenerator()method 
public function 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

Parameters
forceGenerator: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

ISimulatable.addForceGenerator
setCoarseCollisionDetector()method 
public function setCoarseCollisionDetector(detector:ICoarseCollisionDetector):void

Sets the engine's coarse collision detector

Parameters
detector:ICoarseCollisionDetector — ICoarseCollisionDetector to handle broad phase culling
setCollisionFactory()method 
public function setCollisionFactory(factory:ICollisionFactory):void

Defines the collision factory used by the coarse detector to return IFineCollisionDetectors

Parameters
factory:ICollisionFactory — CollisionFactory
setRenderer()method 
public function setRenderer(renderer:IFoamRenderer):void

Sets the renderer

Parameters
renderer:IFoamRenderer

See also

IFoamRenderer
simulate()method 
public function simulate():void

Starts running the simulation

See also

IFoamRenderer.draw
stepForward
stop
stepBackward()method 
public function stepBackward(event:Event = null):voidParameters
event:Event (default = null)
stepForward()method 
public function stepForward(event:Event = null):voidParameters
event:Event (default = null)
stop()method 
public function stop():void

Stops the simulation

See also

stopColliding()method 
public function stopColliding(element:ISimulatable):void

Removes an element from collision consideration

Parameters
element:ISimulatable — element to remove

See also

PhysicsEngine.removeCollidable
stopDrawing()method 
public function stopDrawing(element:*):void

Stops an element from being rendered.

Note that this does not stop the element from simulation when called by itself.

Parameters
element:* — element to remove
stopSimulating()method 
public function stopSimulating(element:ISimulatable):void

Stops an element from being simulated

Note that this does not stop an element from being rendered. It does, however remove it from collision consideration. Also, the simulation is stopped if there is nothing left to simulate.

Parameters
element:ISimulatable — element to remove from simulation
useMouseDragger()method 
public function useMouseDragger(value:Boolean):void

Depicts whether to use the MouseSpring on bodies or not

Parameters
value:Boolean — true to use the dragger, false otherwise
Event detail
stepevent 
Event object type: flash.events.Event

Constant detail
DEFAULT_ODE_SOLVERconstant
public static const DEFAULT_ODE_SOLVER:Class

offers a default solver class for differential equations

STEPconstant 
public static const STEP:String = "step"

step event