Search in sources :

Example 1 with EmitterBoxShape

use of com.jme3.effect.shapes.EmitterBoxShape in project jmonkeyengine by jMonkeyEngine.

the class TestPointSprite method simpleInitApp.

@Override
public void simpleInitApp() {
    final ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Point, 10000);
    emit.setShape(new EmitterBoxShape(new Vector3f(-1.8f, -1.8f, -1.8f), new Vector3f(1.8f, 1.8f, 1.8f)));
    emit.setGravity(0, 0, 0);
    emit.setLowLife(60);
    emit.setHighLife(60);
    emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    emit.setStartSize(0.05f);
    emit.setEndSize(0.05f);
    emit.setStartColor(ColorRGBA.White);
    emit.setEndColor(ColorRGBA.White);
    emit.setSelectRandomImage(true);
    emit.emitAllParticles();
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setBoolean("PointSprite", true);
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    rootNode.attachChild(emit);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if ("setNum".equals(name) && isPressed) {
                emit.setNumParticles(5000);
                emit.emitAllParticles();
            }
        }
    }, "setNum");
    inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ActionListener(com.jme3.input.controls.ActionListener) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) EmitterBoxShape(com.jme3.effect.shapes.EmitterBoxShape) Material(com.jme3.material.Material)

Aggregations

ParticleEmitter (com.jme3.effect.ParticleEmitter)1 EmitterBoxShape (com.jme3.effect.shapes.EmitterBoxShape)1 ActionListener (com.jme3.input.controls.ActionListener)1 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 Material (com.jme3.material.Material)1 Vector3f (com.jme3.math.Vector3f)1