private void addEmitter( float[] colors, Texture particleTexture, Vector3 translation, Vector3 actionAxis, float actionRotation){ ParticleController controller = createBillboardController(colors, particleTexture); controller.init(); controller.start(); emitters.add(controller); controller.translate(translation); ui.addAction(new RotationAction(controller, actionAxis, actionRotation)); }
@Override public void dispose () { if (controller != null) { for (int i = 0; i < controller.particles.size; ++i) { ParticleController controller = particleControllerChannel.data[i]; if (controller != null) { controller.dispose(); particleControllerChannel.data[i] = null; } } } }
@Override public void update () { for (int i = 0, positionOffset = 0, c = controller.particles.size; i < c; ++i, positionOffset += positionChannel.strideSize) { ParticleController particleController = controllerChannel.data[i]; float scale = hasScale ? scaleChannel.data[i] : 1; float qx = 0, qy = 0, qz = 0, qw = 1; if (hasRotation) { int rotationOffset = i * rotationChannel.strideSize; qx = rotationChannel.data[rotationOffset + ParticleChannels.XOffset]; qy = rotationChannel.data[rotationOffset + ParticleChannels.YOffset]; qz = rotationChannel.data[rotationOffset + ParticleChannels.ZOffset]; qw = rotationChannel.data[rotationOffset + ParticleChannels.WOffset]; } particleController.setTransform(positionChannel.data[positionOffset + ParticleChannels.XOffset], positionChannel.data[positionOffset + ParticleChannels.YOffset], positionChannel.data[positionOffset + ParticleChannels.ZOffset], qx, qy, qz, qw, scale); particleController.update(); } }
/** @return a copy of this controller */ public ParticleController copy () { Emitter emitter = (Emitter)this.emitter.copy(); Influencer[] influencers = new Influencer[this.influencers.size]; int i = 0; for (Influencer influencer : this.influencers) { influencers[i++] = (Influencer)influencer.copy(); } return new ParticleController(new String(this.name), emitter, (ParticleControllerRenderer<?, ?>)renderer.copy(), influencers); }
protected void addInfluencer (Class<Influencer> type, ParticleController controller) { if(controller.findInfluencer(type) != null) return; controller.end(); replaced = controller.replaceInfluencer(ColorInfluencer.class, (ColorInfluencer)newInfluencer); replaced = controller.replaceInfluencer(RegionInfluencer.class, (RegionInfluencer)newInfluencer); ModelInfluencer currentInfluencer = (ModelInfluencer)controller.findInfluencer(ModelInfluencer.class); if(currentInfluencer != null){ newModelInfluencer.models.add(currentInfluencer.models.first()); replaced = controller.replaceInfluencer(ModelInfluencer.class, (ModelInfluencer)newInfluencer); ParticleControllerInfluencer currentInfluencer = (ParticleControllerInfluencer)controller.findInfluencer(ParticleControllerInfluencer.class); if(currentInfluencer != null){ newModelInfluencer.templates.add(currentInfluencer.templates.first()); replaced = controller.replaceInfluencer(ParticleControllerInfluencer.class, (ParticleControllerInfluencer)newInfluencer); controller.init(); effect.start(); reloadRows();
@Override public void activateParticles (int startIndex, int count) { for (int i = startIndex, c = startIndex + count; i < c; ++i) { particleControllerChannel.data[i].start(); } }
@Override public void killParticles (int startIndex, int count) { for (int i = startIndex, c = startIndex + count; i < c; ++i) { particleControllerChannel.data[i].end(); } }
/** Initialize the controller. All the sub systems will be initialized and binded to the controller. Must be called before any * other method. */ public void init () { bind(); if (particles != null) { end(); particleChannels.resetIds(); } allocateChannels(emitter.maxParticleCount); emitter.init(); for (Influencer influencer : influencers) influencer.init(); renderer.init(); }
public void init () { for (int i = 0, n = controllers.size; i < n; i++) controllers.get(i).init(); }
} else { if (continuous && emit && emissionMode == EmissionMode.Enabled) controller.start(); else emit = false; controller.killParticles(controller.particles.size, activeParticles - controller.particles.size);
/** Updates the particles data */ public void update () { update(Gdx.graphics.getDeltaTime()); }
@Override public void update () { for (int i = 0, c = controller.particles.size; i < c; ++i) { controllerChannel.data[i].draw(); } }
@Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { if(emitters.size > 0){ //Update float delta = Gdx.graphics.getDeltaTime(); builder.delete(0, builder.length()); builder.append(Gdx.graphics.getFramesPerSecond()); fpsLabel.setText(builder); ui.act(delta); billboardParticleBatch.begin(); for (ParticleController controller : emitters){ controller.update(); controller.draw(); } billboardParticleBatch.end(); batch.render(billboardParticleBatch, environment); } batch.render(instances, environment); ui.draw(); } }
public ParticleEffect (ParticleEffect effect) { controllers = new Array<ParticleController>(true, effect.controllers.size); for (int i = 0, n = effect.controllers.size; i < n; i++) controllers.add(effect.controllers.get(i).copy()); }
@Override public boolean act (float delta) { emitter.getTransform(tmpMatrix); tmpQuaternion.set(axis, angle*delta).toMatrix(tmpMatrix4.val); tmpMatrix4.mul(tmpMatrix); emitter.setTransform(tmpMatrix4); return false; } }
/** Sets the given transform matrix on each controller. */ public void setTransform (Matrix4 transform) { for (int i = 0, n = controllers.size; i < n; i++) controllers.get(i).setTransform(transform); }
/** Applies the translation to the current transformation matrix of each controller. */ public void translate (Vector3 translation) { for (int i = 0, n = controllers.size; i < n; i++) controllers.get(i).translate(translation); }