Java Code Examples for com.jme3.effect.ParticleEmitter#setSelectRandomImage()

The following examples show how to use com.jme3.effect.ParticleEmitter#setSelectRandomImage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BombControl.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void prepareEffect(AssetManager assetManager) {
    int COUNT_FACTOR = 1;
    float COUNT_FACTOR_F = 1f;
    effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
    effect.setSelectRandomImage(true);
    effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (1f / COUNT_FACTOR_F)));
    effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
    effect.setStartSize(1.3f);
    effect.setEndSize(2f);
    effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
    effect.setParticlesPerSec(0);
    effect.setGravity(0, -5f, 0);
    effect.setLowLife(.4f);
    effect.setHighLife(.5f);
    effect.getParticleInfluencer()
            .setInitialVelocity(new Vector3f(0, 7, 0));
    effect.getParticleInfluencer().setVelocityVariation(1f);
    effect.setImagesX(2);
    effect.setImagesY(2);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
    effect.setMaterial(mat);
}
 
Example 2
Source File: TestWalkingChar.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void prepareEffect() {
        int COUNT_FACTOR = 1;
        float COUNT_FACTOR_F = 1f;
        effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
        effect.setSelectRandomImage(true);
        effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (1f / COUNT_FACTOR_F)));
        effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
        effect.setStartSize(1.3f);
        effect.setEndSize(2f);
        effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
        effect.setParticlesPerSec(0);
        effect.setGravity(0, -5, 0);
        effect.setLowLife(.4f);
        effect.setHighLife(.5f);
        effect.getParticleInfluencer()
                .setInitialVelocity(new Vector3f(0, 7, 0));
        effect.getParticleInfluencer().setVelocityVariation(1f);
        effect.setImagesX(2);
        effect.setImagesY(2);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
        mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
        effect.setMaterial(mat);
//        effect.setLocalScale(100);
        rootNode.attachChild(effect);
    }
 
Example 3
Source File: TestExplosionEffect.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void createFlame(){
    flame = new ParticleEmitter("Flame", EMITTER_TYPE, 32 * COUNT_FACTOR);
    flame.setSelectRandomImage(true);
    flame.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (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);
}
 
Example 4
Source File: TestExplosionEffect.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void createFlash(){
    flash = new ParticleEmitter("Flash", EMITTER_TYPE, 24 * COUNT_FACTOR);
    flash.setSelectRandomImage(true);
    flash.setStartColor(new ColorRGBA(1f, 0.8f, 0.36f, 1f / COUNT_FACTOR_F));
    flash.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f));
    flash.setStartSize(.1f);
    flash.setEndSize(3.0f);
    flash.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f));
    flash.setParticlesPerSec(0);
    flash.setGravity(0, 0, 0);
    flash.setLowLife(.2f);
    flash.setHighLife(.2f);
    flash.getParticleInfluencer()
            .setInitialVelocity(new Vector3f(0, 5f, 0));
    flash.getParticleInfluencer().setVelocityVariation(1);
    flash.setImagesX(2);
    flash.setImagesY(2);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flash.png"));
    mat.setBoolean("PointSprite", POINT_SPRITE);
    flash.setMaterial(mat);
    explosionEffect.attachChild(flash);
}
 
Example 5
Source File: TestExplosionEffect.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void createDebris(){
        debris = new ParticleEmitter("Debris", Type.Triangle, 15 * COUNT_FACTOR);
        debris.setSelectRandomImage(true);
        debris.setRandomAngle(true);
        debris.setRotateSpeed(FastMath.TWO_PI * 4);
        debris.setStartColor(new ColorRGBA(1f, 0.59f, 0.28f, 1.0f / COUNT_FACTOR_F));
        debris.setEndColor(new ColorRGBA(.5f, 0.5f, 0.5f, 0f));
        debris.setStartSize(.2f);
        debris.setEndSize(.2f);

//        debris.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f));
        debris.setParticlesPerSec(0);
        debris.setGravity(0, 12f, 0);
        debris.setLowLife(1.4f);
        debris.setHighLife(1.5f);
        debris.getParticleInfluencer()
                .setInitialVelocity(new Vector3f(0, 15, 0));
        debris.getParticleInfluencer().setVelocityVariation(.60f);
        debris.setImagesX(3);
        debris.setImagesY(3);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
        mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/Debris.png"));
        debris.setMaterial(mat);
        explosionEffect.attachChild(debris);
    }
 
