In my previous thread, y’all helped me finally get a cube imported from Blender with its normalmap intact. However, it seems that a side effect of importing a material from Blender instead of creating it in JME3, is that the material will not reflect ambient light, and just appears black if the only light in the scene is ambient.
(Files: .blend file | normal map image)
All I’ve done is drop the .blend and .png into the Models folder, convert the .blend to .j3o, and add + an ambient light to the scene (code below). Oh, I also had to go in and delete the Camera, Point Light, and Lamp from the generated .j3o file (because I forgot to delete those from the .blend) to make sure there weren’t extra lights adding confusions.
It was suggested that the Blender Importer doesn’t properly set the “UseMaterialColors” property on the j3o’s built-in material, and I don’t see a way to set that easily (since the Node object doesn’t have a getMaterial() method). I could make a new material and apply it manually, but the fix I found for the normalmap problem was to STOP using custom materials and let the Blender Importer take care of it. =T
So, is there a good way to edit the properties of a pre-existing material on an imported Blender model (or at least get it to default “UserMaterialColors” to true)? Or do I need to go back to the other thread and try to find a way to assign .j3m’s in the code or scene editor without messing up my normalmaps?
Here’s my simple lil’ program:
public void simpleInitApp() {
Node geom = (Node)assetManager.loadModel(“Models/normalCubeTri.j3o”);
TangentBinormalGenerator.generate(geom);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(1,-1,-2).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.attachChild(geom);
rootNode.addLight(sun); //if you comment this out, all is darkness
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(.4f));
rootNode.addLight(al);
}
Alternatively, is there some other commonly-accepted way of getting .blend models into JME3 aside from converting them directly to j3o’s? If I’m forced to resort to some more venerable approach in order to get both Normal Maps and Ambient Lights working nicely together, I’m willing to look into it. =)