Search in sources :

Example 6 with ParticleEmitter

use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.

the class TestExplosionEffect method createRoundSpark.

private void createRoundSpark() {
    roundspark = new ParticleEmitter("RoundSpark", EMITTER_TYPE, 20 * COUNT_FACTOR);
    roundspark.setStartColor(new ColorRGBA(1f, 0.29f, 0.34f, (float) (1.0 / COUNT_FACTOR_F)));
    roundspark.setEndColor(new ColorRGBA(0, 0, 0, (float) (0.5f / COUNT_FACTOR_F)));
    roundspark.setStartSize(1.2f);
    roundspark.setEndSize(1.8f);
    roundspark.setShape(new EmitterSphereShape(Vector3f.ZERO, 2f));
    roundspark.setParticlesPerSec(0);
    roundspark.setGravity(0, -.5f, 0);
    roundspark.setLowLife(1.8f);
    roundspark.setHighLife(2f);
    roundspark.setInitialVelocity(new Vector3f(0, 3, 0));
    roundspark.setVelocityVariation(.5f);
    roundspark.setImagesX(1);
    roundspark.setImagesY(1);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/roundspark.png"));
    mat.setBoolean("PointSprite", POINT_SPRITE);
    roundspark.setMaterial(mat);
    explosionEffect.attachChild(roundspark);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) EmitterSphereShape(com.jme3.effect.shapes.EmitterSphereShape) Material(com.jme3.material.Material)

Example 7 with ParticleEmitter

use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.

the class TestExplosionEffect method createSpark.

private void createSpark() {
    spark = new ParticleEmitter("Spark", Type.Triangle, 30 * COUNT_FACTOR);
    spark.setStartColor(new ColorRGBA(1f, 0.8f, 0.36f, (float) (1.0f / COUNT_FACTOR_F)));
    spark.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f));
    spark.setStartSize(.5f);
    spark.setEndSize(.5f);
    spark.setFacingVelocity(true);
    spark.setParticlesPerSec(0);
    spark.setGravity(0, 5, 0);
    spark.setLowLife(1.1f);
    spark.setHighLife(1.5f);
    spark.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 20, 0));
    spark.getParticleInfluencer().setVelocityVariation(1);
    spark.setImagesX(1);
    spark.setImagesY(1);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/spark.png"));
    spark.setMaterial(mat);
    explosionEffect.attachChild(spark);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material)

Example 8 with ParticleEmitter

use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.

the class TestMovingParticle method simpleInitApp.

@Override
public void simpleInitApp() {
    emit = new ParticleEmitter("Emitter", Type.Triangle, 300);
    emit.setGravity(0, 0, 0);
    emit.setVelocityVariation(1);
    emit.setLowLife(1);
    emit.setHighLife(1);
    emit.setInitialVelocity(new Vector3f(0, .5f, 0));
    emit.setImagesX(15);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    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(1000);
            }
        }
    }, "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) Material(com.jme3.material.Material)

Example 9 with ParticleEmitter

use of com.jme3.effect.ParticleEmitter in project jmonkeyengine by jMonkeyEngine.

the class TestParticleExportingCloning method simpleInitApp.

@Override
public void simpleInitApp() {
    ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Triangle, 200);
    emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
    emit.setGravity(0, 0, 0);
    emit.setLowLife(5);
    emit.setHighLife(10);
    emit.setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    ParticleEmitter emit2 = emit.clone();
    emit2.move(3, 0, 0);
    rootNode.attachChild(emit);
    rootNode.attachChild(emit2);
    ParticleEmitter emit3 = BinaryExporter.saveAndLoad(assetManager, emit);
    emit3.move(-3, 0, 0);
    rootNode.attachChild(emit3);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) Vector3f(com.jme3.math.Vector3f) EmitterSphereShape(com.jme3.effect.shapes.EmitterSphereShape) Material(com.jme3.material.Material)

Example 10 with ParticleEmitter

use of com.jme3.effect.ParticleEmitter 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)20 Material (com.jme3.material.Material)17 Vector3f (com.jme3.math.Vector3f)15 ColorRGBA (com.jme3.math.ColorRGBA)13 EmitterSphereShape (com.jme3.effect.shapes.EmitterSphereShape)7 Spatial (com.jme3.scene.Spatial)4 ActionListener (com.jme3.input.controls.ActionListener)3 KeyTrigger (com.jme3.input.controls.KeyTrigger)3 EmitterMeshVertexShape (com.jme3.effect.shapes.EmitterMeshVertexShape)2 InputCapsule (com.jme3.export.InputCapsule)2 Geometry (com.jme3.scene.Geometry)2 Node (com.jme3.scene.Node)2 VertexBuffer (com.jme3.scene.VertexBuffer)2 ByteBuffer (java.nio.ByteBuffer)2 FloatBuffer (java.nio.FloatBuffer)2 Type (com.jme3.effect.ParticleMesh.Type)1 EmptyParticleInfluencer (com.jme3.effect.influencers.EmptyParticleInfluencer)1 NewtonianParticleInfluencer (com.jme3.effect.influencers.NewtonianParticleInfluencer)1 ParticleInfluencer (com.jme3.effect.influencers.ParticleInfluencer)1 EmitterBoxShape (com.jme3.effect.shapes.EmitterBoxShape)1