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
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
}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