From: ShadowIsLord Date: Sun, 22 May 2011 23:52:31 +0000 (+0000) Subject: * Added hack to allow loading of non-spec-compliant dotScene files from Blender 2.57 X-Git-Tag: v0.8.0~1048 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e3dfdd4219e7cd3509fb5127d44aff7299918c2f;p=mikumikustudio%2FMikuMikuStudio.git * Added hack to allow loading of non-spec-compliant dotScene files from Blender 2.57 git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7521 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- 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; }