Emini Physics Engine 1.3.5a API Documentation

at.emini.physics2D
Class Script

java.lang.Object
  extended by at.emini.physics2D.Script

public class Script
extends java.lang.Object

The script class represents a sequence of actions for a body.
It represents a sequence of "hard constraints" that can be repeated indefinitely.
Each script consists of simple script elements. Each element can influence the position, velocity or acceleration of the body.

Author:
Alexander Adensamer

Nested Class Summary
 class Script.ScriptElement
          Single action element for a script.
 
Field Summary
static int ACCELERATION
          Element Type acceleration
static int ANGLE
          Element Type angle
protected  java.util.Vector mElements
          Vector containing the scripting elements .
protected  boolean mRestart
          Flag if the script is restarted after finishing.
static int NONE
          Element Type none
static int POSITION
          Element Type position
static int ROTATIONAL_ACCELERATION
          Element Type acceleration
static int ROTATIONAL_VELOCITY
          Element Type velocity
static int VELOCITY
          Element Type velocity
 
Constructor Summary
Script(boolean restart)
          Constructor.
Script(Script script)
          Copy constructor.
 
Method Summary
 void addElement(int type, int target1, int timeSteps)
          Adds a new element to the script (only rotational elements).
 void addElement(int type, int target1, int target2, int timeSteps)
          Adds a new element to the script.
 void addElement(Script.ScriptElement element)
          Adds a script element directly.
 void applyToBody(Body b, World w)
          Applies the script to a body.
 Script copy()
          Copy method for the script object
protected  void executeScript(int index, World w)
          Executes the script.
static Script loadScript(PhysicsFileReader reader)
          Loads a script from a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Element Type none

See Also:
Constant Field Values

POSITION

public static final int POSITION
Element Type position

See Also:
Constant Field Values

VELOCITY

public static final int VELOCITY
Element Type velocity

See Also:
Constant Field Values

ACCELERATION

public static final int ACCELERATION
Element Type acceleration

See Also:
Constant Field Values

ANGLE

public static final int ANGLE
Element Type angle

See Also:
Constant Field Values

ROTATIONAL_VELOCITY

public static final int ROTATIONAL_VELOCITY
Element Type velocity

See Also:
Constant Field Values

ROTATIONAL_ACCELERATION

public static final int ROTATIONAL_ACCELERATION
Element Type acceleration

See Also:
Constant Field Values

mElements

protected java.util.Vector mElements
Vector containing the scripting elements .


mRestart

protected boolean mRestart
Flag if the script is restarted after finishing.

Constructor Detail

Script

public Script(boolean restart)
Constructor. Creates an empty script.

Parameters:
restart - the flag, if the script is restarted after finishing.

Script

public Script(Script script)
Copy constructor.

Parameters:
script - the source script object
Method Detail

copy

public Script copy()
Copy method for the script object

Returns:
the copy

applyToBody

public void applyToBody(Body b,
                        World w)
Applies the script to a body.

Parameters:
b - the body
w - the world managing the scripts

addElement

public void addElement(int type,
                       int target1,
                       int target2,
                       int timeSteps)
Adds a new element to the script.

Parameters:
type - the type of the element (position, velocity, etc.).
target1 - the first target value.
target2 - the second target value (only relevant for the vector types).
timeSteps - the number of timesteps.

addElement

public void addElement(int type,
                       int target1,
                       int timeSteps)
Adds a new element to the script (only rotational elements).

Parameters:
type - the type of the element (position, velocity, etc.).
target1 - the first target value.
timeSteps - the number of timesteps.

addElement

public void addElement(Script.ScriptElement element)
Adds a script element directly.

Parameters:
element - the script element.

executeScript

protected void executeScript(int index,
                             World w)
Executes the script.

Parameters:
index - the execution index (referring to the corresponding body, stored in the world)
w - the world

loadScript

public static Script loadScript(PhysicsFileReader reader)
Loads a script from a stream.

Parameters:
reader - the file reader.
Returns:
the loaded script

Emini Physics Engine 1.3.5a API Documentation

Emini Physics Engine 1.3.5a API Documentation - Copyright 2014 Alexander Adensamer