Importing different light types from Blender

I want to import a simple level scene from blender, but the Blender importer does not support the “sun” light type from blender. So does anybody know how to setup Blender, so it will import a DirectionalLight in jme or something similar?

Also I wonder why the sun light does not get imported as a DirectionalLight? (Probably @Kaelthas has to answer this)

Thank you!
Green Lightning

Be a man. Create light with your code! :smiley:

[java]
void setLight() {
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.8f, -0.6f, -0.08f).normalizeLocal());
dl.setColor(new ColorRGBA(1.2f,0.9f,0.8f,1f));
rootNode.addLight(dl);

    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(1.7f,2.2f,3.2f,1f));
    rootNode.addLight(al);           
}

[/java]

Don’t add many lights. This is a common problem of newbies. :slight_smile:
One directLight and AmbientLight will be good enough for your first scene.

Yeah, that’s what I’m currently doing. What about if I want to create a night level though? I can’t change the lighting in my blend files. :frowning:

I’ll probably just program a workaround then. Scanning the scene for any node starting with “create_directional_light” and then parsing the rest of the name to create the light will be good enough…

There are many approaches for night scenes.
You can add point lights (2 or 3) but it will decrease the performance.
Or you can bake lighting to lightmaps/emissionmaps and use it in some way with shaders.
Also, post filter will help you to create nightlight.

But what about the code that creates the lights? It’ll light up the night levels as well…

i would suggest to start from day light. nightlight is pretty complex.

Yes night has many problems, due to being far more complex as usually you have more smaller lights at night.

I suggest for a ngihtscene to bake lightmaps directly inside blender, that way you can have as many lights as you want if they are static.

You should create different objects in your code for day and night levels - Just loading the model file and hope, that everything that’s different in those types of levels in encoded in your blend-file doesn’t make much sense.
You could create a class “Level” and subclasses “DayLevel”, “NightLevel” - Those will specify the blend file to load, add the lights, modify the sky texture etc. etc…
Model files should only contain model information (Performance reasons are an exception - e.g. baking lightmaps for a lot of static lights makes sense).

Just my opinion. :wink:

@destroflyer said: Just loading the model file and hope, that everything that's different in those types of levels in encoded in your blend-file doesn't make much sense. [...] Model files should only contain model information

Well I think it is well possible to use a blender file not as a model file but as a level file which contains all important information. For example I use empties with special names to tell the game where to spawn players etc. Therefore the level designer can just create everything in blender which is much nicer than having to change your code.

In this manner I also wanted to configure the lighting in blender, though I think this is not possible :frowning: However, I’m going to workaround this with a level xml file which will probably contain a description of the level, the path to it’s blender file and the lightning configuration in the finished game…

Anyway, my original question was not about day and night levels, but about importing lights from blender:
I’ve also looked at the code from the blender importer, and I see no reason why “sun” is not mapped to “DirectionalLight”. It just prints a warning message and does nothing. Also the “Hemi” light type creates a “Directional Light”, but it is not configured in any way (color and direction are not set). I don’t know why this is the case, probably the different light types aren’t just that important.

The focus is on importing models, as most people set up their scene either in code or using the scene composer in the SDK.

Yes, as all our documentation states, you can only expect meshes and uv maps to import. Anything else doesn’t make sense as the differences in how applications achieve the different effects are too vast and most of these are not meant for live rendering. Even (or especially) light sources are affected by that because the propagation of the light is dependent on the implementation which is mostly raytrace-based in 3d editors.

1 Like

Thank you!