I’m trying to incorporate the explosion effect in from TestExplosionEffect (in the jme tests project) into my project. I’ve pretty much copy and pasted the code straight from there… THis is what the code looks like from one of the particle emitters… (the entire “effect” is made up of about 5 emitters all added to the explosionEffect Node)
[java] private void createFlame(){
flame = new ParticleEmitter(“Flame”, EMITTER_TYPE, 32 * COUNT_FACTOR);
flame.setSelectRandomImage(true);
flame.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F)));
flame.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
flame.setStartSize(1.3f);
flame.setEndSize(2f);
flame.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
flame.setParticlesPerSec(0);
flame.setGravity(0, -5, 0);
flame.setLowLife(.4f);
flame.setHighLife(.5f);
flame.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 7, 0));
flame.getParticleInfluencer().setVelocityVariation(1f);
flame.setImagesX(2);
flame.setImagesY(2);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Particle.j3md”);
mat.setTexture(“Texture”, assetManager.loadTexture(“Effects/Explosion/flame.png”));
mat.setBoolean(“PointSprite”, POINT_SPRITE);
flame.setMaterial(mat);
explosionEffect.attachChild(flame);
}[/java]
The way I want to use it is I want the emitter to give off a single “explosion” I’m using this together with a system of throwable objects, i want them to explode when they hit the ground.
I have the code working. but I noticed that my game’s stats were horrible after setting the scene up.Link to screen shot
The switching stat of the textures and the shaders are about 3 times the value of the frame stat. This also shows up in my FPS which is about 350. without the explosionEffect Node’s attached to the cans and cups the Switching value is the same as the Frame value. and my FPS is around 600-700. So I believe this tells me the issue is related to the particle emitters…
What I’ve tried so far is to have each particle emitter disabled at first. Then I would enable it before calling emitAllParticles(). This keeps the switching stat from being high before the explosion. However after the explosion it stays high. I’ve tried doing setEnabled(false) after the explosion is over, but the texture/shader switching stats are still high.
Does anyone have any solutions to this problem?