com.jmex.effects.particles
Class ParticleController

java.lang.Object
  extended by com.jme.scene.Controller
      extended by com.jmex.effects.particles.ParticleController
All Implemented Interfaces:
Savable, java.io.Serializable

public class ParticleController
extends Controller

ParticleController controls and maintains the parameters of a ParticleGeometry particle system over time.

Version:
$Id: ParticleController.java 4133 2009-03-19 20:40:11Z blaine.dev $
Author:
Joshua Slack
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList<ParticleControllerListener> listeners
           
 
Fields inherited from class com.jme.scene.Controller
RT_CLAMP, RT_CYCLE, RT_WRAP
 
Constructor Summary
ParticleController()
           
ParticleController(ParticleSystem system)
          ParticleManager constructor
 
Method Summary
 void addInfluence(ParticleInfluence influence)
          Add an external influence to this particle controller.
 void addListener(ParticleControllerListener listener)
          Subscribe a listener to receive mouse events.
 void clearInfluences()
           
 boolean containsListener(ParticleControllerListener listener)
          Check if a listener is allready added to this ParticleController
 java.util.ArrayList<ParticleInfluence> getInfluences()
          Returns the list of influences acting on this particle controller.
 int getIterations()
          Return the number this manager has warmed up
 java.util.ArrayList<ParticleControllerListener> getListeners()
          Get all added ParticleController listeners
 Spatial getParticles()
          Get the Spatial that holds all of the particle information for display.
 float getPrecision()
          Get how soon after the last update the manager will send updates to the particles.
 float getReleaseVariance()
          Get the variance possible on the release rate.
 Camera getViewCamera()
           
 boolean isControlFlow()
          Does this manager regulate the particle flow?
 boolean isUpdateOnlyInView()
          Does this manager use the particle's bounding volume to limit updates?
 void read(JMEImporter e)
           
 boolean removeInfluence(ParticleInfluence influence)
          Remove an influence from this particle controller.
 void removeListener(ParticleControllerListener listener)
          Unsubscribe a listener.
 void removeListeners()
          Remove all listeners and disable event generation.
 void setControlFlow(boolean regulate)
          Set the regulate flow property on the manager.
 void setIterations(int iterations)
          Sets the iterations for the warmup and calls warmUp with the number of iterations as the argument
 void setPrecision(float precision)
          Set how soon after the last update the manager will send updates to the particles.
 void setReleaseVariance(float variance)
          Set the variance possible on the release rate.
 void setUpdateOnlyInView(boolean updateOnlyInView)
          Set the updateOnlyInView property on the manager.
 void setViewCamera(Camera viewCamera)
           
 void update(float secondsPassed)
          Update the particles managed by this manager.
 void warmUp(int iterations)
          Runs the update method of this particle manager for iteration seconds with an update every .1 seconds (IE iterations * 10 update(.1f) calls).
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.Controller
getClassTag, getControllerValues, getMaxTime, getMinTime, getRepeatType, getSpeed, isActive, setActive, setControllerValues, setMaxTime, setMinTime, setRepeatType, setSpeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected java.util.ArrayList<ParticleControllerListener> listeners
Constructor Detail

ParticleController

public ParticleController()

ParticleController

public ParticleController(ParticleSystem system)
ParticleManager constructor

Parameters:
system - Target ParticleGeometry to act upon.
Method Detail

update

public void update(float secondsPassed)
Update the particles managed by this manager. If any particles are "dead" recreate them at the origin position (which may be a point, line or rectangle.) See com.jme.scene.Controller.update(float)

Specified by:
update in class Controller
Parameters:
secondsPassed - float

getPrecision

public float getPrecision()
Get how soon after the last update the manager will send updates to the particles.

Returns:
The precision.

setPrecision

public void setPrecision(float precision)
Set how soon after the last update the manager will send updates to the particles. Defaults to .01f (10ms)

This means that if an update is called every 2ms (e.g. running at 500 FPS) the particles position and stats will be updated every fifth frame with the elapsed time (in this case, 10ms) since previous update.

Parameters:
precision - in seconds

getReleaseVariance

public float getReleaseVariance()
Get the variance possible on the release rate. 0.0f = no variance 0.5f = between releaseRate / 2f and 1.5f * releaseRate

Returns:
release variance as a percent.

setReleaseVariance

public void setReleaseVariance(float variance)
Set the variance possible on the release rate.

Parameters:
variance - release rate +/- variance as a percent (eg. .5 = 50%)

isControlFlow

public boolean isControlFlow()
Does this manager regulate the particle flow?

Returns:
true if this manager regulates how many particles per sec are emitted.

setControlFlow

public void setControlFlow(boolean regulate)
Set the regulate flow property on the manager.

Parameters:
regulate - regulate particle flow.

isUpdateOnlyInView

public boolean isUpdateOnlyInView()
Does this manager use the particle's bounding volume to limit updates?

Returns:
true if this manager only updates the particles when they are in view.

setUpdateOnlyInView

public void setUpdateOnlyInView(boolean updateOnlyInView)
Set the updateOnlyInView property on the manager.

Parameters:
updateOnlyInView - use the particle's bounding volume to limit updates.

getViewCamera

public Camera getViewCamera()
Returns:
the camera to be used in updateOnlyInView situations. If null, the current displaySystem's renderer camera is used.

setViewCamera

public void setViewCamera(Camera viewCamera)
Parameters:
viewCamera - sets the camera to be used in updateOnlyInView situations. If null, the current displaySystem's renderer camera is used.

getParticles

public Spatial getParticles()
Get the Spatial that holds all of the particle information for display.

Returns:
Spatial holding particle information.

getIterations

public int getIterations()
Return the number this manager has warmed up

Returns:
int

setIterations

public void setIterations(int iterations)
Sets the iterations for the warmup and calls warmUp with the number of iterations as the argument

Parameters:
iterations -

addInfluence

public void addInfluence(ParticleInfluence influence)
Add an external influence to this particle controller.

Parameters:
influence - ParticleInfluence

removeInfluence

public boolean removeInfluence(ParticleInfluence influence)
Remove an influence from this particle controller.

Parameters:
influence - ParticleInfluence
Returns:
true if found and removed.

getInfluences

public java.util.ArrayList<ParticleInfluence> getInfluences()
Returns the list of influences acting on this particle controller.

Returns:
ArrayList

clearInfluences

public void clearInfluences()

addListener

public void addListener(ParticleControllerListener listener)
Subscribe a listener to receive mouse events. Enable event generation.

Parameters:
listener - to be subscribed

removeListener

public void removeListener(ParticleControllerListener listener)
Unsubscribe a listener. Disable event generation if no more listeners.

Parameters:
listener - to be unsuscribed
See Also:
addListener(ParticleControllerListener)

removeListeners

public void removeListeners()
Remove all listeners and disable event generation.


containsListener

public boolean containsListener(ParticleControllerListener listener)
Check if a listener is allready added to this ParticleController

Parameters:
listener - listener to check for
Returns:
true if listener is contained in the listenerlist

getListeners

public java.util.ArrayList<ParticleControllerListener> getListeners()
Get all added ParticleController listeners

Returns:
ArrayList of listeners added to this ParticleController

warmUp

public void warmUp(int iterations)
Runs the update method of this particle manager for iteration seconds with an update every .1 seconds (IE iterations * 10 update(.1f) calls). This is used to "warm up" and get the particle manager going.

Parameters:
iterations - The number of iterations to warm up.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class Controller
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class Controller
Throws:
java.io.IOException