Fixes to spot light loading.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9117 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
db4188c797
commit
65afa0bbc8
@ -86,13 +86,12 @@ public class LightHelper extends AbstractBlenderHelper {
|
|||||||
//range
|
//range
|
||||||
((SpotLight)result).setSpotRange(((Number) structure.getFieldValue("dist")).floatValue());
|
((SpotLight)result).setSpotRange(((Number) structure.getFieldValue("dist")).floatValue());
|
||||||
//outer angle
|
//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);
|
((SpotLight)result).setSpotOuterAngle(outerAngle);
|
||||||
|
|
||||||
//inner angle
|
//inner angle
|
||||||
float spotblend = ((Number) structure.getFieldValue("spotblend")).floatValue();
|
float spotblend = ((Number) structure.getFieldValue("spotblend")).floatValue();
|
||||||
spotblend = FastMath.clamp(spotblend, 0, 1);
|
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);
|
float innerAngle = outerAngle * (1 - spotblend);
|
||||||
((SpotLight)result).setSpotInnerAngle(innerAngle);
|
((SpotLight)result).setSpotInnerAngle(innerAngle);
|
||||||
break;
|
break;
|
||||||
|
@ -207,14 +207,22 @@ public class ObjectHelper extends AbstractBlenderHelper {
|
|||||||
Quaternion quaternion = t.getRotation();
|
Quaternion quaternion = t.getRotation();
|
||||||
Vector3f[] axes = new Vector3f[3];
|
Vector3f[] axes = new Vector3f[3];
|
||||||
quaternion.toAxes(axes);
|
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) {
|
} else if(light instanceof SpotLight) {
|
||||||
((SpotLight)light).setPosition(t.getTranslation());
|
((SpotLight)light).setPosition(t.getTranslation());
|
||||||
|
|
||||||
Quaternion quaternion = t.getRotation();
|
Quaternion quaternion = t.getRotation();
|
||||||
Vector3f[] axes = new Vector3f[3];
|
Vector3f[] axes = new Vector3f[3];
|
||||||
quaternion.toAxes(axes);
|
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 {
|
} else {
|
||||||
LOGGER.log(Level.WARNING, "Unknown type of light: {0}", light);
|
LOGGER.log(Level.WARNING, "Unknown type of light: {0}", light);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user