|
@@ -65,12 +65,12 @@ import java.io.IOException;
|
|
* Particle emitters can be used to simulate various kinds of phenomena,
|
|
* Particle emitters can be used to simulate various kinds of phenomena,
|
|
* such as fire, smoke, explosions and much more.
|
|
* such as fire, smoke, explosions and much more.
|
|
* <p>
|
|
* <p>
|
|
- * Particle emitters have many properties which are used to control the
|
|
|
|
- * simulation. The interpretation of these properties depends on the
|
|
|
|
|
|
+ * Particle emitters have many properties which are used to control the
|
|
|
|
+ * simulation. The interpretation of these properties depends on the
|
|
* {@link ParticleInfluencer} that has been assigned to the emitter via
|
|
* {@link ParticleInfluencer} that has been assigned to the emitter via
|
|
* {@link ParticleEmitter#setParticleInfluencer(com.jme3.effect.influencers.ParticleInfluencer) }.
|
|
* {@link ParticleEmitter#setParticleInfluencer(com.jme3.effect.influencers.ParticleInfluencer) }.
|
|
* By default the implementation {@link DefaultParticleInfluencer} is used.
|
|
* By default the implementation {@link DefaultParticleInfluencer} is used.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @author Kirill Vainer
|
|
* @author Kirill Vainer
|
|
*/
|
|
*/
|
|
public class ParticleEmitter extends Geometry {
|
|
public class ParticleEmitter extends Geometry {
|
|
@@ -100,7 +100,7 @@ public class ParticleEmitter extends Geometry {
|
|
private Vector3f faceNormal = new Vector3f(Vector3f.NAN);
|
|
private Vector3f faceNormal = new Vector3f(Vector3f.NAN);
|
|
private int imagesX = 1;
|
|
private int imagesX = 1;
|
|
private int imagesY = 1;
|
|
private int imagesY = 1;
|
|
-
|
|
|
|
|
|
+
|
|
private ColorRGBA startColor = new ColorRGBA(0.4f, 0.4f, 0.4f, 0.5f);
|
|
private ColorRGBA startColor = new ColorRGBA(0.4f, 0.4f, 0.4f, 0.5f);
|
|
private ColorRGBA endColor = new ColorRGBA(0.1f, 0.1f, 0.1f, 0.0f);
|
|
private ColorRGBA endColor = new ColorRGBA(0.1f, 0.1f, 0.1f, 0.0f);
|
|
private float startSize = 0.2f;
|
|
private float startSize = 0.2f;
|
|
@@ -127,20 +127,20 @@ public class ParticleEmitter extends Geometry {
|
|
// fixed automatically by ParticleEmitter.clone() method.
|
|
// fixed automatically by ParticleEmitter.clone() method.
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
|
|
+ @Override
|
|
public Object jmeClone() {
|
|
public Object jmeClone() {
|
|
try {
|
|
try {
|
|
return super.clone();
|
|
return super.clone();
|
|
} catch( CloneNotSupportedException e ) {
|
|
} catch( CloneNotSupportedException e ) {
|
|
throw new RuntimeException("Error cloning", e);
|
|
throw new RuntimeException("Error cloning", e);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
|
- public void cloneFields( Cloner cloner, Object original ) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void cloneFields( Cloner cloner, Object original ) {
|
|
this.parentEmitter = cloner.clone(parentEmitter);
|
|
this.parentEmitter = cloner.clone(parentEmitter);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void setSpatial(Spatial spatial) {
|
|
public void setSpatial(Spatial spatial) {
|
|
}
|
|
}
|
|
|
|
|
|
@@ -174,6 +174,13 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ParticleEmitter clone(boolean cloneMaterial) {
|
|
public ParticleEmitter clone(boolean cloneMaterial) {
|
|
|
|
+ return (ParticleEmitter)super.clone(cloneMaterial);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The old clone() method that did not use the new Cloner utility.
|
|
|
|
+ */
|
|
|
|
+ public ParticleEmitter oldClone(boolean cloneMaterial) {
|
|
ParticleEmitter clone = (ParticleEmitter) super.clone(cloneMaterial);
|
|
ParticleEmitter clone = (ParticleEmitter) super.clone(cloneMaterial);
|
|
clone.shape = shape.deepClone();
|
|
clone.shape = shape.deepClone();
|
|
|
|
|
|
@@ -211,6 +218,44 @@ public class ParticleEmitter extends Geometry {
|
|
return clone;
|
|
return clone;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void cloneFields( Cloner cloner, Object original ) {
|
|
|
|
+ super.cloneFields(cloner, original);
|
|
|
|
+
|
|
|
|
+ this.shape = cloner.clone(shape);
|
|
|
|
+ this.control = cloner.clone(control);
|
|
|
|
+ this.faceNormal = cloner.clone(faceNormal);
|
|
|
|
+ this.startColor = cloner.clone(startColor);
|
|
|
|
+ this.endColor = cloner.clone(endColor);
|
|
|
|
+ this.particleInfluencer = cloner.clone(particleInfluencer);
|
|
|
|
+
|
|
|
|
+ // change in behavior: gravity was not cloned before -pspeed
|
|
|
|
+ this.gravity = cloner.clone(gravity);
|
|
|
|
+
|
|
|
|
+ // So, simply setting the mesh type will cause all kinds of things
|
|
|
|
+ // to happen:
|
|
|
|
+ // 1) the new mesh gets created.
|
|
|
|
+ // 2) it is set to the Geometry
|
|
|
|
+ // 3) the particles array is recreated because setNumParticles()
|
|
|
|
+ //
|
|
|
|
+ // ...so this should be equivalent but simpler than half of the old clone()
|
|
|
|
+ // method. Note: we do not ever want to share particleMesh so we do not
|
|
|
|
+ // clone it at all.
|
|
|
|
+ setMeshType(meshType);
|
|
|
|
+
|
|
|
|
+ // change in behavior: temp and lastPos were not cloned before...
|
|
|
|
+ // perhaps because it was believed that 'transient' fields were exluded
|
|
|
|
+ // from cloning? (they aren't)
|
|
|
|
+ // If it was ok for these to be shared because of how they are used
|
|
|
|
+ // then they could just as well be made static... else I think it's clearer
|
|
|
|
+ // to clone them.
|
|
|
|
+ this.temp = cloner.clone(temp);
|
|
|
|
+ this.lastPos = cloner.clone(lastPos);
|
|
|
|
+ }
|
|
|
|
+
|
|
public ParticleEmitter(String name, Type type, int numParticles) {
|
|
public ParticleEmitter(String name, Type type, int numParticles) {
|
|
super(name);
|
|
super(name);
|
|
setBatchHint(BatchHint.Never);
|
|
setBatchHint(BatchHint.Never);
|
|
@@ -225,7 +270,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
meshType = type;
|
|
meshType = type;
|
|
|
|
|
|
- // Must create clone of shape/influencer so that a reference to a static is
|
|
|
|
|
|
+ // Must create clone of shape/influencer so that a reference to a static is
|
|
// not maintained
|
|
// not maintained
|
|
shape = shape.deepClone();
|
|
shape = shape.deepClone();
|
|
particleInfluencer = particleInfluencer.clone();
|
|
particleInfluencer = particleInfluencer.clone();
|
|
@@ -267,10 +312,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the {@link ParticleInfluencer} to influence this particle emitter.
|
|
* Set the {@link ParticleInfluencer} to influence this particle emitter.
|
|
- *
|
|
|
|
- * @param particleInfluencer the {@link ParticleInfluencer} to influence
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param particleInfluencer the {@link ParticleInfluencer} to influence
|
|
* this particle emitter.
|
|
* this particle emitter.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @see ParticleInfluencer
|
|
* @see ParticleInfluencer
|
|
*/
|
|
*/
|
|
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) {
|
|
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) {
|
|
@@ -278,12 +323,12 @@ public class ParticleEmitter extends Geometry {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Returns the {@link ParticleInfluencer} that influences this
|
|
|
|
|
|
+ * Returns the {@link ParticleInfluencer} that influences this
|
|
* particle emitter.
|
|
* particle emitter.
|
|
- *
|
|
|
|
- * @return the {@link ParticleInfluencer} that influences this
|
|
|
|
|
|
+ *
|
|
|
|
+ * @return the {@link ParticleInfluencer} that influences this
|
|
* particle emitter.
|
|
* particle emitter.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @see ParticleInfluencer
|
|
* @see ParticleInfluencer
|
|
*/
|
|
*/
|
|
public ParticleInfluencer getParticleInfluencer() {
|
|
public ParticleInfluencer getParticleInfluencer() {
|
|
@@ -292,12 +337,12 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the mesh type used by the particle emitter.
|
|
* Returns the mesh type used by the particle emitter.
|
|
- *
|
|
|
|
- *
|
|
|
|
|
|
+ *
|
|
|
|
+ *
|
|
* @return the mesh type used by the particle emitter.
|
|
* @return the mesh type used by the particle emitter.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @see #setMeshType(com.jme3.effect.ParticleMesh.Type)
|
|
* @see #setMeshType(com.jme3.effect.ParticleMesh.Type)
|
|
- * @see ParticleEmitter#ParticleEmitter(java.lang.String, com.jme3.effect.ParticleMesh.Type, int)
|
|
|
|
|
|
+ * @see ParticleEmitter#ParticleEmitter(java.lang.String, com.jme3.effect.ParticleMesh.Type, int)
|
|
*/
|
|
*/
|
|
public ParticleMesh.Type getMeshType() {
|
|
public ParticleMesh.Type getMeshType() {
|
|
return meshType;
|
|
return meshType;
|
|
@@ -325,26 +370,26 @@ public class ParticleEmitter extends Geometry {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Returns true if particles should spawn in world space.
|
|
|
|
- *
|
|
|
|
- * @return true if particles should spawn in world space.
|
|
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setInWorldSpace(boolean)
|
|
|
|
|
|
+ * Returns true if particles should spawn in world space.
|
|
|
|
+ *
|
|
|
|
+ * @return true if particles should spawn in world space.
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setInWorldSpace(boolean)
|
|
*/
|
|
*/
|
|
public boolean isInWorldSpace() {
|
|
public boolean isInWorldSpace() {
|
|
return worldSpace;
|
|
return worldSpace;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set to true if particles should spawn in world space.
|
|
|
|
- *
|
|
|
|
|
|
+ * Set to true if particles should spawn in world space.
|
|
|
|
+ *
|
|
* <p>If set to true and the particle emitter is moved in the scene,
|
|
* <p>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
|
|
* then particles that have already spawned won't be effected by this
|
|
* motion. If set to false, the particles will emit in local space
|
|
* motion. If set to false, the particles will emit in local space
|
|
* and when the emitter is moved, so are all the particles that
|
|
* and when the emitter is moved, so are all the particles that
|
|
* were emitted previously.
|
|
* were emitted previously.
|
|
- *
|
|
|
|
- * @param worldSpace true if particles should spawn in world space.
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param worldSpace true if particles should spawn in world space.
|
|
*/
|
|
*/
|
|
public void setInWorldSpace(boolean worldSpace) {
|
|
public void setInWorldSpace(boolean worldSpace) {
|
|
this.setIgnoreTransform(worldSpace);
|
|
this.setIgnoreTransform(worldSpace);
|
|
@@ -353,7 +398,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the number of visible particles (spawned but not dead).
|
|
* Returns the number of visible particles (spawned but not dead).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the number of visible particles
|
|
* @return the number of visible particles
|
|
*/
|
|
*/
|
|
public int getNumVisibleParticles() {
|
|
public int getNumVisibleParticles() {
|
|
@@ -365,7 +410,7 @@ public class ParticleEmitter extends Geometry {
|
|
* Set the maximum amount of particles that
|
|
* Set the maximum amount of particles that
|
|
* can exist at the same time with this emitter.
|
|
* can exist at the same time with this emitter.
|
|
* Calling this method many times is not recommended.
|
|
* Calling this method many times is not recommended.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param numParticles the maximum amount of particles that
|
|
* @param numParticles the maximum amount of particles that
|
|
* can exist at the same time with this emitter.
|
|
* can exist at the same time with this emitter.
|
|
*/
|
|
*/
|
|
@@ -387,13 +432,13 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns a list of all particles (shouldn't be used in most cases).
|
|
* Returns a list of all particles (shouldn't be used in most cases).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>
|
|
* <p>
|
|
* This includes both existing and non-existing particles.
|
|
* This includes both existing and non-existing particles.
|
|
* The size of the array is set to the <code>numParticles</code> value
|
|
* The size of the array is set to the <code>numParticles</code> value
|
|
* specified in the constructor or {@link ParticleEmitter#setNumParticles(int) }
|
|
* specified in the constructor or {@link ParticleEmitter#setNumParticles(int) }
|
|
- * method.
|
|
|
|
- *
|
|
|
|
|
|
+ * method.
|
|
|
|
+ *
|
|
* @return a list of all particles.
|
|
* @return a list of all particles.
|
|
*/
|
|
*/
|
|
public Particle[] getParticles() {
|
|
public Particle[] getParticles() {
|
|
@@ -401,11 +446,11 @@ public class ParticleEmitter extends Geometry {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the normal which particles are facing.
|
|
|
|
- *
|
|
|
|
- * @return the normal which particles are facing.
|
|
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setFaceNormal(com.jme3.math.Vector3f)
|
|
|
|
|
|
+ * Get the normal which particles are facing.
|
|
|
|
+ *
|
|
|
|
+ * @return the normal which particles are facing.
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setFaceNormal(com.jme3.math.Vector3f)
|
|
*/
|
|
*/
|
|
public Vector3f getFaceNormal() {
|
|
public Vector3f getFaceNormal() {
|
|
if (Vector3f.isValidVector(faceNormal)) {
|
|
if (Vector3f.isValidVector(faceNormal)) {
|
|
@@ -416,8 +461,8 @@ public class ParticleEmitter extends Geometry {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the normal which particles are facing.
|
|
|
|
- *
|
|
|
|
|
|
+ * Sets the normal which particles are facing.
|
|
|
|
+ *
|
|
* <p>By default, particles
|
|
* <p>By default, particles
|
|
* will face the camera, but for some effects (e.g shockwave) it may
|
|
* will face the camera, but for some effects (e.g shockwave) it may
|
|
* be necessary to face a specific direction instead. To restore
|
|
* be necessary to face a specific direction instead. To restore
|
|
@@ -437,10 +482,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the rotation speed in radians/sec for particles.
|
|
* Returns the rotation speed in radians/sec for particles.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the rotation speed in radians/sec for particles.
|
|
* @return the rotation speed in radians/sec for particles.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setRotateSpeed(float)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setRotateSpeed(float)
|
|
*/
|
|
*/
|
|
public float getRotateSpeed() {
|
|
public float getRotateSpeed() {
|
|
return rotateSpeed;
|
|
return rotateSpeed;
|
|
@@ -449,7 +494,7 @@ public class ParticleEmitter extends Geometry {
|
|
/**
|
|
/**
|
|
* Set the rotation speed in radians/sec for particles
|
|
* Set the rotation speed in radians/sec for particles
|
|
* spawned after the invocation of this method.
|
|
* spawned after the invocation of this method.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param rotateSpeed the rotation speed in radians/sec for particles
|
|
* @param rotateSpeed the rotation speed in radians/sec for particles
|
|
* spawned after the invocation of this method.
|
|
* spawned after the invocation of this method.
|
|
*/
|
|
*/
|
|
@@ -459,12 +504,12 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns true if every particle spawned
|
|
* Returns true if every particle spawned
|
|
- * should have a random facing angle.
|
|
|
|
- *
|
|
|
|
|
|
+ * should have a random facing angle.
|
|
|
|
+ *
|
|
* @return true if every particle spawned
|
|
* @return true if every particle spawned
|
|
- * should have a random facing angle.
|
|
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setRandomAngle(boolean)
|
|
|
|
|
|
+ * should have a random facing angle.
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setRandomAngle(boolean)
|
|
*/
|
|
*/
|
|
public boolean isRandomAngle() {
|
|
public boolean isRandomAngle() {
|
|
return randomAngle;
|
|
return randomAngle;
|
|
@@ -472,8 +517,8 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set to true if every particle spawned
|
|
* Set to true if every particle spawned
|
|
- * should have a random facing angle.
|
|
|
|
- *
|
|
|
|
|
|
+ * should have a random facing angle.
|
|
|
|
+ *
|
|
* @param randomAngle if every particle spawned
|
|
* @param randomAngle if every particle spawned
|
|
* should have a random facing angle.
|
|
* should have a random facing angle.
|
|
*/
|
|
*/
|
|
@@ -484,11 +529,11 @@ public class ParticleEmitter extends Geometry {
|
|
/**
|
|
/**
|
|
* Returns true if every particle spawned should get a random
|
|
* Returns true if every particle spawned should get a random
|
|
* image.
|
|
* image.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return True if every particle spawned should get a random
|
|
* @return True if every particle spawned should get a random
|
|
* image.
|
|
* image.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setSelectRandomImage(boolean)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setSelectRandomImage(boolean)
|
|
*/
|
|
*/
|
|
public boolean isSelectRandomImage() {
|
|
public boolean isSelectRandomImage() {
|
|
return selectRandomImage;
|
|
return selectRandomImage;
|
|
@@ -498,7 +543,7 @@ public class ParticleEmitter extends Geometry {
|
|
* Set to true if every particle spawned
|
|
* Set to true if every particle spawned
|
|
* should get a random image from a pool of images constructed from
|
|
* should get a random image from a pool of images constructed from
|
|
* the texture, with X by Y possible images.
|
|
* the texture, with X by Y possible images.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>By default, X and Y are equal
|
|
* <p>By default, X and Y are equal
|
|
* to 1, thus allowing only 1 possible image to be selected, but if the
|
|
* to 1, thus allowing only 1 possible image to be selected, but if the
|
|
* particle is configured with multiple images by using {@link ParticleEmitter#setImagesX(int) }
|
|
* particle is configured with multiple images by using {@link ParticleEmitter#setImagesX(int) }
|
|
@@ -506,7 +551,7 @@ public class ParticleEmitter extends Geometry {
|
|
* can be selected. Setting to false will cause each particle to have an animation
|
|
* 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
|
|
* of images displayed, starting at image 1, and going until image X*Y when
|
|
* the particle reaches its end of life.
|
|
* the particle reaches its end of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param selectRandomImage True if every particle spawned should get a random
|
|
* @param selectRandomImage True if every particle spawned should get a random
|
|
* image.
|
|
* image.
|
|
*/
|
|
*/
|
|
@@ -516,10 +561,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Check if particles spawned should face their velocity.
|
|
* Check if particles spawned should face their velocity.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return True if particles spawned should face their velocity.
|
|
* @return True if particles spawned should face their velocity.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setFacingVelocity(boolean)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setFacingVelocity(boolean)
|
|
*/
|
|
*/
|
|
public boolean isFacingVelocity() {
|
|
public boolean isFacingVelocity() {
|
|
return facingVelocity;
|
|
return facingVelocity;
|
|
@@ -528,11 +573,11 @@ public class ParticleEmitter extends Geometry {
|
|
/**
|
|
/**
|
|
* Set to true if particles spawned should face
|
|
* Set to true if particles spawned should face
|
|
* their velocity (or direction to which they are moving towards).
|
|
* their velocity (or direction to which they are moving towards).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>This is typically used for e.g spark effects.
|
|
* <p>This is typically used for e.g spark effects.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param followVelocity True if particles spawned should face their velocity.
|
|
* @param followVelocity True if particles spawned should face their velocity.
|
|
- *
|
|
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
public void setFacingVelocity(boolean followVelocity) {
|
|
public void setFacingVelocity(boolean followVelocity) {
|
|
this.facingVelocity = followVelocity;
|
|
this.facingVelocity = followVelocity;
|
|
@@ -540,10 +585,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the end color of the particles spawned.
|
|
* Get the end color of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the end color of the particles spawned.
|
|
* @return the end color of the particles spawned.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setEndColor(com.jme3.math.ColorRGBA)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setEndColor(com.jme3.math.ColorRGBA)
|
|
*/
|
|
*/
|
|
public ColorRGBA getEndColor() {
|
|
public ColorRGBA getEndColor() {
|
|
return endColor;
|
|
return endColor;
|
|
@@ -551,12 +596,12 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the end color of the particles spawned.
|
|
* Set the end color of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>The
|
|
* <p>The
|
|
* particle color at any time is determined by blending the start color
|
|
* 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
|
|
* and end color based on the particle's current time of life relative
|
|
* to its end of life.
|
|
* to its end of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param endColor the end color of the particles spawned.
|
|
* @param endColor the end color of the particles spawned.
|
|
*/
|
|
*/
|
|
public void setEndColor(ColorRGBA endColor) {
|
|
public void setEndColor(ColorRGBA endColor) {
|
|
@@ -565,10 +610,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the end size of the particles spawned.
|
|
* Get the end size of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the end size of the particles spawned.
|
|
* @return the end size of the particles spawned.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setEndSize(float)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setEndSize(float)
|
|
*/
|
|
*/
|
|
public float getEndSize() {
|
|
public float getEndSize() {
|
|
return endSize;
|
|
return endSize;
|
|
@@ -576,12 +621,12 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the end size of the particles spawned.
|
|
* Set the end size of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>The
|
|
* <p>The
|
|
* particle size at any time is determined by blending the start size
|
|
* 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
|
|
* and end size based on the particle's current time of life relative
|
|
* to its end of life.
|
|
* to its end of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param endSize the end size of the particles spawned.
|
|
* @param endSize the end size of the particles spawned.
|
|
*/
|
|
*/
|
|
public void setEndSize(float endSize) {
|
|
public void setEndSize(float endSize) {
|
|
@@ -590,10 +635,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the gravity vector.
|
|
* Get the gravity vector.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the gravity vector.
|
|
* @return the gravity vector.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setGravity(com.jme3.math.Vector3f)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setGravity(com.jme3.math.Vector3f)
|
|
*/
|
|
*/
|
|
public Vector3f getGravity() {
|
|
public Vector3f getGravity() {
|
|
return gravity;
|
|
return gravity;
|
|
@@ -601,7 +646,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* This method sets the gravity vector.
|
|
* This method sets the gravity vector.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param gravity the gravity vector
|
|
* @param gravity the gravity vector
|
|
*/
|
|
*/
|
|
public void setGravity(Vector3f gravity) {
|
|
public void setGravity(Vector3f gravity) {
|
|
@@ -610,7 +655,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Sets the gravity vector.
|
|
* Sets the gravity vector.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param x the x component of the gravity vector
|
|
* @param x the x component of the gravity vector
|
|
* @param y the y component of the gravity vector
|
|
* @param y the y component of the gravity vector
|
|
* @param z the z component of the gravity vector
|
|
* @param z the z component of the gravity vector
|
|
@@ -623,10 +668,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the high value of life.
|
|
* Get the high value of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the high value of life.
|
|
* @return the high value of life.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setHighLife(float)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setHighLife(float)
|
|
*/
|
|
*/
|
|
public float getHighLife() {
|
|
public float getHighLife() {
|
|
return highLife;
|
|
return highLife;
|
|
@@ -634,10 +679,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the high value of life.
|
|
* Set the high value of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>The particle's lifetime/expiration
|
|
* <p>The particle's lifetime/expiration
|
|
* is determined by randomly selecting a time between low life and high life.
|
|
* is determined by randomly selecting a time between low life and high life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param highLife the high value of life.
|
|
* @param highLife the high value of life.
|
|
*/
|
|
*/
|
|
public void setHighLife(float highLife) {
|
|
public void setHighLife(float highLife) {
|
|
@@ -646,10 +691,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the number of images along the X axis (width).
|
|
* Get the number of images along the X axis (width).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the number of images along the X axis (width).
|
|
* @return the number of images along the X axis (width).
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setImagesX(int)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setImagesX(int)
|
|
*/
|
|
*/
|
|
public int getImagesX() {
|
|
public int getImagesX() {
|
|
return imagesX;
|
|
return imagesX;
|
|
@@ -657,11 +702,11 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the number of images along the X axis (width).
|
|
* Set the number of images along the X axis (width).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>To determine
|
|
* <p>To determine
|
|
* how multiple particle images are selected and used, see the
|
|
* how multiple particle images are selected and used, see the
|
|
* {@link ParticleEmitter#setSelectRandomImage(boolean) } method.
|
|
* {@link ParticleEmitter#setSelectRandomImage(boolean) } method.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param imagesX the number of images along the X axis (width).
|
|
* @param imagesX the number of images along the X axis (width).
|
|
*/
|
|
*/
|
|
public void setImagesX(int imagesX) {
|
|
public void setImagesX(int imagesX) {
|
|
@@ -671,10 +716,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the number of images along the Y axis (height).
|
|
* Get the number of images along the Y axis (height).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the number of images along the Y axis (height).
|
|
* @return the number of images along the Y axis (height).
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setImagesY(int)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setImagesY(int)
|
|
*/
|
|
*/
|
|
public int getImagesY() {
|
|
public int getImagesY() {
|
|
return imagesY;
|
|
return imagesY;
|
|
@@ -682,10 +727,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the number of images along the Y axis (height).
|
|
* Set the number of images along the Y axis (height).
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>To determine how multiple particle images are selected and used, see the
|
|
* <p>To determine how multiple particle images are selected and used, see the
|
|
* {@link ParticleEmitter#setSelectRandomImage(boolean) } method.
|
|
* {@link ParticleEmitter#setSelectRandomImage(boolean) } method.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param imagesY the number of images along the Y axis (height).
|
|
* @param imagesY the number of images along the Y axis (height).
|
|
*/
|
|
*/
|
|
public void setImagesY(int imagesY) {
|
|
public void setImagesY(int imagesY) {
|
|
@@ -695,10 +740,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the low value of life.
|
|
* Get the low value of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the low value of life.
|
|
* @return the low value of life.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setLowLife(float)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setLowLife(float)
|
|
*/
|
|
*/
|
|
public float getLowLife() {
|
|
public float getLowLife() {
|
|
return lowLife;
|
|
return lowLife;
|
|
@@ -706,10 +751,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the low value of life.
|
|
* Set the low value of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>The particle's lifetime/expiration
|
|
* <p>The particle's lifetime/expiration
|
|
* is determined by randomly selecting a time between low life and high life.
|
|
* is determined by randomly selecting a time between low life and high life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param lowLife the low value of life.
|
|
* @param lowLife the low value of life.
|
|
*/
|
|
*/
|
|
public void setLowLife(float lowLife) {
|
|
public void setLowLife(float lowLife) {
|
|
@@ -719,11 +764,11 @@ public class ParticleEmitter extends Geometry {
|
|
/**
|
|
/**
|
|
* Get the number of particles to spawn per
|
|
* Get the number of particles to spawn per
|
|
* second.
|
|
* second.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the number of particles to spawn per
|
|
* @return the number of particles to spawn per
|
|
* second.
|
|
* second.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setParticlesPerSec(float)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setParticlesPerSec(float)
|
|
*/
|
|
*/
|
|
public float getParticlesPerSec() {
|
|
public float getParticlesPerSec() {
|
|
return particlesPerSec;
|
|
return particlesPerSec;
|
|
@@ -732,7 +777,7 @@ public class ParticleEmitter extends Geometry {
|
|
/**
|
|
/**
|
|
* Set the number of particles to spawn per
|
|
* Set the number of particles to spawn per
|
|
* second.
|
|
* second.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param particlesPerSec the number of particles to spawn per
|
|
* @param particlesPerSec the number of particles to spawn per
|
|
* second.
|
|
* second.
|
|
*/
|
|
*/
|
|
@@ -740,13 +785,13 @@ public class ParticleEmitter extends Geometry {
|
|
this.particlesPerSec = particlesPerSec;
|
|
this.particlesPerSec = particlesPerSec;
|
|
timeDifference = 0;
|
|
timeDifference = 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get the start color of the particles spawned.
|
|
* Get the start color of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the start color of the particles spawned.
|
|
* @return the start color of the particles spawned.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setStartColor(com.jme3.math.ColorRGBA)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setStartColor(com.jme3.math.ColorRGBA)
|
|
*/
|
|
*/
|
|
public ColorRGBA getStartColor() {
|
|
public ColorRGBA getStartColor() {
|
|
return startColor;
|
|
return startColor;
|
|
@@ -754,11 +799,11 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the start color of the particles spawned.
|
|
* Set the start color of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>The particle color at any time is determined by blending the start color
|
|
* <p>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
|
|
* and end color based on the particle's current time of life relative
|
|
* to its end of life.
|
|
* to its end of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param startColor the start color of the particles spawned
|
|
* @param startColor the start color of the particles spawned
|
|
*/
|
|
*/
|
|
public void setStartColor(ColorRGBA startColor) {
|
|
public void setStartColor(ColorRGBA startColor) {
|
|
@@ -767,10 +812,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the start color of the particles spawned.
|
|
* Get the start color of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the start color of the particles spawned.
|
|
* @return the start color of the particles spawned.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setStartSize(float)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setStartSize(float)
|
|
*/
|
|
*/
|
|
public float getStartSize() {
|
|
public float getStartSize() {
|
|
return startSize;
|
|
return startSize;
|
|
@@ -778,11 +823,11 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set the start size of the particles spawned.
|
|
* Set the start size of the particles spawned.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>The particle size at any time is determined by blending the start size
|
|
* <p>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
|
|
* and end size based on the particle's current time of life relative
|
|
* to its end of life.
|
|
* to its end of life.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param startSize the start size of the particles spawned.
|
|
* @param startSize the start size of the particles spawned.
|
|
*/
|
|
*/
|
|
public void setStartSize(float startSize) {
|
|
public void setStartSize(float startSize) {
|
|
@@ -805,10 +850,10 @@ public class ParticleEmitter extends Geometry {
|
|
* gravity.
|
|
* gravity.
|
|
*
|
|
*
|
|
* @deprecated
|
|
* @deprecated
|
|
- * This method is deprecated.
|
|
|
|
|
|
+ * This method is deprecated.
|
|
* Use ParticleEmitter.getParticleInfluencer().setInitialVelocity(initialVelocity); instead.
|
|
* Use ParticleEmitter.getParticleInfluencer().setInitialVelocity(initialVelocity); instead.
|
|
*
|
|
*
|
|
- * @see ParticleEmitter#setVelocityVariation(float)
|
|
|
|
|
|
+ * @see ParticleEmitter#setVelocityVariation(float)
|
|
* @see ParticleEmitter#setGravity(float)
|
|
* @see ParticleEmitter#setGravity(float)
|
|
*/
|
|
*/
|
|
@Deprecated
|
|
@Deprecated
|
|
@@ -818,7 +863,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* @deprecated
|
|
* @deprecated
|
|
- * This method is deprecated.
|
|
|
|
|
|
+ * This method is deprecated.
|
|
* Use ParticleEmitter.getParticleInfluencer().getVelocityVariation(); instead.
|
|
* Use ParticleEmitter.getParticleInfluencer().getVelocityVariation(); instead.
|
|
* @return the initial velocity variation factor
|
|
* @return the initial velocity variation factor
|
|
*/
|
|
*/
|
|
@@ -833,9 +878,9 @@ public class ParticleEmitter extends Geometry {
|
|
* from 0 to 1, where 0 means particles are to spawn with exactly
|
|
* from 0 to 1, where 0 means particles are to spawn with exactly
|
|
* the velocity given in {@link ParticleEmitter#setStartVel(com.jme3.math.Vector3f) },
|
|
* the velocity given in {@link ParticleEmitter#setStartVel(com.jme3.math.Vector3f) },
|
|
* and 1 means particles are to spawn with a completely random velocity.
|
|
* and 1 means particles are to spawn with a completely random velocity.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @deprecated
|
|
* @deprecated
|
|
- * This method is deprecated.
|
|
|
|
|
|
+ * This method is deprecated.
|
|
* Use ParticleEmitter.getParticleInfluencer().setVelocityVariation(variation); instead.
|
|
* Use ParticleEmitter.getParticleInfluencer().setVelocityVariation(variation); instead.
|
|
*/
|
|
*/
|
|
@Deprecated
|
|
@Deprecated
|
|
@@ -923,7 +968,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
vars.release();
|
|
vars.release();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Instantly kills all active particles, after this method is called, all
|
|
* Instantly kills all active particles, after this method is called, all
|
|
* particles will be dead and no longer visible.
|
|
* particles will be dead and no longer visible.
|
|
@@ -935,12 +980,12 @@ public class ParticleEmitter extends Geometry {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Kills the particle at the given index.
|
|
* Kills the particle at the given index.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param index The index of the particle to kill
|
|
* @param index The index of the particle to kill
|
|
- * @see #getParticles()
|
|
|
|
|
|
+ * @see #getParticles()
|
|
*/
|
|
*/
|
|
public void killParticle(int index){
|
|
public void killParticle(int index){
|
|
freeParticle(index);
|
|
freeParticle(index);
|
|
@@ -995,7 +1040,7 @@ public class ParticleEmitter extends Geometry {
|
|
p.imageIndex = (int) (b * imagesX * imagesY);
|
|
p.imageIndex = (int) (b * imagesX * imagesY);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private void updateParticleState(float tpf) {
|
|
private void updateParticleState(float tpf) {
|
|
// Force world transform to update
|
|
// Force world transform to update
|
|
this.getWorldTransform();
|
|
this.getWorldTransform();
|
|
@@ -1028,7 +1073,7 @@ public class ParticleEmitter extends Geometry {
|
|
firstUnUsed++;
|
|
firstUnUsed++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Spawns particles within the tpf timeslot with proper age
|
|
// Spawns particles within the tpf timeslot with proper age
|
|
float interval = 1f / particlesPerSec;
|
|
float interval = 1f / particlesPerSec;
|
|
float originalTpf = tpf;
|
|
float originalTpf = tpf;
|
|
@@ -1065,10 +1110,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set to enable or disable the particle emitter
|
|
* Set to enable or disable the particle emitter
|
|
- *
|
|
|
|
|
|
+ *
|
|
* <p>When a particle is
|
|
* <p>When a particle is
|
|
* disabled, it will be "frozen in time" and not update.
|
|
* disabled, it will be "frozen in time" and not update.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param enabled True to enable the particle emitter
|
|
* @param enabled True to enable the particle emitter
|
|
*/
|
|
*/
|
|
public void setEnabled(boolean enabled) {
|
|
public void setEnabled(boolean enabled) {
|
|
@@ -1077,10 +1122,10 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Check if a particle emitter is enabled for update.
|
|
* Check if a particle emitter is enabled for update.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return True if a particle emitter is enabled for update.
|
|
* @return True if a particle emitter is enabled for update.
|
|
- *
|
|
|
|
- * @see ParticleEmitter#setEnabled(boolean)
|
|
|
|
|
|
+ *
|
|
|
|
+ * @see ParticleEmitter#setEnabled(boolean)
|
|
*/
|
|
*/
|
|
public boolean isEnabled() {
|
|
public boolean isEnabled() {
|
|
return enabled;
|
|
return enabled;
|
|
@@ -1088,7 +1133,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Callback from Control.update(), do not use.
|
|
* Callback from Control.update(), do not use.
|
|
- * @param tpf
|
|
|
|
|
|
+ * @param tpf
|
|
*/
|
|
*/
|
|
public void updateFromControl(float tpf) {
|
|
public void updateFromControl(float tpf) {
|
|
if (enabled) {
|
|
if (enabled) {
|
|
@@ -1098,9 +1143,9 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Callback from Control.render(), do not use.
|
|
* Callback from Control.render(), do not use.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param rm
|
|
* @param rm
|
|
- * @param vp
|
|
|
|
|
|
+ * @param vp
|
|
*/
|
|
*/
|
|
private void renderFromControl(RenderManager rm, ViewPort vp) {
|
|
private void renderFromControl(RenderManager rm, ViewPort vp) {
|
|
Camera cam = vp.getCamera();
|
|
Camera cam = vp.getCamera();
|
|
@@ -1236,7 +1281,7 @@ public class ParticleEmitter extends Geometry {
|
|
gravity.y = ic.readFloat("gravity", 0);
|
|
gravity.y = ic.readFloat("gravity", 0);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- // since the parentEmitter is not loaded, it must be
|
|
|
|
|
|
+ // since the parentEmitter is not loaded, it must be
|
|
// loaded separately
|
|
// loaded separately
|
|
control = getControl(ParticleEmitterControl.class);
|
|
control = getControl(ParticleEmitterControl.class);
|
|
control.parentEmitter = this;
|
|
control.parentEmitter = this;
|