com.jme3.effect
Class ParticleEmitter

java.lang.Object
  extended by com.jme3.scene.Spatial
      extended by com.jme3.scene.Geometry
          extended by com.jme3.effect.ParticleEmitter
All Implemented Interfaces:
CloneableSmartAsset, Collidable, Savable, java.lang.Cloneable

public class ParticleEmitter
extends Geometry

ParticleEmitter is a special kind of geometry which simulates a particle system.

Particle emitters can be used to simulate various kinds of phenomena, such as fire, smoke, explosions and much more.

Particle emitters have many properties which are used to control the simulation. The interpretation of these properties depends on the ParticleInfluencer that has been assigned to the emitter via setParticleInfluencer(com.jme3.effect.influencers.ParticleInfluencer). By default the implementation DefaultParticleInfluencer is used.


Nested Class Summary
static class ParticleEmitter.ParticleEmitterControl
           
 
Nested classes/interfaces inherited from class com.jme3.scene.Spatial
Spatial.BatchHint, Spatial.CullHint
 
Field Summary
 
Fields inherited from class com.jme3.scene.Geometry
batchNode, cachedOffsetMat, cachedWorldMat, ignoreTransform, lodLevel, material, mesh, prevBatchTransforms, SAVABLE_VERSION, startIndex
 
Fields inherited from class com.jme3.scene.Spatial
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_LIGHTLIST, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldTransform
 
Constructor Summary
ParticleEmitter()
          For serialization only.
