Time for action – welcome to Dark City

For larger scenes, you should try a DirectionalLightShadowFilter object from the com.jme3.shadow package.

You can use a copy of ShadowDirectional.java for the following exercise:

  1. Add a directional light source to the scene:
    public void simpleInitApp() {
      DirectionalLight sunLight = new DirectionalLight();
      sunLight.setDirection(new Vector3f(.3f, -0.5f, -0.5f));
      rootNode.addLight(sunLight);
  2. If you re-use code from the ShadowDirectional.java class, deactivate the previously created DirectionalLightShadowRenderer object, or at least comment out its addProcessor() line:
    // viewPort.addProcessor(dlsr); 
  3. Create a DirectionalLightShadowFilter object in the simpleInitApp() method. Use the setLight() method to specify your ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.