private void stop() { emitter.setParticlesPerSec(0); emitted = false; if (!killParticles.stopRequested) { emitter.addControl(killParticles); killParticles.stopRequested = true; } }
/** * Set the number of images along the Y axis (height). * * <p>To determine how multiple particle images are selected and used, see the * {@link ParticleEmitter#setSelectRandomImage(boolean) } method. * * @param imagesY the number of images along the Y axis (height). */ public void setImagesY(int imagesY) { this.imagesY = imagesY; particleMesh.setImagesXY(this.imagesX, this.imagesY); }
/** * Callback from Control.update(), do not use. * @param tpf */ public void updateFromControl(float tpf) { if (enabled) { this.updateParticleState(tpf); } }
@Override protected void controlUpdate(float tpf) { if (remove) { emitter.removeControl(this); return; } if (emitter.getNumVisibleParticles() == 0) { emitter.setCullHint(CullHint.Always); emitter.setEnabled(false); emitter.removeControl(this); stopRequested = false; } }
/** * Sets the type of mesh used by the particle emitter. * @param meshType The mesh type to use */ public void setMeshType(ParticleMesh.Type meshType) { this.meshType = meshType; switch (meshType) { case Point: particleMesh = new ParticlePointMesh(); this.setMesh(particleMesh); break; case Triangle: particleMesh = new ParticleTriMesh(); this.setMesh(particleMesh); break; default: throw new IllegalStateException("Unrecognized particle type: " + meshType); } this.setNumParticles(particles.length); }
/** * Set the maximum amount of particles that * can exist at the same time with this emitter. * 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) { particles = new Particle[numParticles]; for (int i = 0; i < numParticles; i++) { particles[i] = new Particle(); } //We have to reinit the mesh's buffers with the new size particleMesh.initParticleData(this, particles.length); particleMesh.setImagesXY(this.imagesX, this.imagesY); firstUnUsed = 0; lastUsed = -1; }
public void preload(RenderManager rm, ViewPort vp) { this.updateParticleState(0); particleMesh.updateParticleData(particles, vp.getCamera(), Matrix3f.IDENTITY); }
private void setUserData(EffectTrack effectTrack) { //fetching the UserData TrackInfo. TrackInfo data = (TrackInfo) effectTrack.emitter.getUserData("TrackInfo"); //if it does not exist, we create it and attach it to the emitter. if (data == null) { data = new TrackInfo(); effectTrack.emitter.setUserData("TrackInfo", data); } //adding the given Track to the TrackInfo. data.addTrack(effectTrack); }
@Override public ParticleEmitter clone() { return clone(true); }
/** * Instantly kills all active particles, after this method is called, all * particles will be dead and no longer visible. */ public void killAllParticles() { for (int i = 0; i < particles.length; ++i) { if (particles[i].life > 0) { this.freeParticle(i); } } }
public boolean isEnabled() { return parentEmitter.isEnabled(); }
public void setEnabled(boolean enabled) { parentEmitter.setEnabled(enabled); }
public void update(float tpf) { parentEmitter.updateFromControl(tpf); }
/** * 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 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. * * @param worldSpace true if particles should spawn in world space. */ public void setInWorldSpace(boolean worldSpace) { this.setIgnoreTransform(worldSpace); this.worldSpace = worldSpace; }
@Override public void setImagesXY(int imagesX, int imagesY) { this.imagesX = imagesX; this.imagesY = imagesY; if (imagesX != 1 || imagesY != 1){ uniqueTexCoords = true; getBuffer(VertexBuffer.Type.TexCoord).setUsage(Usage.Stream); } }
/** * Instantly emits all the particles possible to be emitted. Any particles * which are currently inactive will be spawned immediately. */ public void emitAllParticles() { emitParticles(particles.length); }
/** * For serialization only. Do not use. */ public ParticleEmitter() { super(); setBatchHint(BatchHint.Never); }
@Override public void simpleUpdate(float tpf) { angle += tpf; angle %= FastMath.TWO_PI; float x = FastMath.cos(angle) * 2; float y = FastMath.sin(angle) * 2; emit.setLocalTranslation(x, 0, y); } }
/** * Set the number of images along the X axis (width). * * <p>To determine * how multiple particle images are selected and used, see the * {@link ParticleEmitter#setSelectRandomImage(boolean) } method. * * @param imagesX the number of images along the X axis (width). */ public void setImagesX(int imagesX) { this.imagesX = imagesX; particleMesh.setImagesXY(this.imagesX, this.imagesY); }
/** * Kills the particle at the given index. * * @param index The index of the particle to kill * @see #getParticles() */ public void killParticle(int index){ freeParticle(index); }