Lighting How-to

Hello, I’m new here :slight_smile:



I found the following tutorial for lighting:



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:light_and_shadow



Which is good and all, but I don’t want to use the tea pot, I want to use simple boxes and spheres. Which material can i use which supports the Color property as well as light parameters (Ambien, Diffuse, Specular, etc.) ?



Thanks in advance.

Nothing stopping you from using Lighting.j3md for Box and Sphere shapes. The game I’m working on does exactly that.



[java]

public ColorRGBA getDiffuse(ColorRGBA base) {

ColorRGBA color = base.clone();

color.interpolate(ColorRGBA.Black, 0.1f);

return base;

}



public ColorRGBA getAmbient(ColorRGBA base) {

ColorRGBA color = base.clone();

color.interpolate(ColorRGBA.Black, 0.5f);

return color;

}



public Material materialForColor(ColorRGBA color) {

Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat.setFloat(“Shininess”, Float.MAX_VALUE);

mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Diffuse”, getDiffuse(color));

mat.setColor(“Ambient”, getAmbient(color));

mat.setColor(“Specular”, ColorRGBA.Gray);

return mat;

}

[/java]


  • ryan