Time for action – simple water

A correctly simulated water surface reflects the scene around it—or to be more precise, it reflects everything attached to a specific scene node that you supply.

  1. Make a copy of Main.java and name the class WaterSimple.java. Remember to also refactor the first line of the main() method to the following:
    WaterSimple app = new WaterSimple();
  2. Create a class field for the node grouping the reflected scene.
    private Node reflectedScene;
  3. Create a class field for the light's direction.
        private Vector3f lightDir = 
          new Vector3f(-0.39f, -0.32f, -0.74f);
  4. Initialize a DirectionalLight.
      public void simpleInitApp() {
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(lightDir);
        rootNode.addLight(dl);
  5. Initialize the reflectedScene ...

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.