/** * stops an effect * * @param id */ public void stopEffect(long id) { EmitterData data = liveEmitters.get(id); data.emit.removeFromParent(); emitters.get(data.effectName).add(data.emit); List<Spatial> children = data.emit.getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext(); ) { Spatial spatial = it.next(); if (spatial instanceof AudioNode) { audioRenderer.stopSource((AudioNode) spatial); } else if (spatial instanceof ParticleEmitter) { ((ParticleEmitter) spatial).killAllParticles(); } } }
/** * plays an effect in the world * * @param id * @param effectName * @param location * @param endLocation * @param rotation * @param endRotation * @param time */ public void playEffect( long id, String effectName, Vector3f location, Vector3f endLocation, Quaternion rotation, Quaternion endRotation, float time) { if (liveEmitters.containsKey(id)) { Logger.getLogger(ClientEffectsManager.class.getName()) .log(Level.WARNING, "Trying to add effect with existing id"); return; } Node effect = getEffect(effectName); EmitterData data = new EmitterData(effect, id, effectName, location, endLocation, rotation, endRotation, time); effect.setLocalTranslation(location); effect.setLocalRotation(rotation); data.curTime = 0; data.time = time; List<Spatial> children = effect.getChildren(); for (Iterator<Spatial> it = children.iterator(); it.hasNext(); ) { Spatial spat = it.next(); if (spat instanceof ParticleEmitter) { ParticleEmitter emitter = (ParticleEmitter) spat; emitter.emitAllParticles(); } else if (spat instanceof AudioNode) { AudioNode audioNode = (AudioNode) spat; // audioNode.setStatus(AudioNode.Status.Playing); audioRenderer.playSource(audioNode); } } worldManager.getWorldRoot().attachChild(effect); if (id == -1) { putToNew(data); } else { data.id = id; liveEmitters.put(id, data); } }