Particle Fire jme3 - Java Game

Java examples for Game:JME3

Description

Particle Fire jme3

Demo Code

package Effects;/*  w w w .  j  ava2 s. c  o  m*/

import template.*;
import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

/**
 * test
 *
 * @author normenhansen
 */
public class Particle6Fire extends SimpleApplication {

    public static void main(String[] args) {
        Particle6Fire app = new Particle6Fire();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        ParticleEmitter fireEmitter = new ParticleEmitter("Emitter",
                ParticleMesh.Type.Triangle, 30);
        Material fireMat = new Material(assetManager,
                "Common/MatDefs/Misc/Particle.j3md");
        rootNode.attachChild(fireEmitter);

        fireMat.setTexture("Texture",
                assetManager.loadTexture("Effects/flame.png"));
        fireEmitter.setMaterial(fireMat);
        fireEmitter.setImagesX(2);
        fireEmitter.setImagesY(2);
        fireEmitter.setSelectRandomImage(true);
        fireEmitter.setRandomAngle(true);

        fireEmitter.setStartColor(new ColorRGBA(1f, 1f, .5f, 1f));
        fireEmitter.setEndColor(new ColorRGBA(1f, 0f, 0f, 0f));

        fireEmitter.setGravity(0, 0, 0);
        fireEmitter.getParticleInfluencer().setVelocityVariation(0.2f);
        fireEmitter.getParticleInfluencer().setInitialVelocity(
                new Vector3f(0, 3f, 0));

        fireEmitter.setLowLife(0.5f);
        fireEmitter.setHighLife(2f);
        fireEmitter.setStartSize(1.5f);
        fireEmitter.setEndSize(0.05f);
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

Related Tutorials