First we create an illuminated sphere with a blue material, using a normal geometry with a material based on the Lighting.j3md
material definition:
Make a copy of
Main.java
and name the classMaterialColor.java
. Remember to also refactor the first line of themain()
method toMaterialColor app = new MaterialColor ();
.Replace the blue cube code in the
simpleInitApp()
method with the following:Sphere sphereMesh = new Sphere(32,32, 1f); Geometry sphereGeo = new Geometry("Colored lit sphere", sphereMesh); Material sphereMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); sphereMat.setBoolean("UseMaterialColors", true); sphereMat.setColor("Diffuse", ColorRGBA.Blue ); sphereMat.setColor("Ambient", ColorRGBA.Gray ); sphereGeo.setMaterial(sphereMat); rootNode.attachChild(sphereGeo);
Remember to add light sources to make the illuminated material visible!
Run the sample. As opposed to our plain blue cube, this blue, illuminated sphere clearly...