Search in sources :

Example 1 with PointLight

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

the class LightSortTest method testSceneGraphSort.

@Test
public void testSceneGraphSort() {
    Node n = new Node("node");
    Geometry g = new Geometry("geom", new Mesh());
    SpotLight spot = new SpotLight(Vector3f.ZERO, Vector3f.UNIT_X);
    PointLight point = new PointLight(Vector3f.UNIT_X);
    DirectionalLight directional = new DirectionalLight(Vector3f.UNIT_X);
    AmbientLight ambient = new AmbientLight();
    // Some lights are on the node
    n.addLight(spot);
    n.addLight(point);
    // .. and some on the geometry.
    g.addLight(directional);
    g.addLight(ambient);
    n.attachChild(g);
    n.updateGeometricState();
    LightList list = g.getWorldLightList();
    // check the sorting (when geom is at 0,0,0)
    assert list.get(0) instanceof AmbientLight;
    assert list.get(1) instanceof DirectionalLight;
    assert list.get(2) instanceof SpotLight;
    assert list.get(3) instanceof PointLight;
    // move the geometry closer to the point light
    g.setLocalTranslation(Vector3f.UNIT_X);
    n.updateGeometricState();
    assert list.get(0) instanceof AmbientLight;
    assert list.get(1) instanceof DirectionalLight;
    assert list.get(2) instanceof PointLight;
    assert list.get(3) instanceof SpotLight;
// now move the point light away from the geometry
// and the spot light closer
// XXX: doesn't work! jME can't detect that the light moved!
//        point.setPosition(Vector3f.ZERO);
//        spot.setPosition(Vector3f.UNIT_X);
//        n.updateGeometricState();
//        
//        assert list.get(0) instanceof AmbientLight;
//        assert list.get(1) instanceof DirectionalLight;
//        assert list.get(2) instanceof SpotLight;
//        assert list.get(3) instanceof PointLight;
}
Also used : Geometry(com.jme3.scene.Geometry) Node(com.jme3.scene.Node) Mesh(com.jme3.scene.Mesh) Test(org.junit.Test)

Example 2 with PointLight

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

the class TestMultiRenderTarget method simpleInitApp.

@Override
public void simpleInitApp() {
    viewPort.addProcessor(this);
    //        flyCam.setEnabled(false);
    cam.setLocation(new Vector3f(4.8037705f, 4.851632f, 10.789033f));
    cam.setRotation(new Quaternion(-0.05143692f, 0.9483723f, -0.21131563f, -0.230846f));
    Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
    //tankMesh.getMaterial().setColor("Specular", ColorRGBA.Black);
    rootNode.attachChild(tank);
    display1 = new Picture("Picture");
    // make it appear behind stats view
    display1.move(0, 0, -1);
    display2 = (Picture) display1.clone();
    display3 = (Picture) display1.clone();
    display4 = (Picture) display1.clone();
    display = (Picture) display1.clone();
    ColorRGBA[] colors = new ColorRGBA[] { ColorRGBA.White, ColorRGBA.Blue, ColorRGBA.Cyan, ColorRGBA.DarkGray, ColorRGBA.Green, ColorRGBA.Magenta, ColorRGBA.Orange, ColorRGBA.Pink, ColorRGBA.Red, ColorRGBA.Yellow };
    pls = new PointLight[3];
    for (int i = 0; i < pls.length; i++) {
        PointLight pl = new PointLight();
        pl.setColor(colors[i % colors.length]);
        pl.setRadius(5);
        display.addLight(pl);
        pls[i] = pl;
    }
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Picture(com.jme3.ui.Picture) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) PointLight(com.jme3.light.PointLight)

Example 3 with PointLight

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

the class TestMultiRenderTarget method simpleUpdate.

@Override
public void simpleUpdate(float tpf) {
    //To change body of generated methods, choose Tools | Templates.
    super.simpleUpdate(tpf);
    for (int i = 0; i < 3; i++) {
        PointLight pl = pls[i];
        // 3s for full loop
        float angle = (float) Math.PI * (i + (timer.getTimeInSeconds() % 6) / 3);
        pl.setPosition(new Vector3f(FastMath.cos(angle) * 3f, 0, FastMath.sin(angle) * 3f));
    }
}
Also used : Vector3f(com.jme3.math.Vector3f) PointLight(com.jme3.light.PointLight)

Example 4 with PointLight

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

the class TestMonkeyHead method simpleInitApp.

@Override
public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    Spatial bumpy = (Spatial) assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
    rootNode.attachChild(bumpy);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    // flourescent main light
    pl = new PointLight();
    pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f));
    rootNode.addLight(pl);
    // sunset light
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
    rootNode.addLight(dl);
    // skylight
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
    dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
    rootNode.addLight(dl);
    // white ambient light
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
    dl.setColor(new ColorRGBA(0.50f, 0.40f, 0.50f, 1.0f));
    rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ColorRGBA(com.jme3.math.ColorRGBA) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLight(com.jme3.light.PointLight)

Example 5 with PointLight

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

the class TestSimpleBumps method simpleInitApp.

@Override
public void simpleInitApp() {
    Quad quadMesh = new Quad(1, 1);
    Geometry sphere = new Geometry("Rock Ball", quadMesh);
    Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
    sphere.setMaterial(mat);
    TangentBinormalGenerator.generate(sphere);
    rootNode.attachChild(sphere);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(0f, 0f, 4f));
    rootNode.addLight(pl);
//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
//        dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
//        rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Quad(com.jme3.scene.shape.Quad) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Aggregations

PointLight (com.jme3.light.PointLight)30 Vector3f (com.jme3.math.Vector3f)28 Geometry (com.jme3.scene.Geometry)22 DirectionalLight (com.jme3.light.DirectionalLight)21 Sphere (com.jme3.scene.shape.Sphere)18 SpotLight (com.jme3.light.SpotLight)14 Material (com.jme3.material.Material)12 ColorRGBA (com.jme3.math.ColorRGBA)12 Quaternion (com.jme3.math.Quaternion)9 AmbientLight (com.jme3.light.AmbientLight)8 Node (com.jme3.scene.Node)8 Light (com.jme3.light.Light)5 Spatial (com.jme3.scene.Spatial)5 TempVars (com.jme3.util.TempVars)5 FilterPostProcessor (com.jme3.post.FilterPostProcessor)4 Box (com.jme3.scene.shape.Box)4 SpotLightShadowRenderer (com.jme3.shadow.SpotLightShadowRenderer)4 ActionListener (com.jme3.input.controls.ActionListener)3 KeyTrigger (com.jme3.input.controls.KeyTrigger)3 Uniform (com.jme3.shader.Uniform)3