Search in sources :

Example 21 with SpotLight

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

the class SceneLoader method parseLightSpotLightRange.

private void parseLightSpotLightRange(Attributes attribs) throws SAXException {
    checkTopNode("light");
    float outer = SAXUtil.parseFloat(attribs.getValue("outer"));
    float inner = SAXUtil.parseFloat(attribs.getValue("inner"));
    if (!(light instanceof SpotLight)) {
        throw new SAXException("dotScene parse error: spotLightRange " + "can only appear under 'spot' light elements");
    }
    SpotLight sl = (SpotLight) light;
    sl.setSpotInnerAngle(inner * 0.5f);
    sl.setSpotOuterAngle(outer * 0.5f);
}
Also used : SpotLight(com.jme3.light.SpotLight) SAXException(org.xml.sax.SAXException)

Example 22 with SpotLight

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

SpotLight (com.jme3.light.SpotLight)17 DirectionalLight (com.jme3.light.DirectionalLight)12 PointLight (com.jme3.light.PointLight)12 Vector3f (com.jme3.math.Vector3f)10 AmbientLight (com.jme3.light.AmbientLight)8 Geometry (com.jme3.scene.Geometry)7 ColorRGBA (com.jme3.math.ColorRGBA)6 Quaternion (com.jme3.math.Quaternion)6 Light (com.jme3.light.Light)5 Node (com.jme3.scene.Node)5 TempVars (com.jme3.util.TempVars)5 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 FilterPostProcessor (com.jme3.post.FilterPostProcessor)3 Sphere (com.jme3.scene.shape.Sphere)3 Uniform (com.jme3.shader.Uniform)3 Test (org.junit.Test)3 BoundingSphere (com.jme3.bounding.BoundingSphere)2