Example 6
Source File: BombControl.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void prepareEffect(AssetManager assetManager) {
    int COUNT_FACTOR = 1;
    float COUNT_FACTOR_F = 1f;
    effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
    effect.setSelectRandomImage(true);
    effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F)));
    effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
    effect.setStartSize(1.3f);
    effect.setEndSize(2f);
    effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
    effect.setParticlesPerSec(0);
    effect.setGravity(0, -5f, 0);
    effect.setLowLife(.4f);
    effect.setHighLife(.5f);
    effect.setInitialVelocity(new Vector3f(0, 7, 0));
    effect.setVelocityVariation(1f);
    effect.setImagesX(2);
    effect.setImagesY(2);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
    effect.setMaterial(mat);
}
 
Example 7
Source File: TestWalkingChar.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void prepareEffect() {
        int COUNT_FACTOR = 1;
        float COUNT_FACTOR_F = 1f;
        effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
        effect.setSelectRandomImage(true);
        effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F)));
        effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
        effect.setStartSize(1.3f);
        effect.setEndSize(2f);
        effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
        effect.setParticlesPerSec(0);
        effect.setGravity(0, -5, 0);
        effect.setLowLife(.4f);
        effect.setHighLife(.5f);
        effect.setInitialVelocity(new Vector3f(0, 7, 0));
        effect.setVelocityVariation(1f);
        effect.setImagesX(2);
        effect.setImagesY(2);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
        mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
        effect.setMaterial(mat);
//        effect.setLocalScale(100);
        rootNode.attachChild(effect);
    }
 
Example 8
Source File: TestExplosionEffect.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
}
 
Example 9
Source File: TestExplosionEffect.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createFlash(){
    flash = new ParticleEmitter("Flash", EMITTER_TYPE, 24 * COUNT_FACTOR);
    flash.setSelectRandomImage(true);
    flash.setStartColor(new ColorRGBA(1f, 0.8f, 0.36f, (float) (1f / COUNT_FACTOR_F)));
    flash.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f));
    flash.setStartSize(.1f);
    flash.setEndSize(3.0f);
    flash.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f));
    flash.setParticlesPerSec(0);
    flash.setGravity(0, 0, 0);
    flash.setLowLife(.2f);
    flash.setHighLife(.2f);
    flash.setInitialVelocity(new Vector3f(0, 5f, 0));
    flash.setVelocityVariation(1);
    flash.setImagesX(2);
    flash.setImagesY(2);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flash.png"));
    mat.setBoolean("PointSprite", POINT_SPRITE);
    flash.setMaterial(mat);
    explosionEffect.attachChild(flash);
}
 
Example 10
Source File: TestExplosionEffect.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void createDebris(){
        debris = new ParticleEmitter("Debris", Type.Triangle, 15 * COUNT_FACTOR);
        debris.setSelectRandomImage(true);
        debris.setRandomAngle(true);
        debris.setRotateSpeed(FastMath.TWO_PI * 4);
        debris.setStartColor(new ColorRGBA(1f, 0.59f, 0.28f, (float) (1.0f / COUNT_FACTOR_F)));
        debris.setEndColor(new ColorRGBA(.5f, 0.5f, 0.5f, 0f));
        debris.setStartSize(.2f);
        debris.setEndSize(.2f);

//        debris.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f));
        debris.setParticlesPerSec(0);
        debris.setGravity(0, 12f, 0);
        debris.setLowLife(1.4f);
        debris.setHighLife(1.5f);
        debris.setInitialVelocity(new Vector3f(0, 15, 0));
        debris.setVelocityVariation(.60f);
        debris.setImagesX(3);
        debris.setImagesY(3);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
        mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/Debris.png"));
        debris.setMaterial(mat);
        explosionEffect.attachChild(debris);
    }
 
Example 11
Source File: TestPointSprite.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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() {
        
        @Override
        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));
    
}
 
Example 12
Source File: TestPointSprite.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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));
    
}
 
