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 SummaryNested ClassesNested classes/interfaces inherited from class com.jme3.scene.SpatialSpatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
- 
Field SummaryFields inherited from class com.jme3.scene.GeometrycachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndexFields inherited from class com.jme3.scene.SpatialbatchHint, 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 SummaryConstructorsModifierConstructorDescriptionprotectedFor serialization only.ParticleEmitter(String name, ParticleMesh.Type type, int numParticles) 
- 
Method SummaryModifier 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.GeometryassociateWithGroupNode, 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.SpatialaddControl, 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
- 
ParticleEmitterprotected ParticleEmitter()For serialization only. Do not use.
 
- 
- 
Method Details- 
cloneDescription 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 interface- CloneableSmartAsset
- Overrides:
- clonein 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.
- See Also:
 
- 
cloneDescription 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 class- Geometry
- 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:
 
- 
oldCloneThe old clone() method that did not use the new Cloner utility.
- 
cloneFieldsCalled internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
- cloneFieldsin interface- JmeCloneable
- Overrides:
- cloneFieldsin class- Geometry
- 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
- 
setParticleInfluencerSet theParticleInfluencerto influence this particle emitter.- Parameters:
- particleInfluencer- the- ParticleInfluencerto influence this particle emitter.
- See Also:
 
- 
getParticleInfluencerReturns theParticleInfluencerthat influences this particle emitter.- Returns:
- the ParticleInfluencerthat influences this particle emitter.
- See Also:
 
- 
getMeshTypeReturns the mesh type used by the particle emitter.- Returns:
- the mesh type used by the particle emitter.
- See Also:
 
- 
setMeshTypeSets the type of mesh used by the particle emitter.- Parameters:
- meshType- The mesh type to use
 
- 
isInWorldSpacepublic boolean isInWorldSpace()Returns true if particles should spawn in world space.- Returns:
- true if particles should spawn in world space.
- See Also:
 
- 
setInWorldSpacepublic 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.
 
- 
getNumVisibleParticlespublic int getNumVisibleParticles()Returns the number of visible particles (spawned but not dead).- Returns:
- the number of visible particles
 
- 
setNumParticlespublic 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.
 
- 
getMaxNumParticlespublic int getMaxNumParticles()
- 
getParticlesReturns 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.
 
- 
getFaceNormalGet the normal which particles are facing.- Returns:
- the normal which particles are facing.
- See Also:
 
- 
setFaceNormalSets 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, or- nullif particles should face the camera.
 
- 
getRotateSpeedpublic float getRotateSpeed()Returns the rotation speed in radians/sec for particles.- Returns:
- the rotation speed in radians/sec for particles.
- See Also:
 
- 
setRotateSpeedpublic 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.
 
- 
isRandomAnglepublic 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:
 
- 
setRandomAnglepublic 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.
 
- 
isSelectRandomImagepublic 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:
 
- 
setSelectRandomImagepublic 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.
 
- 
isFacingVelocitypublic boolean isFacingVelocity()Check if particles spawned should face their velocity.- Returns:
- True if particles spawned should face their velocity.
- See Also:
 
- 
setFacingVelocitypublic 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.
 
- 
getEndColorGet the end color of the particles spawned.- Returns:
- the end color of the particles spawned.
- See Also:
 
- 
setEndColorSet 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.
 
- 
getEndSizepublic float getEndSize()Get the end size of the particles spawned.- Returns:
- the end size of the particles spawned.
- See Also:
 
- 
setEndSizepublic 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.
 
- 
getGravityGet the gravity vector.- Returns:
- the gravity vector.
- See Also:
 
- 
setGravityThis method sets the gravity vector.- Parameters:
- gravity- the gravity vector
 
- 
setGravitypublic 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
 
- 
getHighLifepublic float getHighLife()Get the high value of life.- Returns:
- the high value of life.
- See Also:
 
- 
setHighLifepublic 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.
 
- 
getImagesXpublic int getImagesX()Get the number of images along the X axis (width).- Returns:
- the number of images along the X axis (width).
- See Also:
 
- 
setImagesXpublic 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).
 
- 
getImagesYpublic int getImagesY()Get the number of images along the Y axis (height).- Returns:
- the number of images along the Y axis (height).
- See Also:
 
- 
setImagesYpublic 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).
 
- 
getLowLifepublic float getLowLife()Get the low value of life.- Returns:
- the low value of life.
- See Also:
 
- 
setLowLifepublic 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.
 
- 
getParticlesPerSecpublic float getParticlesPerSec()Get the number of particles to spawn per second.- Returns:
- the number of particles to spawn per second.
- See Also:
 
- 
setParticlesPerSecpublic void setParticlesPerSec(float particlesPerSec) Set the number of particles to spawn per second.- Parameters:
- particlesPerSec- the number of particles to spawn per second.
 
- 
getStartColorGet the start color of the particles spawned.- Returns:
- the start color of the particles spawned.
- See Also:
 
- 
setStartColorSet 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
 
- 
getStartSizepublic float getStartSize()Get the start color of the particles spawned.- Returns:
- the start color of the particles spawned.
- See Also:
 
- 
setStartSizepublic 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.
 
- 
getInitialVelocityDeprecated.Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead.- Returns:
- the pre-existing velocity vector
 
- 
setInitialVelocityDeprecated.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). The particle will move with this velocity unless it is affected by gravity.
- See Also:
 
- 
getVelocityVariationDeprecated.This method is deprecated. Use ParticleEmitter.getParticleInfluencer().getVelocityVariation(); instead.- Returns:
- the initial velocity variation factor
 
- 
setVelocityVariationDeprecated.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 in- ParticleInfluencer.setInitialVelocity(com.jme3.math.Vector3f), and 1 means particles are to spawn with a completely random velocity.
 
- 
emitAllParticlespublic void emitAllParticles()Instantly emits all the particles possible to be emitted. Any particles which are currently inactive will be spawned immediately.
- 
emitParticlespublic void emitParticles(int num) Instantly emits available particles, up to num.- Parameters:
- num- the maximum number of particles to emit
 
- 
killAllParticlespublic void killAllParticles()Instantly kills all active particles, after this method is called, all particles will be dead and no longer visible.
- 
killParticlepublic void killParticle(int index) Kills the particle at the given index.- Parameters:
- index- The index of the particle to kill
- See Also:
 
- 
updateParticle
- 
setEnabledpublic 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
 
- 
isEnabledpublic boolean isEnabled()Check if a particle emitter is enabled for update.- Returns:
- True if a particle emitter is enabled for update.
- See Also:
 
- 
updateFromControlpublic void updateFromControl(float tpf) Callback from Control.update(), do not use.- Parameters:
- tpf- time per frame (in seconds)
 
- 
preload
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- Geometry
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- Geometry
- Throws:
- IOException
 
 
-