ParticleEmitter(java.lang.String name, ParticleMesh.Type type, int numParticles)
           
 
Method Summary
 ParticleEmitter clone()
          This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.
 ParticleEmitter clone(boolean cloneMaterial)
          This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.
 void emitAllParticles()
          Instantly emits all the particles possible to be emitted.
 ColorRGBA getEndColor()
          Get the end color of the particles spawned.
 float getEndSize()
          Get the end size of the particles spawned.
 Vector3f getFaceNormal()
          Get the normal which particles are facing.
 Vector3f getGravity()
          Get the gravity vector.
 float getHighLife()
          Get the high value of life.
 int getImagesX()
          Get the number of images along the X axis (width).
 int getImagesY()
          Get the number of images along the Y axis (height).
 Vector3f getInitialVelocity()
          Deprecated. Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead.
 float getLowLife()
          Get the low value of life.
 int getMaxNumParticles()
           
 ParticleMesh.Type getMeshType()
          Returns the mesh type used by the particle emitter.
 int getNumVisibleParticles()
          Returns the number of visible particles (spawned but not dead).
 ParticleInfluencer getParticleInfluencer()
          Returns the ParticleInfluencer that influences this particle emitter.
 Particle[] getParticles()
          Returns a list of all particles (shouldn't be used in most cases).
 float getParticlesPerSec()
          Get the number of particles to spawn per second.
 float getRotateSpeed()
          Returns the rotation speed in radians/sec for particles.
 EmitterShape getShape()
           
 ColorRGBA getStartColor()
          Get the start color of the particles spawned.
 float getStartSize()
          Get the start color of the particles spawned.
 float getVelocityVariation()
          Deprecated. This method is deprecated. Use ParticleEmitter.getParticleInfluencer().getVelocityVariation(); instead.
 boolean isEnabled()
          Check if a particle emitter is enabled for update.
 boolean isFacingVelocity()
          Check if particles spawned should face their velocity.
 boolean isInWorldSpace()
          Returns true if particles should spawn in world space.
 boolean isRandomAngle()
          Returns true if every particle spawned should have a random facing angle.
 boolean isSelectRandomImage()
          Returns true if every particle spawned should get a random image.
 void killAllParticles()
          Instantly kills all active particles, after this method is called, all particles will be dead and no longer visible.
 void killParticle(int index)
          Kills the particle at the given index.
 void preload(RenderManager rm, ViewPort vp)
           
 void read(JmeImporter im)
           
 void setEnabled(boolean enabled)
          Set to enable or disable the particle emitter
 void setEndColor(ColorRGBA endColor)
          Set the end color of the particles spawned.
 void setEndSize(float endSize)
          Set the end size of the particles spawned.
 void setFaceNormal(Vector3f faceNormal)
          Sets the normal which particles are facing.
 void setFacingVelocity(boolean followVelocity)
          Set to true if particles spawned should face their velocity (or direction to which they are moving towards).
 void setGravity(float x, float y, float z)
          Sets the gravity vector.
 void setGravity(Vector3f gravity)
          This method sets the gravity vector.
 void setHighLife(float highLife)
          Set the high value of life.
 void setImagesX(int imagesX)
          Set the number of images along the X axis (width).
 void setImagesY(int imagesY)
          Set the number of images along the Y axis (height).
 void setInitialVelocity(Vector3f initialVelocity)
          Deprecated. This method is deprecated. Use ParticleEmitter.getParticleInfluencer().setInitialVelocity(initialVelocity); instead.
 void setInWorldSpace(boolean worldSpace)
          Set to true if particles should spawn in world space.
 void setLowLife(float lowLife)
          Set the low value of life.
 void setMeshType(ParticleMesh.Type meshType)
          Sets the type of mesh used by the particle emitter.
 void setNumParticles(int numParticles)
          Set the maximum amount of particles that can exist at the same time with this emitter.
 void setParticleInfluencer(ParticleInfluencer particleInfluencer)
          Set the ParticleInfluencer to influence this particle emitter.
 void setParticlesPerSec(float particlesPerSec)
          Set the number of particles to spawn per second.
 void setRandomAngle(boolean randomAngle)
          Set to true if every particle spawned should have a random facing angle.
 void setRotateSpeed(float rotateSpeed)
          Set the rotation speed in radians/sec for particles spawned after the invocation of this method.
 void setSelectRandomImage(boolean selectRandomImage)
          Set to true if every particle spawned should get a random image from a pool of images constructed from the texture, with X by Y possible images.
 void setShape(EmitterShape shape)
           
 void setStartColor(ColorRGBA startColor)
          Set the start color of the particles spawned.
 void setStartSize(float startSize)
          Set the start size of the particles spawned.
 void setVelocityVariation(float variation)
          Deprecated. This method is deprecated. Use ParticleEmitter.getParticleInfluencer().setVelocityVariation(variation); instead.
 void updateFromControl(float tpf)
          Callback from Control.update(), do not use.
 void write(JmeExporter ex)
           
 
Methods inherited from class com.jme3.scene.Geometry
batch, breadthFirstTraversal, collideWith, computeOffsetTransform, computeWorldMatrix, deepClone, depthFirstTraversal, getLodLevel, getMaterial, getMesh, getModelBound, getTriangleCount, getVertexCount, getWorldMatrix, isBatched, isIgnoreTransform, removeFromParent, setIgnoreTransform, setLodLevel, setMaterial, setMesh, setModelBound, setParent, unBatch, updateModelBound, updateWorldBound, updateWorldTransforms
 
Methods inherited from class com.jme3.scene.Spatial
addControl, addLight, breadthFirstTraversal, center, checkCulling, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, localToWorld, lookAt, matches, move, move, removeControl, removeControl, removeLight, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLightListRefresh, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setName, setQueueBucket, setShadowMode, setTransformRefresh, setUserData, toString, updateGeometricState, updateLogicalState, updateWorldLightList, worldToLocal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParticleEmitter

public ParticleEmitter(java.lang.String name,
                       ParticleMesh.Type type,
                       int numParticles)

ParticleEmitter

public ParticleEmitter()
For serialization only. Do not use.

Method Detail

clone

public ParticleEmitter clone()
Description copied from class: Geometry
This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry. Exception: if the mesh is marked as being a software animated mesh, (bind pose is set) then the positions and normals are deep copied.

Specified by:
clone in interface CloneableSmartAsset
Overrides:
clone in class Geometry
Returns:
A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated. All controls will be cloned using the Control.cloneForSpatial method on the clone.
See Also:
Mesh.cloneForAnim()

clone

public ParticleEmitter clone(boolean cloneMaterial)
Description copied from class: Geometry
This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry. Exception: if the mesh is marked as being a software animated mesh, (bind pose is set) then the positions and normals are deep copied.

Overrides:
clone in class Geometry
Returns:
A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated. All controls will be cloned using the Control.cloneForSpatial method on the clone.
See Also:
Mesh.cloneForAnim()

setShape

public void setShape(EmitterShape shape)

getShape

public EmitterShape getShape()

setParticleInfluencer

public void setParticleInfluencer(ParticleInfluencer particleInfluencer)
Set the ParticleInfluencer to influence this particle emitter.

Parameters:
particleInfluencer - the ParticleInfluencer to influence this particle emitter.
See Also:
ParticleInfluencer

getParticleInfluencer

public ParticleInfluencer getParticleInfluencer()
Returns the ParticleInfluencer that influences this particle emitter.

Returns:
the ParticleInfluencer that influences this particle emitter.
See Also:
ParticleInfluencer

getMeshType

public ParticleMesh.Type getMeshType()
Returns the mesh type used by the particle emitter.

Returns:
the mesh type used by the particle emitter.
See Also:
setMeshType(com.jme3.effect.ParticleMesh.Type), ParticleEmitter(java.lang.String, com.jme3.effect.ParticleMesh.Type, int)

setMeshType

public void setMeshType(ParticleMesh.Type meshType)
Sets the type of mesh used by the particle emitter.

Parameters:
meshType - The mesh type to use

isInWorldSpace

public boolean isInWorldSpace()
Returns true if particles should spawn in world space.

Returns:
true if particles should spawn in world space.
See Also:
setInWorldSpace(boolean)

setInWorldSpace

public void setInWorldSpace(boolean worldSpace)
Set to true if particles should spawn in world space.

If set to true and the particle emitter is moved in the scene, then particles that have already spawned won't be effected by this motion. If set to false, the particles will emit in local space and when the emitter is moved, so are all the particles that were emitted previously.

Parameters:
worldSpace - true if particles should spawn in world space.

getNumVisibleParticles

public int getNumVisibleParticles()
Returns the number of visible particles (spawned but not dead).

Returns:
the number of visible particles

setNumParticles

public final void setNumParticles(int numParticles)
Set the maximum amount of particles that can exist at the same time with this emitter. Calling this method many times is not recommended.

Parameters:
numParticles - the maximum amount of particles that can exist at the same time with this emitter.

getMaxNumParticles

public int getMaxNumParticles()

getParticles

public Particle[] getParticles()
Returns a list of all particles (shouldn't be used in most cases).

This includes both existing and non-existing particles. The size of the array is set to the numParticles value specified in the constructor or setNumParticles(int) method.

Returns:
a list of all particles.

getFaceNormal

public Vector3f getFaceNormal()
Get the normal which particles are facing.

Returns:
the normal which particles are facing.
See Also:
setFaceNormal(com.jme3.math.Vector3f)

setFaceNormal

public void setFaceNormal(Vector3f faceNormal)
Sets the normal which particles are facing.

By default, particles will face the camera, but for some effects (e.g shockwave) it may be necessary to face a specific direction instead. To restore normal functionality, provide null as the argument for faceNormal.

Parameters:
faceNormal - The normals particles should face, or null if particles should face the camera.

getRotateSpeed

public float getRotateSpeed()
Returns the rotation speed in radians/sec for particles.

Returns:
the rotation speed in radians/sec for particles.
See Also:
setRotateSpeed(float)

setRotateSpeed

public void setRotateSpeed(float rotateSpeed)
Set the rotation speed in radians/sec for particles spawned after the invocation of this method.

Parameters:
rotateSpeed - the rotation speed in radians/sec for particles spawned after the invocation of this method.

isRandomAngle

public boolean isRandomAngle()
Returns true if every particle spawned should have a random facing angle.

Returns:
true if every particle spawned should have a random facing angle.
See Also:
setRandomAngle(boolean)

setRandomAngle

public void setRandomAngle(boolean randomAngle)
Set to true if every particle spawned should have a random facing angle.

Parameters:
randomAngle - if every particle spawned should have a random facing angle.

isSelectRandomImage

public boolean isSelectRandomImage()
Returns true if every particle spawned should get a random image.

Returns:
True if every particle spawned should get a random image.
See Also:
setSelectRandomImage(boolean)

setSelectRandomImage

public void setSelectRandomImage(boolean selectRandomImage)
Set to true if every particle spawned should get a random image from a pool of images constructed from the texture, with X by Y possible images.

By default, X and Y are equal to 1, thus allowing only 1 possible image to be selected, but if the particle is configured with multiple images by using setImagesX(int) and {#link ParticleEmitter#setImagesY(int) } methods, then multiple images can be selected. Setting to false will cause each particle to have an animation of images displayed, starting at image 1, and going until image X*Y when the particle reaches its end of life.

Parameters:
selectRandomImage - True if every particle spawned should get a random image.

isFacingVelocity

public boolean isFacingVelocity()
Check if particles spawned should face their velocity.

Returns:
True if particles spawned should face their velocity.
See Also:
setFacingVelocity(boolean)

setFacingVelocity

public void setFacingVelocity(boolean followVelocity)
Set to true if particles spawned should face their velocity (or direction to which they are moving towards).

This is typically used for e.g spark effects.

Parameters:
followVelocity - True if particles spawned should face their velocity.

getEndColor

public ColorRGBA getEndColor()
Get the end color of the particles spawned.

Returns:
the end color of the particles spawned.
See Also:
setEndColor(com.jme3.math.ColorRGBA)

setEndColor

public void setEndColor(ColorRGBA endColor)
Set the end color of the particles spawned.

The particle color at any time is determined by blending the start color and end color based on the particle's current time of life relative to its end of life.

Parameters:
endColor - the end color of the particles spawned.

getEndSize

public float getEndSize()
Get the end size of the particles spawned.

Returns:
the end size of the particles spawned.
See Also:
setEndSize(float)

setEndSize

public void setEndSize(float endSize)
Set the end size of the particles spawned.

The particle size at any time is determined by blending the start size and end size based on the particle's current time of life relative to its end of life.

Parameters:
endSize - the end size of the particles spawned.

getGravity

public Vector3f getGravity()
Get the gravity vector.

Returns:
the gravity vector.
See Also:
setGravity(com.jme3.math.Vector3f)

setGravity

public void setGravity(Vector3f gravity)
This method sets the gravity vector.

Parameters:
gravity - the gravity vector

setGravity

public void setGravity(float x,
                       float y,
                       float z)
Sets the gravity vector.

Parameters:
x - the x component of the gravity vector
y - the y component of the gravity vector
z - the z component of the gravity vector

getHighLife

public float getHighLife()
Get the high value of life.

Returns:
the high value of life.
See Also:
setHighLife(float)

setHighLife

public void setHighLife(float highLife)
Set the high value of life.

The particle's lifetime/expiration is determined by randomly selecting a time between low life and high life.

Parameters:
highLife - the high value of life.

getImagesX

public int getImagesX()
Get the number of images along the X axis (width).

Returns:
the number of images along the X axis (width).
See Also:
setImagesX(int)

setImagesX

public void setImagesX(int imagesX)
Set the number of images along the X axis (width).

To determine how multiple particle images are selected and used, see the setSelectRandomImage(boolean) method.

Parameters:
imagesX - the number of images along the X axis (width).

getImagesY

public int getImagesY()
Get the number of images along the Y axis (height).

Returns:
the number of images along the Y axis (height).
See Also:
setImagesY(int)

setImagesY

public void setImagesY(int imagesY)
Set the number of images along the Y axis (height).

To determine how multiple particle images are selected and used, see the setSelectRandomImage(boolean) method.

Parameters:
imagesY - the number of images along the Y axis (height).

getLowLife

public float getLowLife()
Get the low value of life.

Returns:
the low value of life.
See Also:
setLowLife(float)

setLowLife

public void setLowLife(float lowLife)
Set the low value of life.

The particle's lifetime/expiration is determined by randomly selecting a time between low life and high life.

Parameters:
lowLife - the low value of life.

getParticlesPerSec

public float getParticlesPerSec()
Get the number of particles to spawn per second.

Returns:
the number of particles to spawn per second.
See Also:
setParticlesPerSec(float)

setParticlesPerSec

public void setParticlesPerSec(float particlesPerSec)
Set the number of particles to spawn per second.

Parameters:
particlesPerSec - the number of particles to spawn per second.

getStartColor

public ColorRGBA getStartColor()
Get the start color of the particles spawned.

Returns:
the start color of the particles spawned.
See Also:
setStartColor(com.jme3.math.ColorRGBA)

setStartColor

public void setStartColor(ColorRGBA startColor)
Set the start color of the particles spawned.

The particle color at any time is determined by blending the start color and end color based on the particle's current time of life relative to its end of life.

Parameters:
startColor - the start color of the particles spawned

getStartSize

public float getStartSize()
Get the start color of the particles spawned.

Returns:
the start color of the particles spawned.
See Also:
setStartSize(float)

setStartSize

public void setStartSize(float startSize)
Set the start size of the particles spawned.

The particle size at any time is determined by blending the start size and end size based on the particle's current time of life relative to its end of life.

Parameters:
startSize - the start size of the particles spawned.

getInitialVelocity

@Deprecated
public Vector3f getInitialVelocity()
Deprecated. Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead.


setInitialVelocity

@Deprecated
public void setInitialVelocity(Vector3f initialVelocity)
Deprecated. This method is deprecated. Use ParticleEmitter.getParticleInfluencer().setInitialVelocity(initialVelocity); instead.

Parameters:
initialVelocity - Set the initial velocity a particle is spawned with, the initial velocity given in the parameter will be varied according to the velocity variation set in setVelocityVariation(float). A particle will move toward its velocity unless it is effected by the gravity.
See Also:
setVelocityVariation(float), ParticleEmitter#setGravity(float)

getVelocityVariation

@Deprecated
public float getVelocityVariation()
Deprecated. This method is deprecated. Use ParticleEmitter.getParticleInfluencer().getVelocityVariation(); instead.

Returns:
the initial velocity variation factor

setVelocityVariation

@Deprecated
public void setVelocityVariation(float variation)
Deprecated. This method is deprecated. Use ParticleEmitter.getParticleInfluencer().setVelocityVariation(variation); instead.

Parameters:
variation - Set the variation by which the initial velocity of the particle is determined. variation should be a value from 0 to 1, where 0 means particles are to spawn with exactly the velocity given in ParticleEmitter#setStartVel(com.jme3.math.Vector3f) , and 1 means particles are to spawn with a completely random velocity.

emitAllParticles

public void emitAllParticles()
Instantly emits all the particles possible to be emitted. Any particles which are currently inactive will be spawned immediately.


killAllParticles

public void killAllParticles()
Instantly kills all active particles, after this method is called, all particles will be dead and no longer visible.


killParticle

public void killParticle(int index)
Kills the particle at the given index.

Parameters:
index - The index of the particle to kill
See Also:
getParticles()

setEnabled

public void setEnabled(boolean enabled)
Set to enable or disable the particle emitter

When a particle is disabled, it will be "frozen in time" and not update.

Parameters:
enabled - True to enable the particle emitter

isEnabled

public boolean isEnabled()
Check if a particle emitter is enabled for update.

Returns:
True if a particle emitter is enabled for update.
See Also:
setEnabled(boolean)

updateFromControl

public void updateFromControl(float tpf)
Callback from Control.update(), do not use.

Parameters:
tpf -

preload

public void preload(RenderManager rm,
                    ViewPort vp)

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class Geometry
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class Geometry
Throws:
java.io.IOException