* Added hack to allow loading of non-spec-compliant dotScene files from Blender 2.57
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7521 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e91fe8f541
commit
8b8e84ac6a
@ -163,8 +163,10 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
|
|||||||
String lightType = parseString(attribs.getValue("type"), "point");
|
String lightType = parseString(attribs.getValue("type"), "point");
|
||||||
if(lightType.equals("point")) {
|
if(lightType.equals("point")) {
|
||||||
light = new PointLight();
|
light = new PointLight();
|
||||||
} else if(lightType.equals("directional")) {
|
} else if(lightType.equals("directional") || lightType.equals("sun")) {
|
||||||
light = new DirectionalLight();
|
light = new DirectionalLight();
|
||||||
|
// Assuming "normal" property is not provided
|
||||||
|
((DirectionalLight)light).setDirection(Vector3f.UNIT_Z);
|
||||||
} else if(lightType.equals("spotLight")) {
|
} else if(lightType.equals("spotLight")) {
|
||||||
// TODO: SpotLight class.
|
// TODO: SpotLight class.
|
||||||
logger.warning("No SpotLight class atm, using Pointlight instead.");
|
logger.warning("No SpotLight class atm, using Pointlight instead.");
|
||||||
@ -284,7 +286,9 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
|
|||||||
parseLight(attribs);
|
parseLight(attribs);
|
||||||
} else if (qName.equals("colourDiffuse") || qName.equals("colorDiffuse")) {
|
} else if (qName.equals("colourDiffuse") || qName.equals("colorDiffuse")) {
|
||||||
if (elementStack.peek().equals("light")){
|
if (elementStack.peek().equals("light")){
|
||||||
light.setColor(parseColor(attribs));
|
if (light != null){
|
||||||
|
light.setColor(parseColor(attribs));
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
assert elementStack.peek().equals("environment");
|
assert elementStack.peek().equals("environment");
|
||||||
}
|
}
|
||||||
@ -309,16 +313,18 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
|
|||||||
}else if (qName.equals("light")){
|
}else if (qName.equals("light")){
|
||||||
// apply the node's world transform on the light..
|
// apply the node's world transform on the light..
|
||||||
root.updateGeometricState();
|
root.updateGeometricState();
|
||||||
if (light instanceof DirectionalLight){
|
if (light != null){
|
||||||
DirectionalLight dl = (DirectionalLight) light;
|
if (light instanceof DirectionalLight){
|
||||||
Quaternion q = node.getWorldRotation();
|
DirectionalLight dl = (DirectionalLight) light;
|
||||||
Vector3f dir = dl.getDirection();
|
Quaternion q = node.getWorldRotation();
|
||||||
q.multLocal(dir);
|
Vector3f dir = dl.getDirection();
|
||||||
dl.setDirection(dir);
|
q.multLocal(dir);
|
||||||
}else if (light instanceof PointLight){
|
dl.setDirection(dir);
|
||||||
PointLight pl = (PointLight) light;
|
}else if (light instanceof PointLight){
|
||||||
Vector3f pos = node.getWorldTranslation();
|
PointLight pl = (PointLight) light;
|
||||||
pl.setPosition(pos);
|
Vector3f pos = node.getWorldTranslation();
|
||||||
|
pl.setPosition(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
light = null;
|
light = null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user