Search in sources :

Example 21 with ParticleEmitter

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

the class TestExplosionEffect method createShockwave.

private void createShockwave() {
    shockwave = new ParticleEmitter("Shockwave", Type.Triangle, 1 * COUNT_FACTOR);
    //        shockwave.setRandomAngle(true);
    shockwave.setFaceNormal(Vector3f.UNIT_Y);
    shockwave.setStartColor(new ColorRGBA(.48f, 0.17f, 0.01f, (float) (.8f / COUNT_FACTOR_F)));
    shockwave.setEndColor(new ColorRGBA(.48f, 0.17f, 0.01f, 0f));
    shockwave.setStartSize(0f);
    shockwave.setEndSize(7f);
    shockwave.setParticlesPerSec(0);
    shockwave.setGravity(0, 0, 0);
    shockwave.setLowLife(0.5f);
    shockwave.setHighLife(0.5f);
    shockwave.setInitialVelocity(new Vector3f(0, 0, 0));
    shockwave.setVelocityVariation(0f);
    shockwave.setImagesX(1);
    shockwave.setImagesY(1);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/shockwave.png"));
    shockwave.setMaterial(mat);
    explosionEffect.attachChild(shockwave);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material)

Example 22 with ParticleEmitter

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

the class TestTransparentShadow method simpleInitApp.

public void simpleInitApp() {
    cam.setLocation(new Vector3f(5.700248f, 6.161693f, 5.1404157f));
    cam.setRotation(new Quaternion(-0.09441641f, 0.8993388f, -0.24089815f, -0.35248178f));
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
    TangentBinormalGenerator.generate(q);
    Geometry geom = new Geometry("floor", q);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    geom.setMaterial(mat);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(geom);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.7f));
    rootNode.addLight(al);
    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(0, -1, 0.5f).normalizeLocal());
    dl1.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(dl1);
    // create the geometry and attach it
    Spatial tree = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    tree.setQueueBucket(Bucket.Transparent);
    tree.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(tree);
    // Uses Texture from jme3-test-data library!
    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.setShadowMode(ShadowMode.Cast);
    fire.setMaterial(mat_red);
    fire.setImagesX(2);
    // 2x2 texture animation
    fire.setImagesY(2);
    // red
    fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));
    // yellow
    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f));
    fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
    fire.setStartSize(0.6f);
    fire.setEndSize(0.1f);
    fire.setGravity(0, 0, 0);
    fire.setLowLife(0.5f);
    fire.setHighLife(1.5f);
    fire.getParticleInfluencer().setVelocityVariation(0.3f);
    fire.setLocalTranslation(5.0f, 0, 1.0f);
    fire.setLocalScale(0.3f);
    fire.setQueueBucket(Bucket.Translucent);
    rootNode.attachChild(fire);
    Material mat2 = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    Geometry ball = new Geometry("sphere", new Sphere(16, 16, 0.5f));
    ball.setMaterial(mat2);
    ball.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ball);
    ball.setLocalTranslation(-1.0f, 1.5f, 1.0f);
    final DirectionalLightShadowRenderer dlsRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 1);
    dlsRenderer.setLight(dl1);
    dlsRenderer.setLambda(0.55f);
    dlsRenderer.setShadowIntensity(0.8f);
    dlsRenderer.setShadowCompareMode(CompareMode.Software);
    dlsRenderer.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsRenderer.displayDebug();
    viewPort.addProcessor(dlsRenderer);
    inputManager.addMapping("stabilize", new KeyTrigger(KeyInput.KEY_B));
    inputManager.addListener(new ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("stabilize") && isPressed) {
                dlsRenderer.setEnabledStabilization(!dlsRenderer.isEnabledStabilization());
            }
        }
    }, "stabilize");
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) Quad(com.jme3.scene.shape.Quad) KeyTrigger(com.jme3.input.controls.KeyTrigger) Material(com.jme3.material.Material) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ActionListener(com.jme3.input.controls.ActionListener) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) AmbientLight(com.jme3.light.AmbientLight)

Example 23 with ParticleEmitter

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

the class TestWalkingChar method prepareEffect.

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);
}
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 24 with ParticleEmitter

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

the class TestPostWater method createFire.

private void createFire() {
    /**
         * Uses Texture from jme3-test-data library!
         */
    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);
    // 2x2 texture animation
    fire.setImagesY(2);
    // red
    fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));
    // yellow
    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f));
    fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
    fire.setStartSize(10f);
    fire.setEndSize(1f);
    fire.setGravity(0, 0, 0);
    fire.setLowLife(0.5f);
    fire.setHighLife(1.5f);
    fire.getParticleInfluencer().setVelocityVariation(0.3f);
    fire.setLocalTranslation(-600, 50, 300);
    fire.setQueueBucket(Bucket.Translucent);
    rootNode.attachChild(fire);
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) 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