Search in sources :

Example 16 with AL

use of com.jme3.audio.openal.AL in project jmonkeyengine by jMonkeyEngine.

the class TestPssmShadow method loadScene.

public void loadScene() {
    obj = new Spatial[2];
    mat = new Material[2];
    mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat[1].setBoolean("UseMaterialColors", true);
    mat[1].setColor("Ambient", ColorRGBA.White.mult(0.5f));
    mat[1].setColor("Diffuse", ColorRGBA.White.clone());
    obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
    obj[0].setShadowMode(ShadowMode.CastAndReceive);
    obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
    obj[1].setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(obj[1]);
    TangentBinormalGenerator.generate(obj[0]);
    for (int i = 0; i < 60; i++) {
        Spatial t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
        t.setLocalScale(FastMath.nextRandomFloat() * 10f);
        t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);
        rootNode.attachChild(t);
        t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
    }
    Box b = new Box(1000, 2, 1000);
    b.scaleTextureCoordinates(new Vector2f(10, 10));
    ground = new Geometry("soil", b);
    ground.setLocalTranslation(0, 10, 550);
    matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matGroundU.setColor("Color", ColorRGBA.Green);
    matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
    grass.setWrap(WrapMode.Repeat);
    matGroundL.setTexture("DiffuseMap", grass);
    ground.setMaterial(matGroundL);
    ground.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ground);
    l = new DirectionalLight();
    l.setDirection(new Vector3f(-1, -1, -1));
    rootNode.addLight(l);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.5f));
    rootNode.addLight(al);
    Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
    sky.setLocalScale(350);
    rootNode.attachChild(sky);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Spatial(com.jme3.scene.Spatial) Vector2f(com.jme3.math.Vector2f) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture) AmbientLight(com.jme3.light.AmbientLight)

Example 17 with AL

use of com.jme3.audio.openal.AL in project jmonkeyengine by jMonkeyEngine.

the class TestSpotLight method setupLighting.

public void setupLighting() {
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.02f));
    rootNode.addLight(al);
    spot = new SpotLight();
    spot.setSpotRange(1000);
    spot.setSpotInnerAngle(5 * FastMath.DEG_TO_RAD);
    spot.setSpotOuterAngle(10 * FastMath.DEG_TO_RAD);
    spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
    spot.setDirection(lightTarget.subtract(spot.getPosition()));
    spot.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(spot);
    //        PointLight pl=new PointLight();
    //      pl.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
    //      pl.setRadius(1000);     
    //      pl.setColor(ColorRGBA.White.mult(2));
    //      rootNode.addLight(pl);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f));
    lightMdl.setLocalScale(5);
    rootNode.attachChild(lightMdl);
//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(lightTarget.subtract(new Vector3f(77.70334f, 34.013165f, 27.1017f)));
//        dl.setColor(ColorRGBA.White.mult(2));
//        rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) SpotLight(com.jme3.light.SpotLight) AmbientLight(com.jme3.light.AmbientLight)

Example 18 with AL

use of com.jme3.audio.openal.AL in project jmonkeyengine by jMonkeyEngine.

the class TestSpotLightShadows method setupLighting.

public void setupLighting() {
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.02f));
    rootNode.addLight(al);
    rootNode.setShadowMode(ShadowMode.CastAndReceive);
    spot = new SpotLight();
    spot.setSpotRange(1000);
    spot.setSpotInnerAngle(5f * FastMath.DEG_TO_RAD);
    spot.setSpotOuterAngle(10 * FastMath.DEG_TO_RAD);
    spot.setPosition(new Vector3f(70.70334f, 34.013165f, 27.1017f));
    spot.setDirection(lightTarget.subtract(spot.getPosition()).normalizeLocal());
    spot.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(spot);
    //        PointLight pl=new PointLight();
    //      pl.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
    //      pl.setRadius(1000);     
    //      pl.setColor(ColorRGBA.White.mult(2));
    //      rootNode.addLight(pl);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f));
    lightMdl.setLocalScale(5);
    rootNode.attachChild(lightMdl);
    //        DirectionalLight dl = new DirectionalLight();
    //        dl.setDirection(lightTarget.subtract(new Vector3f(77.70334f, 34.013165f, 27.1017f)));
    //        dl.setColor(ColorRGBA.White.mult(0.7f));
    //        rootNode.addLight(dl);
    final SpotLightShadowRenderer slsr = new SpotLightShadowRenderer(assetManager, 512);
    slsr.setLight(spot);
    slsr.setShadowIntensity(0.5f);
    slsr.setShadowZExtend(100);
    slsr.setShadowZFadeLength(5);
    slsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
    viewPort.addProcessor(slsr);
    SpotLightShadowFilter slsf = new SpotLightShadowFilter(assetManager, 512);
    slsf.setLight(spot);
    slsf.setShadowIntensity(0.5f);
    slsf.setShadowZExtend(100);
    slsf.setShadowZFadeLength(5);
    slsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
    slsf.setEnabled(false);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(slsf);
    viewPort.addProcessor(fpp);
    ShadowTestUIManager uiMan = new ShadowTestUIManager(assetManager, slsr, slsf, guiNode, inputManager, viewPort);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("stop") && isPressed) {
                stop = !stop;
                //   slsr.displayFrustum();
                System.out.println("pos : " + spot.getPosition());
                System.out.println("dir : " + spot.getDirection());
            }
        }
    }, "stop");
    inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_1));
    flyCam.setDragToRotate(true);
}
Also used : SpotLightShadowFilter(com.jme3.shadow.SpotLightShadowFilter) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) SpotLightShadowRenderer(com.jme3.shadow.SpotLightShadowRenderer) SpotLight(com.jme3.light.SpotLight) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ActionListener(com.jme3.input.controls.ActionListener) AmbientLight(com.jme3.light.AmbientLight)

