BlenderLoader Light direction is wrong (6 posts)

Topic tags: Blender, lights
  • Profile picture of udoprog udoprog1p said 3 months, 3 weeks ago:

    Hi!

    I’m currently relying heavily on composing my scene directly in blender, and just the .blend using the jme3 BlenderLoader. I’ve noticed that light directions are not correctly loaded.

    This is my observation from looking at com.jme3.scene.plugins.blender.objects.ObjectHelper

    See:

    http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java#210

        ((DirectionalLight)light).setDirection(axes[2].negate());//-Z is the direction axis of area lamp in blender
    

    Trial and error has led me to believe that the snippet instead should be something closer to.

        ((DirectionalLight)light).setDirection(axes[1].negate());//-Y is the direction axis of lamps in blender
    

    This seems to produce correctly rotated lights on the latest ObjectHelper (r8951).

  • Profile picture of udoprog udoprog1p said 3 months, 3 weeks ago:

    Same also applies to spotLights at.

    http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java#217

  • Profile picture of udoprog udoprog1p said 3 months, 3 weeks ago:

    Sorry for flood posting, I don’t appear to be able to edit my posts.

    Allright, two more issues with SpotLight loading.

    Looking at com.jme3.scene.plugins.blender.lights.LightHelper.

    1)
    Blender defines the angle of the spotlight beam in degrees, meaning 180 degrees would be a beam shooting out 90 degrees on the spotlight direction axis.

    JME3 outerAngle/innerAngle is from the spotlight direction axis and is currently mapped directly from blender, see.

    http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/blender/com/jme3/scene/plugins/blender/lights/LightHelper.java#89

    Which should in fact be.

    float outerAngle = ((Number) structure.getFieldValue("spotsize")).floatValue()*FastMath.DEG_TO_RAD / 2;
    

    2)
    The range is by default defined as inverse square. And JME3 apparently only uses linear falloff with distance / range. So either no other falloff but linear should be loaded with an exception / warning in any other case, or JME3 should support more types of falloffs :) .

    This is not a biggie since blender can be configured to render with linear falloff aswell, and therefore give an accurate scene representation.

  • Profile picture of Momoko_Fan Momoko_Fan366p said 3 months, 3 weeks ago:

    @Kaelthas: ?

  • Profile picture of Kaelthas Kaelthas57p said 3 months, 2 weeks ago:

    Thanks @udoprog for pointing this out.

    The fixes are already in svn :)

  • Profile picture of udoprog udoprog1p said 3 months, 2 weeks ago:

    Glad to help, keep up the awesome work!