Search in sources :

Example 41 with AmbientLight

use of com.jme3.light.AmbientLight 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

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