Hi,
basicaly I have the box from blender exported as “Example.obj”.
I am loading it to my scene like that
Model = AssetManager.loadModel("\\Modelle\\Menus\\Example.obj");
mat_default = new Material( AssetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_default.setColor("Color", ColorRGBA.Green);
mat_default.setBoolean("VertexColor",false);
Model.setMaterial(mat_default);
rootNode.attachChild(Model);
Model.setLocalTranslation(0,0,-50);
That works fine and is showing me my green box. Anyhow I read into Material Definition Properties :: jMonkeyEngine Docs about Light and shadow and tutorials etc.
I understand that by the code above I can show my box without additional light source. But I like to use a light source to have the ability to use the effects that come with it.
I tried
Model2 = Assetmanager.loadModel("Example.obj");
Material mat_default2 = new Material( AssetManager, "Common/MatDefs/Light/Lighting.j3md");
mat_default2.setBoolean("UseMaterialColors",true);
mat_default2.setColor("Diffuse", ColorRGBA.Blue);
Model2.setMaterial(mat_default2);
rootNode.attachChild(Model2);
Model2.setLocalTranslation(0,0,-50);
AmbientLight al = new AmbientLight();
rootNode.addLight(al);
But nothing is displayed. Also adding
mat_default2.setColor("Specular",ColorRGBA.White);
mat_default2.setFloat("Shininess", 64f);
or adding a directional light dont make a difference.
When I load a “ready to use” model I always have to add the light before I can see it. The wiki says: Add UV Mapping in blender.
Anyhow: What I want is:
Change the color of my model during runtime and have the abillity to use spotlight (with light radius) or even shadow etc.
Currently I can achieve changing color by using the Unshaded.j3md Material and update that material during runtime.
I realy have no experience either with Blender nor with materials/ material definition.
So my question is:
What is the way to load an simple model from blender, being able to change its color while JME is running and how make the visibility depend on added light sources.