From 65afa0bbc8c9fa794d9f8753d5e5b9955aa7abc6 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Sat, 28 Jan 2012 10:25:11 +0000 Subject: [PATCH] Fixes to spot light loading. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9117 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../scene/plugins/blender/lights/LightHelper.java | 3 +-- .../scene/plugins/blender/objects/ObjectHelper.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java index 1910ca197..add3e2147 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.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; diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java index 172ac9742..ed14a11af 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java @@ -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); }