Example 13
Source File: HelloEffects.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
  public void simpleInitApp() {
    ParticleEmitter fire = 
            new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
    Material mat_red = new Material(assetManager, 
            "Common/MatDefs/Misc/Particle.j3md");
    mat_red.setTexture("Texture", assetManager.loadTexture(
            "Effects/Explosion/flame.png"));
    fire.setMaterial(mat_red);
    fire.setImagesX(2); 
    fire.setImagesY(2); // 2x2 texture animation
    fire.setEndColor(  new ColorRGBA(1f, 0f, 0f, 1f));   // red
    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
    fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
    fire.setStartSize(1.5f);
    fire.setEndSize(0.1f);
    fire.setGravity(0, 0, 0);
    fire.setLowLife(1f);
    fire.setHighLife(3f);
    fire.getParticleInfluencer().setVelocityVariation(0.3f);
    rootNode.attachChild(fire);

    ParticleEmitter debris = 
            new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10);
    Material debris_mat = new Material(assetManager, 
            "Common/MatDefs/Misc/Particle.j3md");
    debris_mat.setTexture("Texture", assetManager.loadTexture(
            "Effects/Explosion/Debris.png"));
    debris.setMaterial(debris_mat);
    debris.setImagesX(3); 
    debris.setImagesY(3); // 3x3 texture animation
    debris.setSelectRandomImage(true);
    debris.setRotateSpeed(4);
    debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 4, 0));
    debris.setStartColor(ColorRGBA.White);
    debris.setGravity(0, 6, 0);
    debris.getParticleInfluencer().setVelocityVariation(.60f);
    rootNode.attachChild(debris);
    debris.emitAllParticles();

//    ParticleEmitter water = 
//            new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 20);
//    Material mat_blue = new Material(assetManager, 
//            "Common/MatDefs/Misc/Particle.j3md");
//    mat_blue.setTexture("Texture", assetManager.loadTexture(
//            "Effects/Explosion/flame.png"));
//    water.setMaterial(mat_blue);
//    water.setImagesX(2); 
//    water.setImagesY(2); // 2x2 texture animation
//    water.setStartColor( ColorRGBA.Blue); 
//    water.setEndColor( ColorRGBA.Cyan); 
//    water.getParticleInfluencer().setInitialVelocity(new Vector3f(0, -4, 0));
//    water.setStartSize(1f);
//    water.setEndSize(1.5f);
//    water.setGravity(0,1,0);
//    water.setLowLife(1f);
//    water.setHighLife(1f);
//    water.getParticleInfluencer().setVelocityVariation(0.1f);
//    water.setLocalTranslation(0, 6, 0);
//    rootNode.attachChild(water);

  }
 
Example 14
Source File: HelloEffects.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
  public void simpleInitApp() {
    ParticleEmitter fire = 
            new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
    Material mat_red = new Material(assetManager, 
            "Common/MatDefs/Misc/Particle.j3md");
    mat_red.setTexture("Texture", assetManager.loadTexture(
            "Effects/Explosion/flame.png"));
    fire.setMaterial(mat_red);
    fire.setImagesX(2); 
    fire.setImagesY(2); // 2x2 texture animation
    fire.setEndColor(  new ColorRGBA(1f, 0f, 0f, 1f));   // red
    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
    fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
    fire.setStartSize(1.5f);
    fire.setEndSize(0.1f);
    fire.setGravity(0, 0, 0);
    fire.setLowLife(1f);
    fire.setHighLife(3f);
    fire.getParticleInfluencer().setVelocityVariation(0.3f);
    rootNode.attachChild(fire);

    ParticleEmitter debris = 
            new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10);
    Material debris_mat = new Material(assetManager, 
            "Common/MatDefs/Misc/Particle.j3md");
    debris_mat.setTexture("Texture", assetManager.loadTexture(
            "Effects/Explosion/Debris.png"));
    debris.setMaterial(debris_mat);
    debris.setImagesX(3); 
    debris.setImagesY(3); // 3x3 texture animation
    debris.setSelectRandomImage(true);
    debris.setRotateSpeed(4);
    debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 4, 0));
    debris.setStartColor(ColorRGBA.White);
    debris.setGravity(0, 6, 0);
    debris.getParticleInfluencer().setVelocityVariation(.60f);
    rootNode.attachChild(debris);
    debris.emitAllParticles();

//    ParticleEmitter water = 
//            new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 20);
//    Material mat_blue = new Material(assetManager, 
//            "Common/MatDefs/Misc/Particle.j3md");
//    mat_blue.setTexture("Texture", assetManager.loadTexture(
//            "Effects/Explosion/flame.png"));
//    water.setMaterial(mat_blue);
//    water.setImagesX(2); 
//    water.setImagesY(2); // 2x2 texture animation
//    water.setStartColor( ColorRGBA.Blue); 
//    water.setEndColor( ColorRGBA.Cyan); 
//    water.getParticleInfluencer().setInitialVelocity(new Vector3f(0, -4, 0));
//    water.setStartSize(1f);
//    water.setEndSize(1.5f);
//    water.setGravity(0,1,0);
//    water.setLowLife(1f);
//    water.setHighLife(1f);
//    water.getParticleInfluencer().setVelocityVariation(0.1f);
//    water.setLocalTranslation(0, 6, 0);
//    rootNode.attachChild(water);

  }