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.
Make a copy of
Main.java
and name the classWaterSimple.java
. Remember to also refactor the first line of themain()
method to the following:WaterSimple app = new WaterSimple();
Create a class field for the node grouping the reflected scene.
private Node reflectedScene;
Create a class field for the light's direction.
private Vector3f lightDir = new Vector3f(-0.39f, -0.32f, -0.74f);
Initialize a
DirectionalLight
.public void simpleInitApp() { DirectionalLight dl = new DirectionalLight(); dl.setDirection(lightDir); rootNode.addLight(dl);
Initialize the
reflectedScene
node and attach it to therootNode
.reflectedScene = new Node("Scene"); rootNode.attachChild(reflectedScene);
Add some scene elements, such as a sky and at least one geometry. Attach both to the
reflectedScene
node...