Feature: added importing of Sun and Hemi lights from blender as

PointLight with very large radius and DirectionalLight (with proper
warnings for the developer).
experimental
jmekaelthas 10 years ago
parent 4633d9e546
commit 7783e096cc
  1. 20
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/lights/LightHelper.java

@ -81,7 +81,9 @@ public class LightHelper extends AbstractBlenderHelper {
((PointLight) light).setRadius(distance); ((PointLight) light).setRadius(distance);
break; break;
case 1:// Sun case 1:// Sun
LOGGER.log(Level.WARNING, "'Sun' lamp is not supported in jMonkeyEngine."); LOGGER.log(Level.WARNING, "'Sun' lamp is not supported in jMonkeyEngine. Using PointLight with radius = Float.MAX_VALUE.");
light = new PointLight();
((PointLight) light).setRadius(Float.MAX_VALUE);
break; break;
case 2:// Spot case 2:// Spot
light = new SpotLight(); light = new SpotLight();
@ -98,21 +100,17 @@ public class LightHelper extends AbstractBlenderHelper {
((SpotLight) light).setSpotInnerAngle(innerAngle); ((SpotLight) light).setSpotInnerAngle(innerAngle);
break; break;
case 3:// Hemi case 3:// Hemi
LOGGER.log(Level.WARNING, "'Hemi' lamp is not supported in jMonkeyEngine."); LOGGER.log(Level.WARNING, "'Hemi' lamp is not supported in jMonkeyEngine. Using DirectionalLight instead.");
break;
case 4:// Area case 4:// Area
light = new DirectionalLight(); light = new DirectionalLight();
break; break;
default: default:
throw new BlenderFileException("Unknown light source type: " + type); throw new BlenderFileException("Unknown light source type: " + type);
} }
if (light != null) { float r = ((Number) structure.getFieldValue("r")).floatValue();
float r = ((Number) structure.getFieldValue("r")).floatValue(); float g = ((Number) structure.getFieldValue("g")).floatValue();
float g = ((Number) structure.getFieldValue("g")).floatValue(); float b = ((Number) structure.getFieldValue("b")).floatValue();
float b = ((Number) structure.getFieldValue("b")).floatValue(); light.setColor(new ColorRGBA(r, g, b, 1.0f));
light.setColor(new ColorRGBA(r, g, b, 1.0f)); return new LightNode(structure.getName(), light);
result = new LightNode(structure.getName(), light);
}
return result;
} }
} }

Loading…
Cancel
Save