Java examples for Game:JME3
Particle Dust Smoke in jme3
package Effects;/*from w w w .j a v a 2s .c om*/ import template.*; import com.jme3.app.SimpleApplication; import com.jme3.effect.ParticleEmitter; import com.jme3.effect.ParticleMesh.Type; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; 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 Particle1DustSmoke extends SimpleApplication { private ParticleEmitter dustEmitter; private float angle = 0; public static void main(String[] args) { Particle1DustSmoke app = new Particle1DustSmoke(); app.start(); } @Override public void simpleInitApp() { //Create dust emitter dustEmitter = new ParticleEmitter("dust emitter", Type.Triangle, 10); //Attatch material Material dustMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); dustEmitter.setMaterial(dustMat); //Set texture dustMat.setTexture("Texture", assetManager.loadTexture("Effects/smoke.png")); //Tell the emitter that there are 2 rows and two columns in the pic dustEmitter.setImagesX(2); dustEmitter.setImagesY(2); dustEmitter.setSelectRandomImage(true); dustEmitter.setRandomAngle(true); dustEmitter.getParticleInfluencer().setVelocityVariation(1f); rootNode.attachChild(dustEmitter); } @Override public void simpleUpdate(float tpf) { // make the emitter fly in circles angle += tpf; angle %= FastMath.TWO_PI; float x = FastMath.cos(angle) * 2; float y = FastMath.sin(angle) * 2; dustEmitter.setLocalTranslation(x, 0, y); //TODO: add update code } @Override public void simpleRender(RenderManager rm) { //TODO: add render code } }