diff --git a/engine/src/ogre/com/jme3/scene/plugins/ogre/SceneLoader.java b/engine/src/ogre/com/jme3/scene/plugins/ogre/SceneLoader.java index f867467a2..c45233889 100644 --- a/engine/src/ogre/com/jme3/scene/plugins/ogre/SceneLoader.java +++ b/engine/src/ogre/com/jme3/scene/plugins/ogre/SceneLoader.java @@ -163,8 +163,10 @@ public class SceneLoader extends DefaultHandler implements AssetLoader { String lightType = parseString(attribs.getValue("type"), "point"); if(lightType.equals("point")) { light = new PointLight(); - } else if(lightType.equals("directional")) { + } 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")) { // TODO: SpotLight class. logger.warning("No SpotLight class atm, using Pointlight instead."); @@ -284,7 +286,9 @@ public class SceneLoader extends DefaultHandler implements AssetLoader { parseLight(attribs); } else if (qName.equals("colourDiffuse") || qName.equals("colorDiffuse")) { if (elementStack.peek().equals("light")){ - light.setColor(parseColor(attribs)); + if (light != null){ + light.setColor(parseColor(attribs)); + } }else{ assert elementStack.peek().equals("environment"); } @@ -309,16 +313,18 @@ public class SceneLoader extends DefaultHandler implements AssetLoader { }else if (qName.equals("light")){ // apply the node's world transform on the light.. root.updateGeometricState(); - if (light instanceof DirectionalLight){ - DirectionalLight dl = (DirectionalLight) light; - Quaternion q = node.getWorldRotation(); - Vector3f dir = dl.getDirection(); - q.multLocal(dir); - dl.setDirection(dir); - }else if (light instanceof PointLight){ - PointLight pl = (PointLight) light; - Vector3f pos = node.getWorldTranslation(); - pl.setPosition(pos); + if (light != null){ + if (light instanceof DirectionalLight){ + DirectionalLight dl = (DirectionalLight) light; + Quaternion q = node.getWorldRotation(); + Vector3f dir = dl.getDirection(); + q.multLocal(dir); + dl.setDirection(dir); + }else if (light instanceof PointLight){ + PointLight pl = (PointLight) light; + Vector3f pos = node.getWorldTranslation(); + pl.setPosition(pos); + } } light = null; }