Default Blender loader import multiple materials not shown


Please can someone offer some guidance on the blender importer?

I am trying to import a blender model programatically using the default asset manager registered loader.
The imported spatial has 2 materials {blue and white in the example} but the third material is a shade of grey
Also none of the materials support ambient lighting

Is this a restriction of the blender loader?
Are then any workarounds I can use to set the ambient colour on the model material?

My simple application

import com.jme3.asset.BlenderKey;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;

public class BlenderImport extends SimpleApplication
	private Spatial m_cube = null;
	public void simpleInitApp() 
		BlenderKey keyAsset = new BlenderKey("Cube3colours.blend");
		m_cube = assetManager.loadModel(keyAsset);
		AmbientLight lightAmbient = new AmbientLight();
		lightAmbient.setColor(new ColorRGBA(0.8f, 0.8f, 1.0f, 1.0f).mult(2.0f));
		DirectionalLight lightDirection = new DirectionalLight();		
		lightDirection.setDirection(new Vector3f(0.0f, -1.0f, -1.0f).normalizeLocal());
		viewPort.setBackgroundColor(new ColorRGBA(1.0f, 0.9f, 0.8f, 1.0f));
	public void simpleUpdate(float tpf)
		float fAngle = (float)(Math.PI / 17) * tpf;
		m_cube.rotate(fAngle, 0.0f, fAngle);

	public static void main(String[] ascArgs)
		BlenderImport mainApp = new BlenderImport();

What the blender model looks like …

What the app looks like …

Thank you for any help


I’m pretty sure trying to load a model with multiple materials is going to lead to a bad time.

I would UV map your blender object, then bake the object’s colours to texture, and use that texture as the Diffuse Map for a new, single blender material you can assign to your object.

It would also pay to go over the materials tutorial as very soon you may be wanting to define your own materials.

Thank you for the response @thetoucher

I was hoping to keep everything simple so just model and texture in blender and then use the importer.
Baking and then importing the texture to create a material separately is an option.
And creating a separate material programatically is also an option {though applying multiple materials to separate geometry would be a challenge}

The blender importer documentation page mentions 2 loaders, the default BlenderModelLoader and also BlenderLoader.

I do not know how to separate the materials from the Spatial loaded by the BlenderModelLoader {from the example}.
Because then it might be possible to tweak the material.

Using the BlenderLoader I expected to find a List in the LoadingResults returned by the asset manager, but the list was empty.