Search in sources :

Example 16 with AmbientLight

use of com.jme3.light.AmbientLight in project jmonkeyengine by jMonkeyEngine.

the class PhysicsTestHelper method createPhysicsTestWorldSoccer.

public static void createPhysicsTestWorldSoccer(Node rootNode, AssetManager assetManager, PhysicsSpace space) {
    AmbientLight light = new AmbientLight();
    light.setColor(ColorRGBA.LightGray);
    rootNode.addLight(light);
    Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    Box floorBox = new Box(20, 0.25f, 20);
    Geometry floorGeometry = new Geometry("Floor", floorBox);
    floorGeometry.setMaterial(material);
    floorGeometry.setLocalTranslation(0, -0.25f, 0);
    //        Plane plane = new Plane();
    //        plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y);
    //        floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0));
    floorGeometry.addControl(new RigidBodyControl(0));
    rootNode.attachChild(floorGeometry);
    space.add(floorGeometry);
    //movable spheres
    for (int i = 0; i < 5; i++) {
        Sphere sphere = new Sphere(16, 16, .5f);
        Geometry ballGeometry = new Geometry("Soccer ball", sphere);
        ballGeometry.setMaterial(material);
        ballGeometry.setLocalTranslation(i, 2, -3);
        //RigidBodyControl automatically uses Sphere collision shapes when attached to single geometry with sphere mesh
        ballGeometry.addControl(new RigidBodyControl(.001f));
        ballGeometry.getControl(RigidBodyControl.class).setRestitution(1);
        rootNode.attachChild(ballGeometry);
        space.add(ballGeometry);
    }
    {
        //immovable Box with mesh collision shape
        Box box = new Box(1, 1, 1);
        Geometry boxGeometry = new Geometry("Box", box);
        boxGeometry.setMaterial(material);
        boxGeometry.setLocalTranslation(4, 1, 2);
        boxGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(box), 0));
        rootNode.attachChild(boxGeometry);
        space.add(boxGeometry);
    }
    {
        //immovable Box with mesh collision shape
        Box box = new Box(1, 1, 1);
        Geometry boxGeometry = new Geometry("Box", box);
        boxGeometry.setMaterial(material);
        boxGeometry.setLocalTranslation(4, 3, 4);
        boxGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(box), 0));
        rootNode.attachChild(boxGeometry);
        space.add(boxGeometry);
    }
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) MeshCollisionShape(com.jme3.bullet.collision.shapes.MeshCollisionShape) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) AmbientLight(com.jme3.light.AmbientLight)

Example 17 with AmbientLight

use of com.jme3.light.AmbientLight in project jmonkeyengine by jMonkeyEngine.

the class TerrainTestTile method simpleInitApp.

@Override
public void simpleInitApp() {
    loadHintText();
    setupKeys();
    // WIREFRAME material
    matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matWire.getAdditionalRenderState().setWireframe(true);
    matWire.setColor("Color", ColorRGBA.Green);
    terrain = new TiledTerrain();
    rootNode.attachChild(terrain);
    DirectionalLight light = new DirectionalLight();
    light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
    rootNode.addLight(light);
    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
    rootNode.addLight(ambLight);
    cam.setLocation(new Vector3f(0, 256, 0));
    cam.lookAtDirection(new Vector3f(0, -1, -1).normalizeLocal(), Vector3f.UNIT_Y);
    Sphere s = new Sphere(12, 12, 3);
    Geometry g = new Geometry("marker");
    g.setMesh(s);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Red);
    g.setMaterial(mat);
    g.setLocalTranslation(0, -100, 0);
    rootNode.attachChild(g);
    Geometry g2 = new Geometry("marker");
    g2.setMesh(s);
    mat.setColor("Color", ColorRGBA.Red);
    g2.setMaterial(mat);
    g2.setLocalTranslation(10, -100, 0);
    rootNode.attachChild(g2);
    Geometry g3 = new Geometry("marker");
    g3.setMesh(s);
    mat.setColor("Color", ColorRGBA.Red);
    g3.setMaterial(mat);
    g3.setLocalTranslation(0, -100, 10);
    rootNode.attachChild(g3);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) ColorRGBA(com.jme3.math.ColorRGBA) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) AmbientLight(com.jme3.light.AmbientLight)

