OSDN Git Service

* Added hack to allow loading of non-spec-compliant dotScene files from Blender 2.57
authorShadowIsLord <ShadowIsLord@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Sun, 22 May 2011 23:52:31 +0000 (23:52 +0000)
committerShadowIsLord <ShadowIsLord@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Sun, 22 May 2011 23:52:31 +0000 (23:52 +0000)
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7521 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/ogre/com/jme3/scene/plugins/ogre/SceneLoader.java

index f867467..c452338 100644 (file)
@@ -163,8 +163,10 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
         String lightType = parseString(attribs.getValue("type"), "point");\r
         if(lightType.equals("point")) {\r
             light = new PointLight();\r
-        } else if(lightType.equals("directional")) {\r
+        } else if(lightType.equals("directional") || lightType.equals("sun")) {\r
             light = new DirectionalLight();\r
+            // Assuming "normal" property is not provided\r
+            ((DirectionalLight)light).setDirection(Vector3f.UNIT_Z);\r
         } else if(lightType.equals("spotLight")) {\r
             // TODO: SpotLight class.\r
             logger.warning("No SpotLight class atm, using Pointlight instead.");\r
@@ -284,7 +286,9 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
             parseLight(attribs);\r
         } else if (qName.equals("colourDiffuse") || qName.equals("colorDiffuse")) {\r
             if (elementStack.peek().equals("light")){\r
-                light.setColor(parseColor(attribs));\r
+                if (light != null){\r
+                    light.setColor(parseColor(attribs));\r
+                }\r
             }else{\r
                 assert elementStack.peek().equals("environment");\r
             }\r
@@ -309,16 +313,18 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
         }else if (qName.equals("light")){\r
             // apply the node's world transform on the light..\r
             root.updateGeometricState();\r
-            if (light instanceof DirectionalLight){\r
-                DirectionalLight dl = (DirectionalLight) light;\r
-                Quaternion q = node.getWorldRotation();\r
-                Vector3f dir = dl.getDirection();\r
-                q.multLocal(dir);\r
-                dl.setDirection(dir);\r
-            }else if (light instanceof PointLight){\r
-                PointLight pl = (PointLight) light;\r
-                Vector3f pos = node.getWorldTranslation();\r
-                pl.setPosition(pos);\r
+            if (light != null){\r
+                if (light instanceof DirectionalLight){\r
+                    DirectionalLight dl = (DirectionalLight) light;\r
+                    Quaternion q = node.getWorldRotation();\r
+                    Vector3f dir = dl.getDirection();\r
+                    q.multLocal(dir);\r
+                    dl.setDirection(dir);\r
+                }else if (light instanceof PointLight){\r
+                    PointLight pl = (PointLight) light;\r
+                    Vector3f pos = node.getWorldTranslation();\r
+                    pl.setPosition(pos);\r
+                }\r
             }\r
             light = null;\r
         }\r