org.jocl.cloth
Class Simulator

java.lang.Object
  extended by org.jocl.cloth.Simulator

 class Simulator
extends java.lang.Object

Simple implementation of a Simulator


Constructor Summary
Simulator(java.util.concurrent.Semaphore renderingSemaphore)
          Creates a new simulator using the given semaphore.
 
Method Summary
(package private)  void addTimeStepListener(TimeStepListener timeStepListener)
          Add the given listener to receive notifications about time steps
protected  void notifyAfterTimeStep(float totalTime, float timeStepSize)
          Notify all listeners about a time step
protected  void notifyBeforeTimeStep(float totalTime, float timeStepSize)
          Notify all listeners about a time step
(package private)  void removeTimeStepListener(TimeStepListener timeStepListener)
          Remove the given listener
(package private)  void setPaused(boolean newPaused)
          Set whether the simulation should be paused
(package private)  void setSimulation(Simulation simulation)
          Set the Simulation driven by this simulator.
(package private)  void start()
          Start the simulation thread.
(package private)  void stop()
          Stop the simulator as soon as possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulator

Simulator(java.util.concurrent.Semaphore renderingSemaphore)
Creates a new simulator using the given semaphore.

Parameters:
renderingSemaphore - The rendering semaphore. May be null.
Method Detail

setSimulation

void setSimulation(Simulation simulation)
Set the Simulation driven by this simulator. Any previously running simulations will be stopped.

Parameters:
simulation - The Simulation

start

void start()
Start the simulation thread. A Simulation must have been assigned to this simulator before this method may be called. Any previously running simulations will be stopped.


setPaused

void setPaused(boolean newPaused)
Set whether the simulation should be paused

Parameters:
newPaused - Whether the simulation should be paused

stop

void stop()
Stop the simulator as soon as possible. This method will block until the simulator has finished any time steps that may currently be in progress.


addTimeStepListener

void addTimeStepListener(TimeStepListener timeStepListener)
Add the given listener to receive notifications about time steps

Parameters:
timeStepListener - The listener to add

removeTimeStepListener

void removeTimeStepListener(TimeStepListener timeStepListener)
Remove the given listener

Parameters:
timeStepListener - The listener to add

notifyBeforeTimeStep

protected void notifyBeforeTimeStep(float totalTime,
                                    float timeStepSize)
Notify all listeners about a time step

Parameters:
totalTime - The total simulation time
timeStepSize - The time step size

notifyAfterTimeStep

protected void notifyAfterTimeStep(float totalTime,
                                   float timeStepSize)
Notify all listeners about a time step

Parameters:
totalTime - The total simulation time
timeStepSize - The time step size