espresso3d.engine.world.sector.particle
Class E3DParticleSystem

java.lang.Object
  extended byespresso3d.engine.base.E3DEngineItem
      extended byespresso3d.engine.renderer.base.E3DRenderable
          extended byespresso3d.engine.world.sector.base.E3DPortalEnabledRenderable
              extended byespresso3d.engine.world.sector.particle.E3DParticleSystem
All Implemented Interfaces:
E3DPortalEnabledItem
Direct Known Subclasses:
BluePlasmaParticleFountain, RedPlasmaParticleFountain

public abstract class E3DParticleSystem
extends E3DPortalEnabledRenderable

Author:
Curt A particle system is a grouping of particles used for creating animated particle systems in a world/sector.

Constructor Summary
E3DParticleSystem(E3DEngine engine)
          Create a new unnamed particle system (can't be quickly accessed from a map once its added).
E3DParticleSystem(E3DEngine engine, double lifeSeconds)
          Create a named particle system.
E3DParticleSystem(E3DEngine engine, E3DVector3F gravityDirection, double gravityStrength)
          Create an unnamed particle system with gravity.
E3DParticleSystem(E3DEngine engine, E3DVector3F gravityDirection, double gravityStrength, double lifeSeconds)
          Create an named particle system with gravity.
E3DParticleSystem(E3DParticleSystem toCopy)
          Create a new particle system as a copy of the old
 
Method Summary
 void addParticle(E3DParticle particle)
          This will add a particle to the system.
 E3DSortedRenderableMap getBlendAndTextureSortedParticleMap()
          Get the list of particle's quads sorted by texture name.
 E3DVector3F getGravityDirection()
          Get the normalised direciton vector of gravity for this system
 double getGravityStrength()
          Get the strength of gravity for the system
 double getLifeSeconds()
           
 E3DOrientation getOrientation()
           
 java.util.ArrayList getParticleList()
          Get the list of all the particles in the system
 java.util.ArrayList getQuadList()
          Returns the list of all the quads of all the particles in it
 java.util.ArrayList getQuadList(java.util.ArrayList particleList)
           
 boolean isAlive()
          Returns false if the engine has expired its lifespan
abstract  boolean isCollideable()
          If any of the particles are needing to be collision detected, set this to true.
abstract  boolean isCollisionCausedByMovement()
          Set this to true if any particles in the system need to cause collisions when they move.
abstract  E3DParticleSystem onGetClone()
          This method must be overriden to return a clone of the particle system.
 void removeParticle(E3DParticle particle)
           
 void render()
          This will render this particle system individually.
 void rotate(double angle, E3DVector3F upVec)
          Rotate all particles, and movement directions(permanently) in the system around upVec by angle amount
 void setGravityDirection(E3DVector3F gravityDirection)
          Set the direction of the gravity vector for this system.
 void setGravityStrength(double gravityStrength)
          Set the strength of gravity for the system.
 void setLifeSeconds(double lifeSeconds)
           
 void setPosition(E3DVector3F position)
          Set the position of the particle system This is origin of the positions of all the particles are based around.
 void setRenderMode(int renderMode)
          If a particle systems renderMode is changed, so are all the particles contained in the particle system.
 void setSector(E3DSector sector)
          Override setSector to automatically set the sector the particles are in as well as the system.
 void translate(E3DVector3F translationAmt)
          Translate the particleSystem by translationVec amt.
 void updateParticles(E3DActor curActor)
          This updates the particles in the system (makes them all move 1 unit)
 
Methods inherited from class espresso3d.engine.world.sector.base.E3DPortalEnabledRenderable
checkSectorChangeDuringMovement, getSector
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getBlendMode, getKey, getRenderMode, initCorrectGeometryRenderer, isKeyChanged, setBlendMode, setKeyChanged
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

E3DParticleSystem

public E3DParticleSystem(E3DEngine engine)
Create a new unnamed particle system (can't be quickly accessed from a map once its added). Very useful for temporary systems)

Parameters:
engine -

E3DParticleSystem

public E3DParticleSystem(E3DEngine engine,
                         double lifeSeconds)
Create a named particle system. This is useful for quick access to the system from the sectors map or particle systems.

Parameters:
engine -

E3DParticleSystem

public E3DParticleSystem(E3DEngine engine,
                         E3DVector3F gravityDirection,
                         double gravityStrength)
Create an unnamed particle system with gravity.

Parameters:
engine -
gravityDirection - Normalised direction of gravity
gravityStrength - strenth of the gravity

E3DParticleSystem

public E3DParticleSystem(E3DEngine engine,
                         E3DVector3F gravityDirection,
                         double gravityStrength,
                         double lifeSeconds)
Create an named particle system with gravity.

Parameters:
engine -
gravityDirection - Normalised direction of gravity
gravityStrength - strenth of the gravity
lifeSeconds - number of seconds for the particle system to stay around. -1 for infinite

E3DParticleSystem

public E3DParticleSystem(E3DParticleSystem toCopy)
Create a new particle system as a copy of the old

Parameters:
toCopy -
Method Detail

addParticle

public void addParticle(E3DParticle particle)
This will add a particle to the system.

Parameters:
particle -

removeParticle

public void removeParticle(E3DParticle particle)

getParticleList

public java.util.ArrayList getParticleList()
Get the list of all the particles in the system

Returns:

updateParticles

public void updateParticles(E3DActor curActor)
This updates the particles in the system (makes them all move 1 unit)


isAlive

public boolean isAlive()
Returns false if the engine has expired its lifespan

Returns:

render

public void render()
This will render this particle system individually. However, it will be taken care of in a better fashion by the engine so shouldn't be called under normal circumstances

Specified by:
render in class E3DRenderable

getQuadList

public java.util.ArrayList getQuadList()
Returns the list of all the quads of all the particles in it

Returns:

getQuadList

public java.util.ArrayList getQuadList(java.util.ArrayList particleList)

setSector

public void setSector(E3DSector sector)
Override setSector to automatically set the sector the particles are in as well as the system. This is done automatically when adding it to a sector so normally should be modified.

Specified by:
setSector in interface E3DPortalEnabledItem
Overrides:
setSector in class E3DPortalEnabledRenderable
Parameters:
sector -

getBlendAndTextureSortedParticleMap

public E3DSortedRenderableMap getBlendAndTextureSortedParticleMap()
Get the list of particle's quads sorted by texture name. Each entry of the map is keyed off texture name and contains an ArrayList of quads for that texture as the value

Returns:

getGravityDirection

public E3DVector3F getGravityDirection()
Get the normalised direciton vector of gravity for this system

Returns:
Gravity direciton. Can be null.

setGravityDirection

public void setGravityDirection(E3DVector3F gravityDirection)
Set the direction of the gravity vector for this system. It is automatically noramlised.

Parameters:
gravityDirection -

getGravityStrength

public double getGravityStrength()
Get the strength of gravity for the system

Returns:

setGravityStrength

public void setGravityStrength(double gravityStrength)
Set the strength of gravity for the system. This value scales the gravityDirection vector

Parameters:
gravityStrength -

setPosition

public void setPosition(E3DVector3F position)
Set the position of the particle system This is origin of the positions of all the particles are based around. It begins at 0, 0, 0. Changing the position will translate particles currently in the system. It will NOT translate particles that are added after the translation. New particles will be assumed to know it is at its position when they're startPositions are set

Returns:

translate

public void translate(E3DVector3F translationAmt)
Translate the particleSystem by translationVec amt. Translating will translate particles currently in the system. It will NOT translate particles that are added after the translation. New particles will be assumed to know it is at its position when they're startPositions are set

Returns:

rotate

public void rotate(double angle,
                   E3DVector3F upVec)
Rotate all particles, and movement directions(permanently) in the system around upVec by angle amount

Parameters:
angle - Radian angle
upVec - Normalised up vector to use as the rotation axis

onGetClone

public abstract E3DParticleSystem onGetClone()
                                      throws java.lang.Exception
This method must be overriden to return a clone of the particle system. This normally gets called when a specific actor in the preloadedActorMap of the world is specified in a world's map that is getting loaded What it wants is a clone of the preloaded actor returned (CLONE, not ref to the same object!). This is exposed to you so you can modify the actor if necessary when cloning it.

Throws:
java.lang.Exception

getLifeSeconds

public double getLifeSeconds()

setLifeSeconds

public void setLifeSeconds(double lifeSeconds)

setRenderMode

public void setRenderMode(int renderMode)
If a particle systems renderMode is changed, so are all the particles contained in the particle system. To change a single particle, change that particles rendermode This will overwrite an individual particle's rendermode. It will not be able to revert back to its original renderMode automatically, you will be responsible for resetting any particle to a different render mode as you see fit.

Overrides:
setRenderMode in class E3DRenderable

isCollideable

public abstract boolean isCollideable()
If any of the particles are needing to be collision detected, set this to true. If set to false, its a shortcut to disable all collision detection for particles in the system This does not automatically make particles stop causing collisions with their own movement, it just keeps the particles from being run into by other object's movement.

Returns:

isCollisionCausedByMovement

public abstract boolean isCollisionCausedByMovement()
Set this to true if any particles in the system need to cause collisions when they move. If set to false, its a shortcut to disable all collisions caused by particles in the system. This does not automatically make particles uncollideable. It just keeps the particles from causing collisions with their own movement.

Returns:

getOrientation

public E3DOrientation getOrientation()