com.speckled.specksim
Interface MovementModel

All Superinterfaces:
Configurable
All Known Implementing Classes:
CacheingMovementModel, ExcitedHenge, GridMovementModel, PerspecksModel, SpeckledBodyModel, StaticMovementModel, WaypointMovementModel

public interface MovementModel
extends Configurable

Defines the physical position, orientation and velocity for each speck. I recommend that you extend the CacheingMovementModel class.

Author:
ryanm

Method Summary
 void deInit()
          Called when this model is replaced as the current model
 double getMaxSpeed()
          Gets the maximum possible speed that any Speck can move under this movement model.
 java.lang.String getName()
          Gets the name of this model
 SpeckPosition getSpeckOrientation(Speck speck, float time)
          Works out the position of a given speck at a given time.
 Vector3d getSpeckVelocity(Speck speck, float time)
          Works out the velocity of a given speck at a given time
 SerializableState getState(float time)
          Gets a state object from this model.
 void init(SpeckSim simulator)
          Called when this model is set to be the current model, or when the simulator is reset.
 void removeSpeck(Speck speck)
          Called when a speck is removed from the simulator.
 
Methods inherited from interface com.ryanm.config.Configurable
getConfigurator
 

Method Detail

getName

java.lang.String getName()
Gets the name of this model

Returns:
A String name for this model

init

void init(SpeckSim simulator)
Called when this model is set to be the current model, or when the simulator is reset. As such, this method must clear any old state as well as set up the new state

Parameters:
simulator - The simulator that this model is current in.

deInit

void deInit()
Called when this model is replaced as the current model


removeSpeck

void removeSpeck(Speck speck)
Called when a speck is removed from the simulator. Could be useful if the model maintain any state for each speck.

Parameters:
speck -

getSpeckOrientation

SpeckPosition getSpeckOrientation(Speck speck,
                                  float time)
Works out the position of a given speck at a given time. It can be assumed that, for a given speck, successive calls to the methods getSpeckOrientation() and getVelocity() method will be made with strictly increasing or equals values for time between simulator resets. If you need to maintain any state for each speck, this is the place to initialise it whenever you encounter a new speck

Parameters:
speck - The speck to locate
time - The time at which to locate
Returns:
The position and orientation of the speck at the time.

getSpeckVelocity

Vector3d getSpeckVelocity(Speck speck,
                          float time)
Works out the velocity of a given speck at a given time

Parameters:
speck - The speck to calculate velocity for
time - The time at which to calculate
Returns:
The velocity of the speck, in units per second

getMaxSpeed

double getMaxSpeed()
Gets the maximum possible speed that any Speck can move under this movement model. Enables some performance optimisations when looking for broadcast recipients. If we cannot define a maximum speed, we should return -1. Also, if you cannot guarantee that specks will not leave the unit cube,-1 should be returned

Returns:
The maximum possible speed of any speck, in units per second, or -1 if we cannot define a max speed, or if specks may possibly leave the unit cube

getState

SerializableState getState(float time)
Gets a state object from this model. This will be placed in the SimulatorState object that is passed to the GUI, consequently, this is useful for providing some data to be visualised. For instance, SpeckledBodyModels use it to pass the vertices of their bodies for visualisation. Feel free to pass null if you want to. This implementation of this method should not assume that the init() method has been called, so return an empty instance of the state object if this is the case

Parameters:
time - The time at which the state should be captured
Returns:
The interesting state of the movement model, or null if no state is needed