Example 18 with AmbientLight

use of com.jme3.light.AmbientLight in project jmonkeyengine by jMonkeyEngine.

the class TerrainTestModifyHeight method simpleInitApp.

@Override
public void simpleInitApp() {
    loadHintText();
    initCrossHairs();
    setupKeys();
    createMarker();
    // WIREFRAME material
    matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matWire.getAdditionalRenderState().setWireframe(true);
    matWire.setColor("Color", ColorRGBA.Green);
    createTerrain();
    //createTerrainGrid();
    DirectionalLight light = new DirectionalLight();
    light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
    rootNode.addLight(light);
    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
    rootNode.addLight(ambLight);
    cam.setLocation(new Vector3f(0, 256, 0));
    cam.lookAtDirection(new Vector3f(0, -1f, 0).normalizeLocal(), Vector3f.UNIT_X);
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) AmbientLight(com.jme3.light.AmbientLight)

Example 19 with AmbientLight

use of com.jme3.light.AmbientLight in project jmonkeyengine by jMonkeyEngine.

the class TestJaime method setupLights.

public void setupLights() {
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1));
    rootNode.addLight(al);
    SpotLight sl = new SpotLight();
    sl.setColor(ColorRGBA.White.mult(1.0f));
    sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f));
    sl.setDirection(sl.getPosition().mult(-1));
    sl.setSpotOuterAngle(0.1f);
    sl.setSpotInnerAngle(0.004f);
    rootNode.addLight(sl);
    //pointlight to fake indirect light coming from the ground
    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White.mult(1.5f));
    pl.setPosition(new Vector3f(0, 0, 1));
    pl.setRadius(2);
    rootNode.addLight(pl);
    SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024);
    shadows.setLight(sl);
    shadows.setShadowIntensity(0.3f);
    shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8);
    viewPort.addProcessor(shadows);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter filter = new SSAOFilter(0.10997847f, 0.440001f, 0.39999998f, -0.008000026f);
    ;
    fpp.addFilter(filter);
    fpp.addFilter(new FXAAFilter());
    fpp.addFilter(new FXAAFilter());
    viewPort.addProcessor(fpp);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) FXAAFilter(com.jme3.post.filters.FXAAFilter) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor) PointLight(com.jme3.light.PointLight) SpotLightShadowRenderer(com.jme3.shadow.SpotLightShadowRenderer) SpotLight(com.jme3.light.SpotLight) AmbientLight(com.jme3.light.AmbientLight)

Example 20 with AmbientLight

use of com.jme3.light.AmbientLight in project jmonkeyengine by jMonkeyEngine.

the class LightFilterTest method testAmbientFiltering.

@Test
public void testAmbientFiltering() {
    geom.addLight(new AmbientLight());
    // Ambient lights must never be filtered
    checkFilteredLights(1);
    // Test for bounding Sphere
    geom.setModelBound(new BoundingSphere(0.5f, Vector3f.ZERO));
    // Ambient lights must never be filtered
    checkFilteredLights(1);
}
Also used : BoundingSphere(com.jme3.bounding.BoundingSphere) Test(org.junit.Test)

Aggregations

AmbientLight (com.jme3.light.AmbientLight)35 DirectionalLight (com.jme3.light.DirectionalLight)24 Vector3f (com.jme3.math.Vector3f)24 Geometry (com.jme3.scene.Geometry)24 Material (com.jme3.material.Material)16 Box (com.jme3.scene.shape.Box)13 Node (com.jme3.scene.Node)12 Spatial (com.jme3.scene.Spatial)12 Sphere (com.jme3.scene.shape.Sphere)12 ColorRGBA (com.jme3.math.ColorRGBA)11 Quaternion (com.jme3.math.Quaternion)9 SpotLight (com.jme3.light.SpotLight)8 ActionListener (com.jme3.input.controls.ActionListener)7 KeyTrigger (com.jme3.input.controls.KeyTrigger)7 FilterPostProcessor (com.jme3.post.FilterPostProcessor)7 PointLight (com.jme3.light.PointLight)6 Texture (com.jme3.texture.Texture)6 Vector2f (com.jme3.math.Vector2f)5 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)4 SSAOFilter (com.jme3.post.ssao.SSAOFilter)3