O'Reilly logo

jMonkeyEngine 3.0 Beginner's Guide by Ruth Kusterer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – welcome to Dark Town

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:

  1. Make a copy of Main.java and name the class ShadowDirectional.java. Remember to also refactor the first line of the main() method to ShadowDirectional app = new ShadowDirectional().
  2. 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);
  3. Create a DirectionalLightShadowRenderer object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required