|
|
@ -29,7 +29,6 @@ |
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package com.jme3.effect; |
|
|
|
package com.jme3.effect; |
|
|
|
|
|
|
|
|
|
|
|
import com.jme3.bounding.BoundingBox; |
|
|
|
import com.jme3.bounding.BoundingBox; |
|
|
@ -57,22 +56,36 @@ import com.jme3.scene.control.Control; |
|
|
|
import com.jme3.util.TempVars; |
|
|
|
import com.jme3.util.TempVars; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
|
|
public class ParticleEmitter extends Geometry implements Control { |
|
|
|
/** |
|
|
|
|
|
|
|
* <code>ParticleEmitter</code> is a special kind of geometry which simulates |
|
|
|
|
|
|
|
* a particle system. |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Particle emitters can be used to simulate various kinds of phenomena, |
|
|
|
|
|
|
|
* such as fire, smoke, explosions and much more. |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* 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 ParticleEmitter#setParticleInfluencer(com.jme3.effect.influencers.ParticleInfluencer) }. |
|
|
|
|
|
|
|
* By default the implementation {@link DefaultParticleInfluencer} is used. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @author Kirill Vainer |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public class ParticleEmitter extends Geometry { |
|
|
|
|
|
|
|
|
|
|
|
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO); |
|
|
|
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO); |
|
|
|
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer(); |
|
|
|
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ParticleEmitterControl control = new ParticleEmitterControl(); |
|
|
|
private EmitterShape shape = DEFAULT_SHAPE; |
|
|
|
private EmitterShape shape = DEFAULT_SHAPE; |
|
|
|
private ParticleMesh particleMesh; |
|
|
|
private ParticleMesh particleMesh; |
|
|
|
private ParticleInfluencer particleInfluencer = DEFAULT_INFLUENCER; |
|
|
|
private ParticleInfluencer particleInfluencer = DEFAULT_INFLUENCER; |
|
|
|
private ParticleMesh.Type meshType; |
|
|
|
private ParticleMesh.Type meshType; |
|
|
|
private Particle[] particles; |
|
|
|
private Particle[] particles; |
|
|
|
|
|
|
|
|
|
|
|
private int firstUnUsed; |
|
|
|
private int firstUnUsed; |
|
|
|
private int lastUsed; |
|
|
|
private int lastUsed; |
|
|
|
|
|
|
|
|
|
|
|
// private int next = 0;
|
|
|
|
// private int next = 0;
|
|
|
|
// private ArrayList<Integer> unusedIndices = new ArrayList<Integer>();
|
|
|
|
// private ArrayList<Integer> unusedIndices = new ArrayList<Integer>();
|
|
|
|
|
|
|
|
|
|
|
|
private boolean randomAngle; |
|
|
|
private boolean randomAngle; |
|
|
|
private boolean selectRandomImage; |
|
|
|
private boolean selectRandomImage; |
|
|
|
private boolean facingVelocity; |
|
|
|
private boolean facingVelocity; |
|
|
@ -83,20 +96,52 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
private Vector3f gravity = new Vector3f(0.0f, 0.1f, 0.0f); |
|
|
|
private Vector3f gravity = new Vector3f(0.0f, 0.1f, 0.0f); |
|
|
|
private float rotateSpeed; |
|
|
|
private float rotateSpeed; |
|
|
|
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 boolean enabled = true; |
|
|
|
private boolean enabled = true; |
|
|
|
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; |
|
|
|
private float endSize = 2f; |
|
|
|
private float endSize = 2f; |
|
|
|
private boolean worldSpace = true; |
|
|
|
private boolean worldSpace = true; |
|
|
|
|
|
|
|
|
|
|
|
//variable that helps with computations
|
|
|
|
//variable that helps with computations
|
|
|
|
private transient Vector3f temp = new Vector3f(); |
|
|
|
private transient Vector3f temp = new Vector3f(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ParticleEmitterControl implements Control { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Control cloneForSpatial(Spatial spatial) { |
|
|
|
|
|
|
|
return ((ParticleEmitter)spatial).control; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setSpatial(Spatial spatial) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setEnabled(boolean enabled) { |
|
|
|
|
|
|
|
ParticleEmitter.this.setEnabled(enabled); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isEnabled() { |
|
|
|
|
|
|
|
return ParticleEmitter.this.isEnabled(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void update(float tpf) { |
|
|
|
|
|
|
|
updateFromControl(tpf); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void render(RenderManager rm, ViewPort vp) { |
|
|
|
|
|
|
|
renderFromControl(rm, vp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void write(JmeExporter ex) throws IOException { |
|
|
|
|
|
|
|
// the data is not written here
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void read(JmeImporter im) throws IOException { |
|
|
|
|
|
|
|
// the data is not written here
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ParticleEmitter clone() { |
|
|
|
public ParticleEmitter clone() { |
|
|
|
ParticleEmitter clone = (ParticleEmitter) super.clone(); |
|
|
|
ParticleEmitter clone = (ParticleEmitter) super.clone(); |
|
|
@ -106,7 +151,7 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
clone.startColor = startColor.clone(); |
|
|
|
clone.startColor = startColor.clone(); |
|
|
|
clone.endColor = endColor.clone(); |
|
|
|
clone.endColor = endColor.clone(); |
|
|
|
clone.particleInfluencer = particleInfluencer.clone(); |
|
|
|
clone.particleInfluencer = particleInfluencer.clone(); |
|
|
|
clone.controls.add(clone); |
|
|
|
clone.controls.add(clone.control); |
|
|
|
return clone; |
|
|
|
return clone; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -126,7 +171,7 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
|
|
|
|
|
|
|
|
this.setNumParticles(numParticles); |
|
|
|
this.setNumParticles(numParticles); |
|
|
|
|
|
|
|
|
|
|
|
controls.add(this); |
|
|
|
controls.add(control); |
|
|
|
|
|
|
|
|
|
|
|
switch (meshType) { |
|
|
|
switch (meshType) { |
|
|
|
case Point: |
|
|
|
case Point: |
|
|
@ -143,53 +188,105 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
particleMesh.initParticleData(this, particles.length); |
|
|
|
particleMesh.initParticleData(this, particles.length); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* For serialization only. Do not use. |
|
|
|
|
|
|
|
*/ |
|
|
|
public ParticleEmitter() { |
|
|
|
public ParticleEmitter() { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Control cloneForSpatial(Spatial spatial){ |
|
|
|
|
|
|
|
return (Control) spatial; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setShape(EmitterShape shape) { |
|
|
|
public void setShape(EmitterShape shape) { |
|
|
|
this.shape = shape; |
|
|
|
this.shape = shape; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EmitterShape getShape() { |
|
|
|
public EmitterShape getShape() { |
|
|
|
return shape; |
|
|
|
return shape; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set the {@link ParticleInfluencer} to influence this particle emitter. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param particleInfluencer the {@link ParticleInfluencer} to influence |
|
|
|
|
|
|
|
* this particle emitter. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleInfluencer |
|
|
|
|
|
|
|
*/ |
|
|
|
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) { |
|
|
|
public void setParticleInfluencer(ParticleInfluencer particleInfluencer) { |
|
|
|
this.particleInfluencer = particleInfluencer; |
|
|
|
this.particleInfluencer = particleInfluencer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the {@link ParticleInfluencer} that influences this |
|
|
|
|
|
|
|
* particle emitter. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the {@link ParticleInfluencer} that influences this |
|
|
|
|
|
|
|
* particle emitter. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleInfluencer |
|
|
|
|
|
|
|
*/ |
|
|
|
public ParticleInfluencer getParticleInfluencer() { |
|
|
|
public ParticleInfluencer getParticleInfluencer() { |
|
|
|
return particleInfluencer; |
|
|
|
return particleInfluencer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the mesh type used by the particle emitter. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>This value is set in the constructor and cannot be modified |
|
|
|
|
|
|
|
* afterwards. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the mesh type used by the particle emitter. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#ParticleEmitter(java.lang.String, com.jme3.effect.ParticleMesh.Type, int) |
|
|
|
|
|
|
|
*/ |
|
|
|
public ParticleMesh.Type getMeshType() { |
|
|
|
public ParticleMesh.Type getMeshType() { |
|
|
|
return meshType; |
|
|
|
return meshType; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 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. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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 |
|
|
|
|
|
|
|
* 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. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @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); |
|
|
|
this.worldSpace = worldSpace; |
|
|
|
this.worldSpace = worldSpace; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the number of visible particles (spawned but not dead). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the number of visible particles |
|
|
|
|
|
|
|
*/ |
|
|
|
public int getNumVisibleParticles() { |
|
|
|
public int getNumVisibleParticles() { |
|
|
|
// return unusedIndices.size() + next;
|
|
|
|
// return unusedIndices.size() + next;
|
|
|
|
return lastUsed + 1; |
|
|
|
return lastUsed + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param numParticles 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 |
|
|
|
|
|
|
|
* can exist at the same time with this emitter. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final void setNumParticles(int numParticles) { |
|
|
|
public final void setNumParticles(int numParticles) { |
|
|
|
particles = new Particle[numParticles]; |
|
|
|
particles = new Particle[numParticles]; |
|
|
@ -201,16 +298,27 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return 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> |
|
|
|
* 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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Particle[] getParticles() { |
|
|
|
public Particle[] getParticles() { |
|
|
|
return particles; |
|
|
|
return particles; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 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)) { |
|
|
|
return faceNormal; |
|
|
|
return faceNormal; |
|
|
@ -220,7 +328,9 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the normal which particles are facing. By default, particles |
|
|
|
* Sets the normal which particles are facing. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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 |
|
|
|
* normal functionality, provide <code>null</code> as the argument for |
|
|
|
* normal functionality, provide <code>null</code> as the argument for |
|
|
@ -237,85 +347,154 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the rotation speed in radians/sec for particles. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the rotation speed in radians/sec for particles. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setRotateSpeed(float) |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getRotateSpeed() { |
|
|
|
public float getRotateSpeed() { |
|
|
|
return rotateSpeed; |
|
|
|
return rotateSpeed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param rotateSpeed 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. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param rotateSpeed the rotation speed in radians/sec for particles |
|
|
|
* spawned after the invocation of this method. |
|
|
|
* spawned after the invocation of this method. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setRotateSpeed(float rotateSpeed) { |
|
|
|
public void setRotateSpeed(float rotateSpeed) { |
|
|
|
this.rotateSpeed = rotateSpeed; |
|
|
|
this.rotateSpeed = rotateSpeed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns true if every particle spawned |
|
|
|
|
|
|
|
* should have a random facing angle. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return true if every particle spawned |
|
|
|
|
|
|
|
* should have a random facing angle. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setRandomAngle(boolean) |
|
|
|
|
|
|
|
*/ |
|
|
|
public boolean isRandomAngle() { |
|
|
|
public boolean isRandomAngle() { |
|
|
|
return randomAngle; |
|
|
|
return randomAngle; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param randomAngle Set to <code>true</code> if every particle spawned |
|
|
|
* Set to true if every particle spawned |
|
|
|
|
|
|
|
* should have a random facing angle. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param randomAngle if every particle spawned |
|
|
|
* should have a random facing angle. |
|
|
|
* should have a random facing angle. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setRandomAngle(boolean randomAngle) { |
|
|
|
public void setRandomAngle(boolean randomAngle) { |
|
|
|
this.randomAngle = randomAngle; |
|
|
|
this.randomAngle = randomAngle; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns true if every particle spawned should get a random |
|
|
|
|
|
|
|
* image. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return True if every particle spawned should get a random |
|
|
|
|
|
|
|
* image. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setSelectRandomImage(boolean) |
|
|
|
|
|
|
|
*/ |
|
|
|
public boolean isSelectRandomImage() { |
|
|
|
public boolean isSelectRandomImage() { |
|
|
|
return selectRandomImage; |
|
|
|
return selectRandomImage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param selectRandomImage 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. By default, X and Y are equal |
|
|
|
* the texture, with X by Y possible images. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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) } |
|
|
|
* and {#link ParticleEmitter#setImagesY(int) } methods, then multiple images |
|
|
|
* and {#link ParticleEmitter#setImagesY(int) } methods, then multiple images |
|
|
|
* 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 |
|
|
|
|
|
|
|
* image. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setSelectRandomImage(boolean selectRandomImage) { |
|
|
|
public void setSelectRandomImage(boolean selectRandomImage) { |
|
|
|
this.selectRandomImage = selectRandomImage; |
|
|
|
this.selectRandomImage = selectRandomImage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Check if particles spawned should face their velocity. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return True if particles spawned should face their velocity. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setFacingVelocity(boolean) |
|
|
|
|
|
|
|
*/ |
|
|
|
public boolean isFacingVelocity() { |
|
|
|
public boolean isFacingVelocity() { |
|
|
|
return facingVelocity; |
|
|
|
return facingVelocity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param followVelocity 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). |
|
|
|
* 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. |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setFacingVelocity(boolean followVelocity) { |
|
|
|
public void setFacingVelocity(boolean followVelocity) { |
|
|
|
this.facingVelocity = followVelocity; |
|
|
|
this.facingVelocity = followVelocity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the end color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the end color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setEndColor(com.jme3.math.ColorRGBA) |
|
|
|
|
|
|
|
*/ |
|
|
|
public ColorRGBA getEndColor() { |
|
|
|
public ColorRGBA getEndColor() { |
|
|
|
return endColor; |
|
|
|
return endColor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param endColor Set the end color of the particles spawned. The |
|
|
|
* Set the end color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setEndColor(ColorRGBA endColor) { |
|
|
|
public void setEndColor(ColorRGBA endColor) { |
|
|
|
this.endColor.set(endColor); |
|
|
|
this.endColor.set(endColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the end size of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the end size of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setEndSize(float) |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getEndSize() { |
|
|
|
public float getEndSize() { |
|
|
|
return endSize; |
|
|
|
return endSize; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param endSize Set the end size of the particles spawned.The |
|
|
|
* Set the end size of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setEndSize(float endSize) { |
|
|
|
public void setEndSize(float endSize) { |
|
|
|
this.endSize = endSize; |
|
|
|
this.endSize = endSize; |
|
|
@ -323,10 +502,14 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method sets the gravity value of Y axis. |
|
|
|
* This method sets the gravity value of Y axis. |
|
|
|
|
|
|
|
* |
|
|
|
* By default the Y axis is the only one to have gravity value non zero. |
|
|
|
* By default the Y axis is the only one to have gravity value non zero. |
|
|
|
|
|
|
|
* |
|
|
|
* @param gravity |
|
|
|
* @param gravity |
|
|
|
* Set the gravity of Y axis, in units/sec/sec, of particles |
|
|
|
* Set the gravity of Y axis, in units/sec/sec, of particles |
|
|
|
* spawned. |
|
|
|
* spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @deprecated Use {@link ParticleEmitter#setGravity(float, float, float) instead. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
|
public void setGravity(float gravity) { |
|
|
|
public void setGravity(float gravity) { |
|
|
@ -334,8 +517,11 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method returns the gravity vector. |
|
|
|
* Get the gravity vector. |
|
|
|
* @return the gravity vector |
|
|
|
* |
|
|
|
|
|
|
|
* @return the gravity vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setGravity(com.jme3.math.Vector3f) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Vector3f getGravity() { |
|
|
|
public Vector3f getGravity() { |
|
|
|
return gravity; |
|
|
|
return gravity; |
|
|
@ -343,26 +529,17 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 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) { |
|
|
|
this.gravity.set(gravity); |
|
|
|
this.gravity.set(gravity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method sets the gravity vector. |
|
|
|
* Sets the gravity vector. |
|
|
|
* @param gravity |
|
|
|
* |
|
|
|
* the gravity vector |
|
|
|
* @param gravity the gravity vector |
|
|
|
*/ |
|
|
|
|
|
|
|
public void setGravity(float[] gravity) { |
|
|
|
|
|
|
|
this.setGravity(gravity[0], gravity[1], gravity[2]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* This method sets the gravity vector. |
|
|
|
|
|
|
|
* @param gravity |
|
|
|
|
|
|
|
* the gravity vector |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setGravity(float x, float y, float z) { |
|
|
|
public void setGravity(float x, float y, float z) { |
|
|
|
this.gravity.x = x; |
|
|
|
this.gravity.x = x; |
|
|
@ -370,102 +547,175 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
this.gravity.z = z; |
|
|
|
this.gravity.z = z; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the high value of life. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the high value of life. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setHighLife(float) |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getHighLife() { |
|
|
|
public float getHighLife() { |
|
|
|
return highLife; |
|
|
|
return highLife; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param highLife Set the high value of life. The particle's lifetime/expiration |
|
|
|
* Set the high value of life. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setHighLife(float highLife) { |
|
|
|
public void setHighLife(float highLife) { |
|
|
|
this.highLife = highLife; |
|
|
|
this.highLife = highLife; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the number of images along the X axis (width). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the number of images along the X axis (width). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setImagesX(int) |
|
|
|
|
|
|
|
*/ |
|
|
|
public int getImagesX() { |
|
|
|
public int getImagesX() { |
|
|
|
return imagesX; |
|
|
|
return imagesX; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param imagesX Set the number of images along the X axis (width). To determine |
|
|
|
* Set the number of images along the X axis (width). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setImagesX(int imagesX) { |
|
|
|
public void setImagesX(int imagesX) { |
|
|
|
this.imagesX = imagesX; |
|
|
|
this.imagesX = imagesX; |
|
|
|
particleMesh.setImagesXY(this.imagesX, this.imagesY); |
|
|
|
particleMesh.setImagesXY(this.imagesX, this.imagesY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the number of images along the Y axis (height). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the number of images along the Y axis (height). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setImagesY(int) |
|
|
|
|
|
|
|
*/ |
|
|
|
public int getImagesY() { |
|
|
|
public int getImagesY() { |
|
|
|
return imagesY; |
|
|
|
return imagesY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param imagesY Set the number of images along the Y axis (height). To determine |
|
|
|
* Set the number of images along the Y axis (height). |
|
|
|
* 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). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setImagesY(int imagesY) { |
|
|
|
public void setImagesY(int imagesY) { |
|
|
|
this.imagesY = imagesY; |
|
|
|
this.imagesY = imagesY; |
|
|
|
particleMesh.setImagesXY(this.imagesX, this.imagesY); |
|
|
|
particleMesh.setImagesXY(this.imagesX, this.imagesY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the low value of life. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the low value of life. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setLowLife(float) |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getLowLife() { |
|
|
|
public float getLowLife() { |
|
|
|
return lowLife; |
|
|
|
return lowLife; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param lowLife Set the low value of life. The particle's lifetime/expiration |
|
|
|
* Set the low value of life. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setLowLife(float lowLife) { |
|
|
|
public void setLowLife(float lowLife) { |
|
|
|
this.lowLife = lowLife; |
|
|
|
this.lowLife = lowLife; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the number of particles to spawn per |
|
|
|
|
|
|
|
* second. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the number of particles to spawn per |
|
|
|
|
|
|
|
* second. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setParticlesPerSec(float) |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getParticlesPerSec() { |
|
|
|
public float getParticlesPerSec() { |
|
|
|
return particlesPerSec; |
|
|
|
return particlesPerSec; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param particlesPerSec Set the number of particles to spawn per |
|
|
|
* Set the number of particles to spawn per |
|
|
|
|
|
|
|
* second. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param particlesPerSec the number of particles to spawn per |
|
|
|
* second. |
|
|
|
* second. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setParticlesPerSec(float particlesPerSec) { |
|
|
|
public void setParticlesPerSec(float particlesPerSec) { |
|
|
|
this.particlesPerSec = particlesPerSec; |
|
|
|
this.particlesPerSec = particlesPerSec; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the start color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the start color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setStartColor(com.jme3.math.ColorRGBA) |
|
|
|
|
|
|
|
*/ |
|
|
|
public ColorRGBA getStartColor() { |
|
|
|
public ColorRGBA getStartColor() { |
|
|
|
return startColor; |
|
|
|
return startColor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param startColor Set the start color of the particles spawned. The |
|
|
|
* Set the start color of the particles spawned. |
|
|
|
* 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 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setStartColor(ColorRGBA startColor) { |
|
|
|
public void setStartColor(ColorRGBA startColor) { |
|
|
|
this.startColor.set(startColor); |
|
|
|
this.startColor.set(startColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the start color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the start color of the particles spawned. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setStartSize(float) |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getStartSize() { |
|
|
|
public float getStartSize() { |
|
|
|
return startSize; |
|
|
|
return startSize; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param startSize Set the start size of the particles spawned.The |
|
|
|
* Set the start size of the particles spawned. |
|
|
|
* 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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setStartSize(float startSize) { |
|
|
|
public void setStartSize(float startSize) { |
|
|
|
this.startSize = startSize; |
|
|
|
this.startSize = startSize; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method is deprecated. |
|
|
|
* @deprecated Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead. |
|
|
|
* Use ParticleEmitter.getParticleInfluencer().getInitialVelocity() instead. |
|
|
|
|
|
|
|
* @return the initial velocity for particles |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
|
public Vector3f getInitialVelocity() { |
|
|
|
public Vector3f getInitialVelocity() { |
|
|
@ -531,7 +781,6 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
// return -1;
|
|
|
|
// return -1;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// private void freeIndex(int index){
|
|
|
|
// private void freeIndex(int index){
|
|
|
|
// liveParticles--;
|
|
|
|
// liveParticles--;
|
|
|
|
// if (index == next-1)
|
|
|
|
// if (index == next-1)
|
|
|
@ -540,7 +789,6 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
// assert !unusedIndices.contains(index);
|
|
|
|
// assert !unusedIndices.contains(index);
|
|
|
|
// unusedIndices.add(index);
|
|
|
|
// unusedIndices.add(index);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
private boolean emitParticle(Vector3f min, Vector3f max) { |
|
|
|
private boolean emitParticle(Vector3f min, Vector3f max) { |
|
|
|
// int idx = newIndex();
|
|
|
|
// int idx = newIndex();
|
|
|
|
// if (idx == -1)
|
|
|
|
// if (idx == -1)
|
|
|
@ -680,7 +928,7 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// position += velocity * tpf
|
|
|
|
// position += velocity * tpf
|
|
|
|
p.distToCam = -1; |
|
|
|
//p.distToCam = -1;
|
|
|
|
|
|
|
|
|
|
|
|
// applying gravity
|
|
|
|
// applying gravity
|
|
|
|
p.velocity.x -= gravity.x * tpf; |
|
|
|
p.velocity.x -= gravity.x * tpf; |
|
|
@ -735,35 +983,45 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Do not use. |
|
|
|
* Set to enable or disable the particle emitter |
|
|
|
*/ |
|
|
|
* |
|
|
|
@Override |
|
|
|
* <p>When a particle is |
|
|
|
public void setSpatial(Spatial spatial) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param enabled Set to enable or disable a particle. 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 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
|
|
|
|
public void setEnabled(boolean enabled) { |
|
|
|
public void setEnabled(boolean enabled) { |
|
|
|
this.enabled = enabled; |
|
|
|
this.enabled = enabled; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
|
|
|
|
* Check if a particle emitter is enabled for update. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return True if a particle emitter is enabled for update. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see ParticleEmitter#setEnabled(boolean) |
|
|
|
|
|
|
|
*/ |
|
|
|
public boolean isEnabled() { |
|
|
|
public boolean isEnabled() { |
|
|
|
return enabled; |
|
|
|
return enabled; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
public void update(float tpf) { |
|
|
|
* Callback from Control.update(), do not use. |
|
|
|
|
|
|
|
* @param tpf |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void updateFromControl(float tpf) { |
|
|
|
if (enabled) { |
|
|
|
if (enabled) { |
|
|
|
this.updateParticleState(tpf); |
|
|
|
this.updateParticleState(tpf); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
public void render(RenderManager rm, ViewPort vp) { |
|
|
|
* Callback from Control.render(), do not use. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param rm |
|
|
|
|
|
|
|
* @param vp |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void renderFromControl(RenderManager rm, ViewPort vp) { |
|
|
|
Camera cam = vp.getCamera(); |
|
|
|
Camera cam = vp.getCamera(); |
|
|
|
|
|
|
|
|
|
|
|
if (meshType == ParticleMesh.Type.Point) { |
|
|
|
if (meshType == ParticleMesh.Type.Point) { |
|
|
@ -862,5 +1120,4 @@ public class ParticleEmitter extends Geometry implements Control { |
|
|
|
|
|
|
|
|
|
|
|
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER); |
|
|
|
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|