Class ParticleEmitter
- All Implemented Interfaces:
HasLocalTransform,CloneableSmartAsset,Collidable,Savable,JmeCloneable,Cloneable
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 DefaultParticleInfluencer implementation is used.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.jme3.scene.Spatial
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode -
Field Summary
Fields inherited from class com.jme3.scene.Geometry
cachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndexFields inherited from class com.jme3.scene.Spatial
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localOverrides, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_CHILD_LIGHTLIST, RF_LIGHTLIST, RF_MATPARAM_OVERRIDE, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldOverrides, worldTransform -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFor serialization only.ParticleEmitter(String name, ParticleMesh.Type type, int numParticles) -
Method Summary
Modifier and TypeMethodDescriptionclone()This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.clone(boolean cloneMaterial) This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.voidcloneFields(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.voidInstantly emits all the particles possible to be emitted.voidemitParticles(int num) Instantly emits available particles, up to num.Get the end color of the particles spawned.floatGet the end size of the particles spawned.Get the normal which particles are facing.Get the gravity vector.floatGet the high value of life.intGet the number of images along the X axis (width).intGet the number of images along the Y axis (height).Deprecated.Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead.floatGet the low value of life.intReturns the mesh type used by the particle emitter.intReturns the number of visible particles (spawned but not dead).Returns theParticleInfluencerthat influences this particle emitter.Particle[]Returns a list of all particles (shouldn't be used in most cases).floatGet the number of particles to spawn per second.floatReturns the rotation speed in radians/sec for particles.getShape()Get the start color of the particles spawned.floatGet the start color of the particles spawned.floatDeprecated.This method is deprecated.booleanCheck if a particle emitter is enabled for update.booleanCheck if particles spawned should face their velocity.booleanReturns true if particles should spawn in world space.booleanReturns true if every particle spawned should have a random facing angle.booleanReturns true if every particle spawned should get a random image.voidInstantly kills all active particles, after this method is called, all particles will be dead and no longer visible.voidkillParticle(int index) Kills the particle at the given index.oldClone(boolean cloneMaterial) The old clone() method that did not use the new Cloner utility.voidpreload(RenderManager rm, ViewPort vp) voidread(JmeImporter im) voidsetEnabled(boolean enabled) Set to enable or disable the particle emittervoidsetEndColor(ColorRGBA endColor) Set the end color of the particles spawned.voidsetEndSize(float endSize) Set the end size of the particles spawned.voidsetFaceNormal(Vector3f faceNormal) Sets the normal which particles are facing.voidsetFacingVelocity(boolean followVelocity) Set to true if particles spawned should face their velocity (or direction to which they are moving towards).voidsetGravity(float x, float y, float z) Sets the gravity vector.voidsetGravity(Vector3f gravity) This method sets the gravity vector.voidsetHighLife(float highLife) Set the high value of life.voidsetImagesX(int imagesX) Set the number of images along the X axis (width).voidsetImagesY(int imagesY) Set the number of images along the Y axis (height).voidsetInitialVelocity(Vector3f initialVelocity) Deprecated.This method is deprecated.voidsetInWorldSpace(boolean worldSpace) Set to true if particles should spawn in world space.voidsetLowLife(float lowLife) Set the low value of life.voidsetMeshType(ParticleMesh.Type meshType) Sets the type of mesh used by the particle emitter.final voidsetNumParticles(int numParticles) Set the maximum amount of particles that can exist at the same time with this emitter.voidsetParticleInfluencer(ParticleInfluencer particleInfluencer) Set theParticleInfluencerto influence this particle emitter.voidsetParticlesPerSec(float particlesPerSec) Set the number of particles to spawn per second.voidsetRandomAngle(boolean randomAngle) Set to true if every particle spawned should have a random facing angle.voidsetRotateSpeed(float rotateSpeed) Set the rotation speed in radians/sec for particles spawned after the invocation of this method.voidsetSelectRandomImage(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.voidsetShape(EmitterShape shape) voidsetStartColor(ColorRGBA startColor) Set the start color of the particles spawned.voidsetStartSize(float startSize) Set the start size of the particles spawned.voidsetVelocityVariation(float variation) Deprecated.This method is deprecated.voidupdateFromControl(float tpf) Callback from Control.update(), do not use.protected voidupdateParticle(Particle p, float tpf, Vector3f min, Vector3f max) voidwrite(JmeExporter ex) Methods inherited from class com.jme3.scene.Geometry
associateWithGroupNode, breadthFirstTraversal, checkCulling, collideWith, computeWorldMatrix, deepClone, depthFirstTraversal, getFallbackMorphTarget, getLodLevel, getMaterial, getMesh, getModelBound, getMorphState, getMorphState, getNbSimultaneousGPUMorph, getTriangleCount, getVertexCount, getWorldMatrix, isBatched, isDirtyMorph, isGrouped, isIgnoreTransform, oldDeepClone, removeFromParent, setDirtyMorph, setFallbackMorphTarget, setIgnoreTransform, setLodLevel, setMaterial, setMesh, setModelBound, setMorphState, setMorphState, setNbSimultaneousGPUMorph, setParent, unassociateFromGroupNode, updateModelBound, updateWorldBound, updateWorldLightList, updateWorldTransformsMethods inherited from class com.jme3.scene.Spatial
addControl, addControlAt, addLight, addMatParamOverride, breadthFirstTraversal, center, clearMatParamOverrides, depthFirstTraversal, forceRefresh, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalMatParamOverrides, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldMatParamOverrides, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, jmeClone, localToWorld, lookAt, matches, move, move, removeControl, removeControl, removeLight, removeMatParamOverride, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLightListRefresh, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setMatParamOverrideRefresh, setName, setQueueBucket, setRequiresUpdates, setShadowMode, setTransformRefresh, setUserData, toString, updateGeometricState, updateLogicalState, updateMatParamOverrides, worldToLocal
-
Constructor Details
-
ParticleEmitter
-
ParticleEmitter
protected ParticleEmitter()For serialization only. Do not use.
-
-
Method Details
-
clone
Description copied from class:GeometryThis 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:
clonein interfaceCloneableSmartAsset- Overrides:
clonein classGeometry- 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.
- See Also:
-
clone
Description copied from class:GeometryThis 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:
clonein classGeometry- Parameters:
cloneMaterial- true to clone materials, false to share them- 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.
- See Also:
-
oldClone
The old clone() method that did not use the new Cloner utility. -
cloneFields
Called internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
cloneFieldsin interfaceJmeCloneable- Overrides:
cloneFieldsin classGeometry- Parameters:
cloner- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.original- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
-
setShape
-
getShape
-
setParticleInfluencer
Set theParticleInfluencerto influence this particle emitter.- Parameters:
particleInfluencer- theParticleInfluencerto influence this particle emitter.- See Also:
-
getParticleInfluencer
Returns theParticleInfluencerthat influences this particle emitter.- Returns:
- the
ParticleInfluencerthat influences this particle emitter. - See Also:
-
getMeshType
Returns the mesh type used by the particle emitter.- Returns:
- the mesh type used by the particle emitter.
- See Also:
-
setMeshType
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
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 affected 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
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
numParticlesvalue specified in the constructor orsetNumParticles(int)method.- Returns:
- a list of all particles.
-
getFaceNormal
Get the normal which particles are facing.- Returns:
- the normal which particles are facing.
- See Also:
-
setFaceNormal
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
nullas the argument forfaceNormal.- Parameters:
faceNormal- The normals particles should face, ornullif 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
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
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
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
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
Get the end color of the particles spawned.- Returns:
- the end color of the particles spawned.
- See Also:
-
setEndColor
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
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
Get the gravity vector.- Returns:
- the gravity vector.
- See Also:
-
setGravity
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 vectory- the y component of the gravity vectorz- 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
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
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
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
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
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
Get the start color of the particles spawned.- Returns:
- the start color of the particles spawned.
- See Also:
-
setStartColor
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
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.Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead.- Returns:
- the pre-existing velocity vector
-
setInitialVelocity
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 insetVelocityVariation(float). The particle will move with this velocity unless it is affected by gravity.- See Also:
-
getVelocityVariation
Deprecated.This method is deprecated. Use ParticleEmitter.getParticleInfluencer().getVelocityVariation(); instead.- Returns:
- the initial velocity variation factor
-
setVelocityVariation
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.variationshould be a value from 0 to 1, where 0 means particles are to spawn with exactly the velocity specified inParticleInfluencer.setInitialVelocity(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. -
emitParticles
public void emitParticles(int num) Instantly emits available particles, up to num.- Parameters:
num- the maximum number of particles to emit
-
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:
-
updateParticle
-
setEnabled
public void setEnabled(boolean enabled) Set to enable or disable the particle emitterWhen 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:
-
updateFromControl
public void updateFromControl(float tpf) Callback from Control.update(), do not use.- Parameters:
tpf- time per frame (in seconds)
-
preload
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classGeometry- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classGeometry- Throws:
IOException
-