TestBatchParticles and ForceRespawn

Inside TestBatchParticles class the ParticleFactory is using the following settings

        pMesh = ParticleFactory.buildBatchParticles("particles", sphere.getBatch(0));
        pMesh.setEmissionDirection(new Vector3f(1, 1, 1));
        pMesh.setOriginOffset(new Vector3f(0, 0, 0));
        pMesh.setStartColor(new ColorRGBA(1, 1, 1, 1));
        pMesh.setEndColor(new ColorRGBA(1, 1, 1, 0));
        pMesh.setMaximumAngle(0f * FastMath.DEG_TO_RAD);
        pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);
        wind = SimpleParticleInfluenceFactory.createBasicWind(.008f, new Vector3f(-1, 0, 0), true, true);

Whenever I comment pMesh.forceRespawn, the particles still respawn. Is that correct? If so, how can I make the particles respawn just once?

forceRespawn just recreates all particles geometry and sets them to be viable…  I think what you are looking for is the flow control settings.  If you pull up the RenParticleEditor and play around with enabling flow control and setting the release rate to 0, then to 50, then to 0… etc. I think that will be closer to what you are looking for.

I've checked the release rate in TestBatchParticles but it's 0 all the time, even when its "spreading particles". Changing the number of particles that get released per second to 0, results in all particles being frozen (even though in your editor they all disappear).

What I hope to achieve is a shattering effect where the particles "explode" just once from their origin.

In your editor there is a "Respawn 'dead' particles" checkbox. I want to disable that and do a "Force Respawn" once.

I see…  Hmm… simply taking the existing test and adding the following line works for me:


The mesh is still there though, as you say... although you can't see it because the end alpha is 0.

I should mention that you can register a ParticleControllerListener with the particle system's controller to remove it from the scene.  Here's an example to show you what I mean:

         pMesh.setMaximumAngle(0f * FastMath.DEG_TO_RAD);
         pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);
+        pMesh.setRepeatType(Controller.RT_CLAMP);
+        ParticleControllerListener remover = new ParticleControllerListener() {
+            public void onDead(ParticleGeometry particles) {
+                pMesh.removeFromParent();
+            }
+        };
+        pMesh.getParticleController().addListener(remover);
         wind = SimpleParticleInfluenceFactory.createBasicWind(.008f, new Vector3f(-1, 0, 0), true, true);