Fixes to spot light loading.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9117 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 13 years ago
parent db4188c797
commit 65afa0bbc8
  1. 3
      engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java
  2. 12
      engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java

@ -86,13 +86,12 @@ public class LightHelper extends AbstractBlenderHelper {
//range
((SpotLight)result).setSpotRange(((Number) structure.getFieldValue("dist")).floatValue());
//outer angle
float outerAngle = ((Number) structure.getFieldValue("spotsize")).floatValue()*FastMath.DEG_TO_RAD;
float outerAngle = ((Number) structure.getFieldValue("spotsize")).floatValue()*FastMath.DEG_TO_RAD * 0.5f;
((SpotLight)result).setSpotOuterAngle(outerAngle);
//inner angle
float spotblend = ((Number) structure.getFieldValue("spotblend")).floatValue();
spotblend = FastMath.clamp(spotblend, 0, 1);
//float innerAngle = 2.0f * (float)Math.atan((1.0f-spotblend)*Math.tan(spotblend/2.0f));
float innerAngle = outerAngle * (1 - spotblend);
((SpotLight)result).setSpotInnerAngle(innerAngle);
break;

@ -207,14 +207,22 @@ public class ObjectHelper extends AbstractBlenderHelper {
Quaternion quaternion = t.getRotation();
Vector3f[] axes = new Vector3f[3];
quaternion.toAxes(axes);
((DirectionalLight)light).setDirection(axes[2].negate());//-Z is the direction axis of area lamp in blender
if(fixUpAxis) {
((DirectionalLight)light).setDirection(axes[1].negate());//-Z is the direction axis of area lamp in blender
} else {
((DirectionalLight)light).setDirection(axes[2].negate());
}
} else if(light instanceof SpotLight) {
((SpotLight)light).setPosition(t.getTranslation());
Quaternion quaternion = t.getRotation();
Vector3f[] axes = new Vector3f[3];
quaternion.toAxes(axes);
((SpotLight)light).setDirection(axes[2].negate());//-Z is the direction axis of area lamp in blender
if(fixUpAxis) {
((SpotLight)light).setDirection(axes[1].negate());//-Z is the direction axis of area lamp in blender
} else {
((SpotLight)light).setDirection(axes[2].negate());
}
} else {
LOGGER.log(Level.WARNING, "Unknown type of light: {0}", light);
}

Loading…
Cancel
Save