Search in sources :

Example 36 with PointLight

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

the class TestNormalMapping method simpleInitApp.

@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);
    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    sphere.setMaterial(mat);
    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 : Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Example 37 with PointLight

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

the class TestUnshadedModel method simpleInitApp.

@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);
    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);
    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight) AmbientLight(com.jme3.light.AmbientLight)

Example 38 with PointLight

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

the class TestOgreLoading method simpleInitApp.

public void simpleInitApp() {
    //        PointLight pl = new PointLight();
    //        pl.setPosition(new Vector3f(10, 10, -10));
    //        rootNode.addLight(pl);
    flyCam.setMoveSpeed(10f);
    // sunset light
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m"));
    rootNode.attachChild(lightMd2);
    pl = new PointLight();
    pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0));
    pl.setPosition(new Vector3f(0f, 0f, 4f));
    rootNode.addLight(pl);
    p2 = new PointLight();
    p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0));
    p2.setPosition(new Vector3f(0f, 0f, 3f));
    rootNode.addLight(p2);
    // create the geometry and attach it
    Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
    float scale = 0.05f;
    elephant.scale(scale, scale, scale);
    rootNode.attachChild(elephant);
}
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 39 with PointLight

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

the class SceneLoader method parseLight.

private void parseLight(Attributes attribs) throws SAXException {
    if (node == null || node.getParent() == null) {
        throw new SAXException("dotScene parse error: light can only appear under a node");
    }
    checkTopNode("node");
    String lightType = parseString(attribs.getValue("type"), "point");
    if (lightType.equals("point")) {
        light = new PointLight();
    } else if (lightType.equals("directional") || lightType.equals("sun")) {
        light = new DirectionalLight();
        // Assuming "normal" property is not provided
        ((DirectionalLight) light).setDirection(Vector3f.UNIT_Z);
    } else if (lightType.equals("spotLight") || lightType.equals("spot")) {
        light = new SpotLight();
    } else if (lightType.equals("omni")) {
        // XXX: It doesn't seem any exporters actually emit this type?
        light = new AmbientLight();
    } else {
        logger.log(Level.WARNING, "No matching jME3 LightType found for OGRE LightType: {0}", lightType);
    }
    logger.log(Level.FINEST, "{0} created.", light);
    if (!parseBool(attribs.getValue("visible"), true)) {
    // set to disabled
    }
    // "attach" it to the parent of this node
    if (light != null) {
        node.getParent().addLight(light);
    }
}
Also used : DirectionalLight(com.jme3.light.DirectionalLight) PointLight(com.jme3.light.PointLight) SpotLight(com.jme3.light.SpotLight) AmbientLight(com.jme3.light.AmbientLight) SAXException(org.xml.sax.SAXException)

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