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 DefaultParticleInfluencer
implementation is used.
Modifier and Type | Class and Description |
---|---|
static class |
ParticleEmitter.ParticleEmitterControl |
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
cachedWorldMat, groupNode, ignoreTransform, lodLevel, material, mesh, SAVABLE_VERSION, startIndex
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
Modifier | Constructor and Description |
---|---|
protected |
ParticleEmitter()
For serialization only.
|
|
ParticleEmitter(java.lang.String name,
ParticleMesh.Type type,
int numParticles) |
Modifier and Type | Method and Description |
---|---|
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 |
cloneFields(Cloner cloner,
java.lang.Object original)
Called internally by com.jme3.util.clone.Cloner.
|
void |
emitAllParticles()
Instantly emits all the particles possible to be emitted.
|
void |
emitParticles(int num)
Instantly emits available particles, up to num.
|
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.
|
ParticleEmitter |
oldClone(boolean cloneMaterial)
The old clone() method that did not use the new Cloner utility.
|
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.
|
protected void |
updateParticle(Particle p,
float tpf,
Vector3f min,
Vector3f max) |
void |
write(JmeExporter ex) |
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, updateWorldTransforms
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
public ParticleEmitter(java.lang.String name, ParticleMesh.Type type, int numParticles)
protected ParticleEmitter()
public ParticleEmitter clone()
Geometry
clone
in interface CloneableSmartAsset
clone
in class Geometry
Mesh.cloneForAnim()
public ParticleEmitter clone(boolean cloneMaterial)
Geometry
clone
in class Geometry
cloneMaterial
- true to clone materials, false to share themMesh.cloneForAnim()
public ParticleEmitter oldClone(boolean cloneMaterial)
public void cloneFields(Cloner cloner, java.lang.Object original)
cloneFields
in interface JmeCloneable
cloneFields
in class Geometry
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.public void setShape(EmitterShape shape)
public EmitterShape getShape()
public void setParticleInfluencer(ParticleInfluencer particleInfluencer)
ParticleInfluencer
to influence this particle emitter.particleInfluencer
- the ParticleInfluencer
to influence
this particle emitter.ParticleInfluencer
public ParticleInfluencer getParticleInfluencer()
ParticleInfluencer
that influences this
particle emitter.ParticleInfluencer
that influences this
particle emitter.ParticleInfluencer
public ParticleMesh.Type getMeshType()
setMeshType(com.jme3.effect.ParticleMesh.Type)
,
ParticleEmitter(java.lang.String, com.jme3.effect.ParticleMesh.Type, int)
public void setMeshType(ParticleMesh.Type meshType)
meshType
- The mesh type to usepublic boolean isInWorldSpace()
setInWorldSpace(boolean)
public void setInWorldSpace(boolean worldSpace)
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.
worldSpace
- true if particles should spawn in world space.public int getNumVisibleParticles()
public final void setNumParticles(int numParticles)
numParticles
- the maximum amount of particles that
can exist at the same time with this emitter.public int getMaxNumParticles()
public Particle[] getParticles()
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.
public Vector3f getFaceNormal()
setFaceNormal(com.jme3.math.Vector3f)
public void setFaceNormal(Vector3f faceNormal)
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
.
faceNormal
- The normals particles should face, or null
if particles should face the camera.public float getRotateSpeed()
setRotateSpeed(float)
public void setRotateSpeed(float rotateSpeed)
rotateSpeed
- the rotation speed in radians/sec for particles
spawned after the invocation of this method.public boolean isRandomAngle()
setRandomAngle(boolean)
public void setRandomAngle(boolean randomAngle)
randomAngle
- if every particle spawned
should have a random facing angle.public boolean isSelectRandomImage()
setSelectRandomImage(boolean)
public void setSelectRandomImage(boolean selectRandomImage)
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.
selectRandomImage
- True if every particle spawned should get a random
image.public boolean isFacingVelocity()
setFacingVelocity(boolean)
public void setFacingVelocity(boolean followVelocity)
This is typically used for e.g. spark effects.
followVelocity
- True if particles spawned should face their velocity.public ColorRGBA getEndColor()
setEndColor(com.jme3.math.ColorRGBA)
public void setEndColor(ColorRGBA endColor)
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.
endColor
- the end color of the particles spawned.public float getEndSize()
setEndSize(float)
public void setEndSize(float endSize)
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.
endSize
- the end size of the particles spawned.public Vector3f getGravity()
setGravity(com.jme3.math.Vector3f)
public void setGravity(Vector3f gravity)
gravity
- the gravity vectorpublic void setGravity(float x, float y, float z)
x
- the x component of the gravity vectory
- the y component of the gravity vectorz
- the z component of the gravity vectorpublic float getHighLife()
setHighLife(float)
public void setHighLife(float highLife)
The particle's lifetime/expiration is determined by randomly selecting a time between low life and high life.
highLife
- the high value of life.public int getImagesX()
setImagesX(int)
public void setImagesX(int imagesX)
To determine
how multiple particle images are selected and used, see the
setSelectRandomImage(boolean)
method.
imagesX
- the number of images along the X axis (width).public int getImagesY()
setImagesY(int)
public void setImagesY(int imagesY)
To determine how multiple particle images are selected and used, see the
setSelectRandomImage(boolean)
method.
imagesY
- the number of images along the Y axis (height).public float getLowLife()
setLowLife(float)
public void setLowLife(float lowLife)
The particle's lifetime/expiration is determined by randomly selecting a time between low life and high life.
lowLife
- the low value of life.public float getParticlesPerSec()
setParticlesPerSec(float)
public void setParticlesPerSec(float particlesPerSec)
particlesPerSec
- the number of particles to spawn per
second.public ColorRGBA getStartColor()
setStartColor(com.jme3.math.ColorRGBA)
public void setStartColor(ColorRGBA startColor)
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.
startColor
- the start color of the particles spawnedpublic float getStartSize()
setStartSize(float)
public void setStartSize(float startSize)
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.
startSize
- the start size of the particles spawned.@Deprecated public Vector3f getInitialVelocity()
@Deprecated public void setInitialVelocity(Vector3f initialVelocity)
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.setVelocityVariation(float)
,
setGravity(com.jme3.math.Vector3f)
@Deprecated public float getVelocityVariation()
@Deprecated public void setVelocityVariation(float variation)
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 specified in
ParticleInfluencer.setInitialVelocity(com.jme3.math.Vector3f)
,
and 1 means particles are to spawn with a completely random velocity.public void emitAllParticles()
public void emitParticles(int num)
num
- the maximum number of particles to emitpublic void killAllParticles()
public void killParticle(int index)
index
- The index of the particle to killgetParticles()
public void setEnabled(boolean enabled)
When a particle is disabled, it will be "frozen in time" and not update.
enabled
- True to enable the particle emitterpublic boolean isEnabled()
setEnabled(boolean)
public void updateFromControl(float tpf)
tpf
- time per frame (in seconds)public void preload(RenderManager rm, ViewPort vp)
public void write(JmeExporter ex) throws java.io.IOException
public void read(JmeImporter im) throws java.io.IOException