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.
- 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 ...
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.