Example 19 with AL

use of com.jme3.audio.openal.AL 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 20 with AL

use of com.jme3.audio.openal.AL in project jmonkeyengine by jMonkeyEngine.

the class TestPbrEnv method loadScene.

public void loadScene() {
    renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
    renderManager.setSinglePassLightBatchSize(3);
    obj = new Spatial[2];
    // Setup first view
    mat = new Material[2];
    mat[0] = assetManager.loadMaterial("jme3test/light/pbr/pbrMat.j3m");
    //mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat[1] = assetManager.loadMaterial("jme3test/light/pbr/pbrMat2.j3m");
    //        mat[1].setBoolean("UseMaterialColors", true);
    //        mat[1].setColor("Ambient", ColorRGBA.White.mult(0.5f));
    //        mat[1].setColor("Diffuse", ColorRGBA.White.clone());
    obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
    obj[0].setShadowMode(ShadowMode.CastAndReceive);
    obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
    obj[1].setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(obj[1]);
    TangentBinormalGenerator.generate(obj[0]);
    for (int i = 0; i < 2; i++) {
        Spatial t = obj[0].clone(false);
        t.setName("Cube" + i);
        t.setLocalScale(10f);
        t.setMaterial(mat[1].clone());
        rootNode.attachChild(t);
        t.setLocalTranslation(i * 200f + 100f, 50, 800f * (i));
    }
    Box b = new Box(1000, 2, 1000);
    b.scaleTextureCoordinates(new Vector2f(20, 20));
    ground = new Geometry("soil", b);
    TangentBinormalGenerator.generate(ground);
    ground.setLocalTranslation(0, 10, 550);
    matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matGroundU.setColor("Color", ColorRGBA.Green);
    //        matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    //        Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
    //        grass.setWrap(WrapMode.Repeat);
    //        matGroundL.setTexture("DiffuseMap", grass);
    matGroundL = assetManager.loadMaterial("jme3test/light/pbr/pbrMat4.j3m");
    ground.setMaterial(matGroundL);
    //ground.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ground);
    l = new DirectionalLight();
    l.setColor(ColorRGBA.White);
    //l.setDirection(new Vector3f(0.5973172f, -0.16583486f, 0.7846725f).normalizeLocal());
    l.setDirection(new Vector3f(-0.2823181f, -0.41889593f, 0.863031f).normalizeLocal());
    rootNode.addLight(l);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.5f));
    //  rootNode.addLight(al);
    //Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", SkyFactory.EnvMapType.CubeMap);
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
    sky.setLocalScale(350);
    rootNode.attachChild(sky);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) BoundingSphere(com.jme3.bounding.BoundingSphere) Spatial(com.jme3.scene.Spatial) Vector2f(com.jme3.math.Vector2f) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) AmbientLight(com.jme3.light.AmbientLight)

Aggregations

AmbientLight (com.jme3.light.AmbientLight)26 DirectionalLight (com.jme3.light.DirectionalLight)19 Vector3f (com.jme3.math.Vector3f)19 Geometry (com.jme3.scene.Geometry)18 Material (com.jme3.material.Material)12 Spatial (com.jme3.scene.Spatial)12 Node (com.jme3.scene.Node)10 Box (com.jme3.scene.shape.Box)10 Sphere (com.jme3.scene.shape.Sphere)9 KeyTrigger (com.jme3.input.controls.KeyTrigger)8 Quaternion (com.jme3.math.Quaternion)8 FilterPostProcessor (com.jme3.post.FilterPostProcessor)8 ActionListener (com.jme3.input.controls.ActionListener)7 ColorRGBA (com.jme3.math.ColorRGBA)7 SpotLight (com.jme3.light.SpotLight)5 Vector2f (com.jme3.math.Vector2f)5 Texture (com.jme3.texture.Texture)5 AL (com.jme3.audio.openal.AL)3 ALAudioRenderer (com.jme3.audio.openal.ALAudioRenderer)3 ALC (com.jme3.audio.openal.ALC)3