From the point of view of a 3D engine, shading and lighting are two separate things. You may have noticed that, by default, our walls, bricks, and cannon balls don't cast drop shadows onto the floor or on each other.
This is how you can activate drop shadows using a SceneProcessor:
Make a copy of
Main.java
and name the classShadowDirectional.java
. Remember to also refactor the first line of themain()
method toShadowDirectional app = new ShadowDirectional()
.Create a directional light source and add it to the scene:
public void simpleInitApp() { DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(.3f, -0.5f, -0.5f)); rootNode.addLight(sun);
Create a
DirectionalLightShadowRenderer
object in thesimpleInitApp()
method. You find it in thecom.jme3.shadow
package. InitializeDirectionalLightShadowRenderer
and use thesetLight()
method to link it to the global light source:DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer...