// Need to setup fog cause the water use it for various calculations.
setupFog();
// Collect everything we want reflected in the water under a node.
final Node reflectedNode = new Node("reflectNode");
reflectedNode.attachChild(createObjects());
buildSkyBox();
reflectedNode.attachChild(skybox);
_root.attachChild(reflectedNode);
final Camera cam = _canvas.getCanvasRenderer().getCamera();
// Create a new WaterNode with refraction enabled.
waterNode = new WaterNode(cam, 4, false, true);
// Setup textures to use for the water.
waterNode.setNormalMapTextureString("images/water/normalmap3.dds");
waterNode.setDudvMapTextureString("images/water/dudvmap.png");
waterNode.setFallbackMapTextureString("images/water/water2.png");
// setting to default value just to show
waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 0.0));
// Create a quad to use as geometry for the water.
waterQuad = new Quad("waterQuad", 1, 1);
// Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as
// we move this is more convenient than rotating the quad.
final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer();
normBuf.clear();
normBuf.put(0).put(1).put(0);
normBuf.put(0).put(1).put(0);
normBuf.put(0).put(1).put(0);
normBuf.put(0).put(1).put(0);
waterNode.attachChild(waterQuad);
waterNode.addReflectedScene(reflectedNode);
waterNode.setSkybox(skybox);
_root.attachChild(waterNode);
// Setyp textfields for presenting example info.
final Node textNodes = new Node("Text");
_root.attachChild(textNodes);
textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);
final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2;
for (int i = 0; i < _exampleInfo.length; i++) {
_exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
_exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0));
textNodes.attachChild(_exampleInfo[i]);
}
textNodes.updateGeometricState(0.0);
updateText();
// Register keyboard triggers for manipulating example
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {