159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/* 259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Copyright (c) 2009-2012 jMonkeyEngine 359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * All rights reserved. 459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Redistribution and use in source and binary forms, with or without 659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * modification, are permitted provided that the following conditions are 759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * met: 859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * * Redistributions of source code must retain the above copyright 1059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * notice, this list of conditions and the following disclaimer. 1159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 1259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * * Redistributions in binary form must reproduce the above copyright 1359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * notice, this list of conditions and the following disclaimer in the 1459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * documentation and/or other materials provided with the distribution. 1559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 1659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * * Neither the name of 'jMonkeyEngine' nor the names of its contributors 1759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * may be used to endorse or promote products derived from this software 1859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * without specific prior written permission. 1959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 2059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 2459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 2859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 2959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 3259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapackage com.jme3.water; 3359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 3459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.asset.AssetManager; 3559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.export.InputCapsule; 3659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.export.JmeExporter; 3759b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.export.JmeImporter; 3859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.export.OutputCapsule; 3959b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.light.DirectionalLight; 4059b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.light.Light; 4159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.material.Material; 4259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.math.*; 4359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.post.Filter; 4459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.post.Filter.Pass; 4559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.renderer.Camera; 4659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.renderer.RenderManager; 4759b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.renderer.ViewPort; 4859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.Node; 4959b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.Spatial; 5059b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Image.Format; 5159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture.WrapMode; 5259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture2D; 5359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.util.TempVars; 5459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.io.IOException; 5559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 5659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/** 5759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * The WaterFilter is a 2D post process that simulate water. 5859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * It renders water above and under water. 5959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * See this blog post for more info <a href="http://jmonkeyengine.org/2011/01/15/new-advanced-water-effect-for-jmonkeyengine-3/">http://jmonkeyengine.org/2011/01/15/new-advanced-water-effect-for-jmonkeyengine-3/</a> 6059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 6159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 6259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @author Rémy Bouquet aka Nehon 6359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 6459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapublic class WaterFilter extends Filter { 6559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 6659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Pass reflectionPass; 6759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected Spatial reflectionScene; 6859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected ViewPort reflectionView; 6959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Texture2D normalTexture; 7059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Texture2D foamTexture; 7159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Texture2D causticsTexture; 7259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Texture2D heightTexture; 7359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Plane plane; 7459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Camera reflectionCam; 7559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected Ray ray = new Ray(); 7659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Vector3f targetLocation = new Vector3f(); 7759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private ReflectionProcessor reflectionProcessor; 7859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Matrix4f biasMatrix = new Matrix4f(0.5f, 0.0f, 0.0f, 0.5f, 7959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 0.0f, 0.5f, 0.0f, 0.5f, 8059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 0.0f, 0.0f, 0.0f, 0.5f, 8159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 0.0f, 0.0f, 0.0f, 1.0f); 8259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Matrix4f textureProjMatrix = new Matrix4f(); 8359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean underWater; 8459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private RenderManager renderManager; 8559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private ViewPort viewPort; 8659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float time = 0; 8759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta //properties 8859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float speed = 1; 8959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Vector3f lightDirection = new Vector3f(0, -1, 0); 9059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private ColorRGBA lightColor = ColorRGBA.White; 9159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float waterHeight = 0.0f; 9259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private ColorRGBA waterColor = new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f); 9359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private ColorRGBA deepWaterColor = new ColorRGBA(0.0039f, 0.00196f, 0.145f, 1.0f); 9459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Vector3f colorExtinction = new Vector3f(5.0f, 20.0f, 30.0f); 9559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float waterTransparency = 0.1f; 9659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float maxAmplitude = 1.5f; 9759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float shoreHardness = 0.1f; 9859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean useFoam = true; 9959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float foamIntensity = 0.5f; 10059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float foamHardness = 1.0f; 10159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Vector3f foamExistence = new Vector3f(0.45f, 4.35f, 1.5f); 10259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float waveScale = 0.005f; 10359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float sunScale = 3.0f; 10459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float shininess = 0.7f; 10559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private Vector2f windDirection = new Vector2f(0.0f, -1.0f); 10659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private int reflectionMapSize = 512; 10759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean useRipples = true; 10859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float normalScale = 3.0f; 10959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean useHQShoreline = true; 11059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean useSpecular = true; 11159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean useRefraction = true; 11259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float refractionStrength = 0.0f; 11359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float refractionConstant = 0.5f; 11459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float reflectionDisplace = 30; 11559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float underWaterFogDistance = 120; 11659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private boolean useCaustics = true; 11759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private float causticsIntensity = 0.5f; 11859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 11959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 12059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Create a Water Filter 12159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 12259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public WaterFilter() { 12359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta super("WaterFilter"); 12459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 12559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 12659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public WaterFilter(Node reflectionScene, Vector3f lightDirection) { 12759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta super("WaterFilter"); 12859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.reflectionScene = reflectionScene; 12959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.lightDirection = lightDirection; 13059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 13159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 13259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 13359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected boolean isRequiresDepthTexture() { 13459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return true; 13559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 13659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 13759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 13859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected void preFrame(float tpf) { 13959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta time = time + (tpf * speed); 14059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("Time", time); 14159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta Camera sceneCam = viewPort.getCamera(); 14259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta biasMatrix.mult(sceneCam.getViewProjectionMatrix(), textureProjMatrix); 14359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setMatrix4("TextureProjMatrix", textureProjMatrix); 14459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("CameraPosition", sceneCam.getLocation()); 14559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setMatrix4("ViewProjectionMatrixInverse", sceneCam.getViewProjectionMatrix().invert()); 14659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 14759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("WaterHeight", waterHeight); 14859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 14959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta //update reflection cam 15059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ray.setOrigin(sceneCam.getLocation()); 15159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ray.setDirection(sceneCam.getDirection()); 15259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta plane = new Plane(Vector3f.UNIT_Y, new Vector3f(0, waterHeight, 0).dot(Vector3f.UNIT_Y)); 15359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionProcessor.setReflectionClipPlane(plane); 15459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta boolean inv = false; 15559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (!ray.intersectsWherePlane(plane, targetLocation)) { 15659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ray.setDirection(ray.getDirection().negateLocal()); 15759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta ray.intersectsWherePlane(plane, targetLocation); 15859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta inv = true; 15959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 16059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta Vector3f loc = plane.reflect(sceneCam.getLocation(), new Vector3f()); 16159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionCam.setLocation(loc); 16259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionCam.setFrustum(sceneCam.getFrustumNear(), 16359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta sceneCam.getFrustumFar(), 16459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta sceneCam.getFrustumLeft(), 16559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta sceneCam.getFrustumRight(), 16659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta sceneCam.getFrustumTop(), 16759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta sceneCam.getFrustumBottom()); 16859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta TempVars vars = TempVars.get(); 16959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 17059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 17159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta vars.vect1.set(sceneCam.getLocation()).addLocal(sceneCam.getUp()); 17259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta float planeDistance = plane.pseudoDistance(vars.vect1); 17359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta vars.vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f); 17459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta vars.vect3.set(vars.vect1.subtractLocal(vars.vect2)).subtractLocal(loc).normalizeLocal().negateLocal(); 17559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 17659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionCam.lookAt(targetLocation, vars.vect3); 17759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta vars.release(); 17859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 17959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (inv) { 18059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal()); 18159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 18259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 18359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta //if we're under water no need to compute reflection 18459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (sceneCam.getLocation().y >= waterHeight) { 18559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta boolean rtb = true; 18659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (!renderManager.isHandleTranslucentBucket()) { 18759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta renderManager.setHandleTranslucentBucket(true); 18859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta rtb = false; 18959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 19059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta renderManager.renderViewPort(reflectionView, tpf); 19159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (!rtb) { 19259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta renderManager.setHandleTranslucentBucket(false); 19359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 19459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta renderManager.setCamera(sceneCam, false); 19559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); 19659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 19759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 19859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta underWater = false; 19959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } else { 20059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta underWater = true; 20159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 20259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 20359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 20459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 20559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected Material getMaterial() { 20659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return material; 20759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 20859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 20959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta private DirectionalLight findLight(Node node) { 21059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta for (Light light : node.getWorldLightList()) { 21159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (light instanceof DirectionalLight) { 21259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return (DirectionalLight) light; 21359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 21459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 21559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta for (Spatial child : node.getChildren()) { 21659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (child instanceof Node) { 21759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return findLight((Node) child); 21859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 21959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 22059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 22159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return null; 22259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 22359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 22459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 22559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { 22659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 22759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (reflectionScene == null) { 22859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionScene = vp.getScenes().get(0); 22959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta DirectionalLight l = findLight((Node) reflectionScene); 23059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (l != null) { 23159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta lightDirection = l.getDirection(); 23259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 23359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 23459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 23559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 23659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.renderManager = renderManager; 23759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.viewPort = vp; 23859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionPass = new Pass(); 23959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth); 24059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionCam = new Camera(reflectionMapSize, reflectionMapSize); 24159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionView = new ViewPort("reflectionView", reflectionCam); 24259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionView.setClearFlags(true, true, true); 24359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionView.attachScene(reflectionScene); 24459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionView.setOutputFrameBuffer(reflectionPass.getRenderFrameBuffer()); 24559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta plane = new Plane(Vector3f.UNIT_Y, new Vector3f(0, waterHeight, 0).dot(Vector3f.UNIT_Y)); 24659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionProcessor = new ReflectionProcessor(reflectionCam, reflectionPass.getRenderFrameBuffer(), plane); 24759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionView.addProcessor(reflectionProcessor); 24859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 24959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta normalTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/water_normalmap.dds"); 25059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (foamTexture == null) { 25159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta foamTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/foam.jpg"); 25259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 25359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (causticsTexture == null) { 25459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta causticsTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/caustics.jpg"); 25559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 25659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta heightTexture = (Texture2D) manager.loadTexture("Common/MatDefs/Water/Textures/heightmap.jpg"); 25759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 25859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta normalTexture.setWrap(WrapMode.Repeat); 25959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta foamTexture.setWrap(WrapMode.Repeat); 26059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta causticsTexture.setWrap(WrapMode.Repeat); 26159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta heightTexture.setWrap(WrapMode.Repeat); 26259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 26359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material = new Material(manager, "Common/MatDefs/Water/Water.j3md"); 26459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("HeightMap", heightTexture); 26559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("CausticsMap", causticsTexture); 26659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("FoamMap", foamTexture); 26759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("NormalMap", normalTexture); 26859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("ReflectionMap", reflectionPass.getRenderedTexture()); 26959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 27059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("WaterTransparency", waterTransparency); 27159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("NormalScale", normalScale); 27259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("R0", refractionConstant); 27359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("MaxAmplitude", maxAmplitude); 27459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("LightDir", lightDirection); 27559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setColor("LightColor", lightColor); 27659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("ShoreHardness", shoreHardness); 27759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("RefractionStrength", refractionStrength); 27859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("WaveScale", waveScale); 27959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("FoamExistence", foamExistence); 28059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("SunScale", sunScale); 28159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("ColorExtinction", colorExtinction); 28259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("Shininess", shininess); 28359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setColor("WaterColor", waterColor); 28459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setColor("DeepWaterColor", deepWaterColor); 28559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector2("WindDirection", windDirection); 28659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("FoamHardness", foamHardness); 28759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseRipples", useRipples); 28859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseHQShoreline", useHQShoreline); 28959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseSpecular", useSpecular); 29059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseFoam", useFoam); 29159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseCaustics", useCaustics); 29259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseRefraction", useRefraction); 29359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("ReflectionDisplace", reflectionDisplace); 29459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("FoamIntensity", foamIntensity); 29559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("UnderWaterFogDistance", underWaterFogDistance); 29659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("CausticsIntensity", causticsIntensity); 29759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 29859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 29959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 30059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 30159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 30259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void write(JmeExporter ex) throws IOException { 30359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta super.write(ex); 30459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta OutputCapsule oc = ex.getCapsule(this); 30559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 30659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(speed, "speed", 1f); 30759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(lightDirection, "lightDirection", new Vector3f(0, -1, 0)); 30859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(lightColor, "lightColor", ColorRGBA.White); 30959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(waterHeight, "waterHeight", 0.0f); 31059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(waterColor, "waterColor", new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f)); 31159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(deepWaterColor, "deepWaterColor", new ColorRGBA(0.0039f, 0.00196f, 0.145f, 1.0f)); 31259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 31359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(colorExtinction, "colorExtinction", new Vector3f(5.0f, 20.0f, 30.0f)); 31459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(waterTransparency, "waterTransparency", 0.1f); 31559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(maxAmplitude, "maxAmplitude", 1.5f); 31659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(shoreHardness, "shoreHardness", 0.1f); 31759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(useFoam, "useFoam", true); 31859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 31959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(foamIntensity, "foamIntensity", 0.5f); 32059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(foamHardness, "foamHardness", 1.0f); 32159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 32259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(foamExistence, "foamExistence", new Vector3f(0.45f, 4.35f, 1.5f)); 32359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(waveScale, "waveScale", 0.005f); 32459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 32559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(sunScale, "sunScale", 3.0f); 32659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(shininess, "shininess", 0.7f); 32759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(windDirection, "windDirection", new Vector2f(0.0f, -1.0f)); 32859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(reflectionMapSize, "reflectionMapSize", 512); 32959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(useRipples, "useRipples", true); 33059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 33159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(normalScale, "normalScale", 3.0f); 33259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(useHQShoreline, "useHQShoreline", true); 33359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 33459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(useSpecular, "useSpecular", true); 33559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 33659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(useRefraction, "useRefraction", true); 33759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(refractionStrength, "refractionStrength", 0.0f); 33859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(refractionConstant, "refractionConstant", 0.5f); 33959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(reflectionDisplace, "reflectionDisplace", 30f); 34059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(underWaterFogDistance, "underWaterFogDistance", 120f); 34159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(causticsIntensity, "causticsIntensity", 0.5f); 34259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 34359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta oc.write(useCaustics, "useCaustics", true); 34459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 34559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 34659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta @Override 34759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void read(JmeImporter im) throws IOException { 34859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta super.read(im); 34959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta InputCapsule ic = im.getCapsule(this); 35059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta speed = ic.readFloat("speed", 1f); 35159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta lightDirection = (Vector3f) ic.readSavable("lightDirection", new Vector3f(0, -1, 0)); 35259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta lightColor = (ColorRGBA) ic.readSavable("lightColor", ColorRGBA.White); 35359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta waterHeight = ic.readFloat("waterHeight", 0.0f); 35459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta waterColor = (ColorRGBA) ic.readSavable("waterColor", new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f)); 35559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta deepWaterColor = (ColorRGBA) ic.readSavable("deepWaterColor", new ColorRGBA(0.0039f, 0.00196f, 0.145f, 1.0f)); 35659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 35759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta colorExtinction = (Vector3f) ic.readSavable("colorExtinction", new Vector3f(5.0f, 20.0f, 30.0f)); 35859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta waterTransparency = ic.readFloat("waterTransparency", 0.1f); 35959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta maxAmplitude = ic.readFloat("maxAmplitude", 1.5f); 36059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta shoreHardness = ic.readFloat("shoreHardness", 0.1f); 36159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta useFoam = ic.readBoolean("useFoam", true); 36259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 36359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta foamIntensity = ic.readFloat("foamIntensity", 0.5f); 36459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta foamHardness = ic.readFloat("foamHardness", 1.0f); 36559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 36659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta foamExistence = (Vector3f) ic.readSavable("foamExistence", new Vector3f(0.45f, 4.35f, 1.5f)); 36759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta waveScale = ic.readFloat("waveScale", 0.005f); 36859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 36959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta sunScale = ic.readFloat("sunScale", 3.0f); 37059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta shininess = ic.readFloat("shininess", 0.7f); 37159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta windDirection = (Vector2f) ic.readSavable("windDirection", new Vector2f(0.0f, -1.0f)); 37259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionMapSize = ic.readInt("reflectionMapSize", 512); 37359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta useRipples = ic.readBoolean("useRipples", true); 37459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 37559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta normalScale = ic.readFloat("normalScale", 3.0f); 37659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta useHQShoreline = ic.readBoolean("useHQShoreline", true); 37759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 37859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta useSpecular = ic.readBoolean("useSpecular", true); 37959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 38059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta useRefraction = ic.readBoolean("useRefraction", true); 38159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta refractionStrength = ic.readFloat("refractionStrength", 0.0f); 38259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta refractionConstant = ic.readFloat("refractionConstant", 0.5f); 38359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta reflectionDisplace = ic.readFloat("reflectionDisplace", 30f); 38459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta underWaterFogDistance = ic.readFloat("underWaterFogDistance", 120f); 38559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta causticsIntensity = ic.readFloat("causticsIntensity", 0.5f); 38659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 38759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta useCaustics = ic.readBoolean("useCaustics", true); 38859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 38959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 39059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 39159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 39259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * gets the height of the water plane 39359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 39459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 39559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getWaterHeight() { 39659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return waterHeight; 39759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 39859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 39959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 40059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the height of the water plane 40159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 0.0 40259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param waterHeight 40359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 40459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setWaterHeight(float waterHeight) { 40559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.waterHeight = waterHeight; 40659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 40759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 40859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 40959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the scene to render in the reflection map 41059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param reflectionScene 41159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 41259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setReflectionScene(Spatial reflectionScene) { 41359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.reflectionScene = reflectionScene; 41459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 41559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 41659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 41759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the waterTransparency value 41859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 41959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 42059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getWaterTransparency() { 42159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return waterTransparency; 42259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 42359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 42459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 42559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets how fast will colours fade out. You can also think about this 42659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * values as how clear water is. Therefore use smaller values (eg. 0.05) 42759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * to have crystal clear water and bigger to achieve "muddy" water. 42859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 0.1f 42959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param waterTransparency 43059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 43159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setWaterTransparency(float waterTransparency) { 43259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.waterTransparency = waterTransparency; 43359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 43459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("WaterTransparency", waterTransparency); 43559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 43659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 43759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 43859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 43959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Returns the normal scales applied to the normal map 44059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 44159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 44259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getNormalScale() { 44359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return normalScale; 44459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 44559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 44659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 44759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the normal scaling factors to apply to the normal map. 44859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the higher the value the more small ripples will be visible on the waves. 44959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 1.0 45059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param normalScale 45159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 45259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setNormalScale(float normalScale) { 45359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.normalScale = normalScale; 45459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 45559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("NormalScale", normalScale); 45659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 45759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 45859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 45959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 46059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the refractoin constant 46159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 46259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 46359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getRefractionConstant() { 46459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return refractionConstant; 46559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 46659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 46759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 46859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * This is a constant related to the index of refraction (IOR) used to compute the fresnel term. 46959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * F = R0 + (1-R0)( 1 - N.V)^5 47059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * where F is the fresnel term, R0 the constant, N the normal vector and V tne view vector. 47159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * It usually depend on the material you are lookinh through (here water). 47259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Default value is 0.3f 47359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * In practice, the lowest the value and the less the reflection can be seen on water 47459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param refractionConstant 47559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 47659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setRefractionConstant(float refractionConstant) { 47759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.refractionConstant = refractionConstant; 47859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 47959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("R0", refractionConstant); 48059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 48159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 48259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 48359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 48459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * return the maximum wave amplitude 48559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 48659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 48759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getMaxAmplitude() { 48859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return maxAmplitude; 48959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 49059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 49159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 49259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the maximum waves amplitude 49359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 1.0 49459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param maxAmplitude 49559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 49659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setMaxAmplitude(float maxAmplitude) { 49759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.maxAmplitude = maxAmplitude; 49859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 49959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("MaxAmplitude", maxAmplitude); 50059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 50159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 50259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 50359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 50459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * gets the light direction 50559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 50659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 50759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public Vector3f getLightDirection() { 50859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return lightDirection; 50959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 51059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 51159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 51259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the light direction 51359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param lightDirection 51459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 51559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setLightDirection(Vector3f lightDirection) { 51659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.lightDirection = lightDirection; 51759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 51859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("LightDir", lightDirection); 51959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 52059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 52159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 52259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 52359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the light color 52459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 52559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 52659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public ColorRGBA getLightColor() { 52759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return lightColor; 52859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 52959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 53059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 53159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the light color to use 53259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is white 53359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param lightColor 53459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 53559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setLightColor(ColorRGBA lightColor) { 53659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.lightColor = lightColor; 53759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 53859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setColor("LightColor", lightColor); 53959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 54059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 54159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 54259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 54359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Return the shoreHardeness 54459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 54559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 54659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getShoreHardness() { 54759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return shoreHardness; 54859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 54959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 55059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 55159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * The smaller this value is, the softer the transition between 55259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * shore and water. If you want hard edges use very big value. 55359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Default is 0.1f. 55459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param shoreHardness 55559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 55659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setShoreHardness(float shoreHardness) { 55759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.shoreHardness = shoreHardness; 55859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 55959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("ShoreHardness", shoreHardness); 56059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 56159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 56259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 56359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 56459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the foam hardness 56559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 56659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 56759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getFoamHardness() { 56859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return foamHardness; 56959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 57059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 57159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 57259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the foam hardness : How much the foam will blend with the shore to avoid hard edged water plane. 57359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Default is 1.0 57459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param foamHardness 57559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 57659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setFoamHardness(float foamHardness) { 57759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.foamHardness = foamHardness; 57859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 57959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("FoamHardness", foamHardness); 58059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 58159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 58259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 58359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 58459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the refractionStrenght 58559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 58659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 58759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getRefractionStrength() { 58859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return refractionStrength; 58959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 59059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 59159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 59259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * This value modifies current fresnel term. If you want to weaken 59359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * reflections use bigger value. If you want to empasize them use 59459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * value smaller then 0. Default is 0.0f. 59559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param refractionStrength 59659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 59759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setRefractionStrength(float refractionStrength) { 59859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.refractionStrength = refractionStrength; 59959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 60059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("RefractionStrength", refractionStrength); 60159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 60259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 60359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 60459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 60559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the scale factor of the waves height map 60659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 60759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 60859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getWaveScale() { 60959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return waveScale; 61059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 61159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 61259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 61359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the scale factor of the waves height map 61459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the smaller the value the bigger the waves 61559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 0.005f 61659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param waveScale 61759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 61859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setWaveScale(float waveScale) { 61959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.waveScale = waveScale; 62059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 62159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("WaveScale", waveScale); 62259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 62359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 62459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 62559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 62659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the foam existance vector 62759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 62859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 62959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public Vector3f getFoamExistence() { 63059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return foamExistence; 63159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 63259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 63359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 63459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Describes at what depth foam starts to fade out and 63559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * at what it is completely invisible. The third value is at 63659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * what height foam for waves appear (+ waterHeight). 63759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is (0.45, 4.35, 1.0); 63859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param foamExistence 63959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 64059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setFoamExistence(Vector3f foamExistence) { 64159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.foamExistence = foamExistence; 64259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 64359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("FoamExistence", foamExistence); 64459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 64559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 64659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 64759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 64859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * gets the scale of the sun 64959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 65059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 65159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getSunScale() { 65259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return sunScale; 65359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 65459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 65559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 65659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the scale of the sun for specular effect 65759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param sunScale 65859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 65959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setSunScale(float sunScale) { 66059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.sunScale = sunScale; 66159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 66259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("SunScale", sunScale); 66359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 66459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 66559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 66659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 66759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Returns the color exctinction vector of the water 66859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 66959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 67059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public Vector3f getColorExtinction() { 67159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return colorExtinction; 67259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 67359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 67459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 67559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Return at what depth the refraction color extinct 67659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the first value is for red 67759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the second is for green 67859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the third is for blue 67959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Play with thos parameters to "trouble" the water 68059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is (5.0, 20.0, 30.0f); 68159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param colorExtinction 68259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 68359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setColorExtinction(Vector3f colorExtinction) { 68459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.colorExtinction = colorExtinction; 68559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 68659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector3("ColorExtinction", colorExtinction); 68759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 68859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 68959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 69059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 69159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the foam texture 69259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param foamTexture 69359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 69459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setFoamTexture(Texture2D foamTexture) { 69559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.foamTexture = foamTexture; 69659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta foamTexture.setWrap(WrapMode.Repeat); 69759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 69859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("FoamMap", foamTexture); 69959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 70059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 70159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 70259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 70359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the height texture 70459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param heightTexture 70559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 70659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setHeightTexture(Texture2D heightTexture) { 70759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.heightTexture = heightTexture; 70859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta heightTexture.setWrap(WrapMode.Repeat); 70959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 71059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 71159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 71259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the normal Texture 71359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param normalTexture 71459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 71559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setNormalTexture(Texture2D normalTexture) { 71659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.normalTexture = normalTexture; 71759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta normalTexture.setWrap(WrapMode.Repeat); 71859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 71959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 72059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 72159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * return the shininess factor of the water 72259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 72359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 72459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getShininess() { 72559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return shininess; 72659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 72759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 72859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 72959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the shinines factor of the water 73059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 0.7f 73159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param shininess 73259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 73359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setShininess(float shininess) { 73459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.shininess = shininess; 73559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 73659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("Shininess", shininess); 73759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 73859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 73959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 74059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 74159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * retruns the speed of the waves 74259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 74359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 74459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getSpeed() { 74559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return speed; 74659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 74759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 74859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 74959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Set the speed of the waves (0.0 is still) default is 1.0 75059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param speed 75159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 75259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setSpeed(float speed) { 75359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.speed = speed; 75459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 75559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 75659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 75759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the color of the water 75859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 75959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 76059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 76159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public ColorRGBA getWaterColor() { 76259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return waterColor; 76359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 76459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 76559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 76659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the color of the water 76759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * see setDeepWaterColor for deep water color 76859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is (0.0078f, 0.5176f, 0.5f,1.0f) (greenish blue) 76959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param waterColor 77059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 77159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setWaterColor(ColorRGBA waterColor) { 77259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.waterColor = waterColor; 77359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 77459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setColor("WaterColor", waterColor); 77559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 77659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 77759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 77859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 77959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the deep water color 78059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 78159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 78259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public ColorRGBA getDeepWaterColor() { 78359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return deepWaterColor; 78459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 78559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 78659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 78759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the deep water color 78859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * see setWaterColor for general color 78959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is (0.0039f, 0.00196f, 0.145f,1.0f) (very dark blue) 79059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param deepWaterColor 79159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 79259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setDeepWaterColor(ColorRGBA deepWaterColor) { 79359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.deepWaterColor = deepWaterColor; 79459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 79559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setColor("DeepWaterColor", deepWaterColor); 79659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 79759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 79859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 79959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 80059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the wind direction 80159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 80259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 80359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public Vector2f getWindDirection() { 80459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return windDirection; 80559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 80659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 80759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 80859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the wind direction 80959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * the direction where the waves move 81059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is (0.0f, -1.0f) 81159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param windDirection 81259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 81359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setWindDirection(Vector2f windDirection) { 81459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.windDirection = windDirection; 81559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 81659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setVector2("WindDirection", windDirection); 81759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 81859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 81959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 82059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 82159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the size of the reflection map 82259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 82359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 82459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public int getReflectionMapSize() { 82559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return reflectionMapSize; 82659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 82759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 82859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 82959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the size of the reflection map 83059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 512, the higher, the better quality, but the slower the effect. 83159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param reflectionMapSize 83259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 83359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setReflectionMapSize(int reflectionMapSize) { 83459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.reflectionMapSize = reflectionMapSize; 83559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 83659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 83759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 83859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns true if the water uses foam 83959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 84059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 84159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUseFoam() { 84259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return useFoam; 84359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 84459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 84559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 84659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * set to true to use foam with water 84759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default true 84859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param useFoam 84959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 85059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUseFoam(boolean useFoam) { 85159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.useFoam = useFoam; 85259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 85359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseFoam", useFoam); 85459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 85559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 85659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 85759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 85859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 85959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the texture to use to render caustics on the ground underwater 86059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param causticsTexture 86159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 86259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setCausticsTexture(Texture2D causticsTexture) { 86359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.causticsTexture = causticsTexture; 86459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 86559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setTexture("causticsMap", causticsTexture); 86659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 86759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 86859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 86959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 87059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns true if caustics are rendered 87159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 87259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 87359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUseCaustics() { 87459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return useCaustics; 87559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 87659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 87759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 87859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * set to true if you want caustics to be rendered on the ground underwater, false otherwise 87959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param useCaustics 88059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 88159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUseCaustics(boolean useCaustics) { 88259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.useCaustics = useCaustics; 88359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 88459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseCaustics", useCaustics); 88559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 88659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 88759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 88859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 88959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * return true 89059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 89159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 89259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUseHQShoreline() { 89359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return useHQShoreline; 89459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 89559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 89659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUseHQShoreline(boolean useHQShoreline) { 89759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.useHQShoreline = useHQShoreline; 89859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 89959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseHQShoreline", useHQShoreline); 90059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 90159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 90259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 90359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 90459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 90559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns true if the water use the refraction 90659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 90759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 90859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUseRefraction() { 90959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return useRefraction; 91059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 91159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 91259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 91359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * set to true to use refraction (default is true) 91459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param useRefraction 91559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 91659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUseRefraction(boolean useRefraction) { 91759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.useRefraction = useRefraction; 91859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 91959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseRefraction", useRefraction); 92059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 92159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 92259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 92359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 92459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 92559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns true if the ater use ripples 92659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 92759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 92859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUseRipples() { 92959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return useRipples; 93059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 93159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 93259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 93359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * 93459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Set to true tu use ripples 93559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param useRipples 93659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 93759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUseRipples(boolean useRipples) { 93859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.useRipples = useRipples; 93959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 94059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseRipples", useRipples); 94159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 94259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 94359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 94459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 94559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 94659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns true if the water use specular 94759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 94859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 94959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUseSpecular() { 95059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return useSpecular; 95159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 95259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 95359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 95459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Set to true to use specular lightings on the water 95559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param useSpecular 95659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 95759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUseSpecular(boolean useSpecular) { 95859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.useSpecular = useSpecular; 95959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 96059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setBoolean("UseSpecular", useSpecular); 96159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 96259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 96359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 96459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 96559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the foam intensity 96659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 96759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 96859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getFoamIntensity() { 96959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return foamIntensity; 97059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 97159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 97259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 97359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the foam intensity default is 0.5f 97459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param foamIntensity 97559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 97659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setFoamIntensity(float foamIntensity) { 97759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.foamIntensity = foamIntensity; 97859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 97959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("FoamIntensity", foamIntensity); 98059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 98159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 98259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 98359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 98459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 98559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the reflection displace 98659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * see {@link setReflectionDisplace(float reflectionDisplace)} 98759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 98859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 98959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getReflectionDisplace() { 99059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return reflectionDisplace; 99159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 99259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 99359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 99459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Sets the reflection displace. define how troubled will look the reflection in the water. default is 30 99559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param reflectionDisplace 99659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 99759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setReflectionDisplace(float reflectionDisplace) { 99859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.reflectionDisplace = reflectionDisplace; 99959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 100059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("m_ReflectionDisplace", reflectionDisplace); 100159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 100259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 100359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 100459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 100559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns true if the camera is under the water level 100659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 100759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 100859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public boolean isUnderWater() { 100959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return underWater; 101059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 101159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 101259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 101359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * returns the distance of the fog when under water 101459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 101559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 101659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getUnderWaterFogDistance() { 101759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return underWaterFogDistance; 101859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 101959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 102059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 102159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the distance of the fog when under water. 102259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * default is 120 (120 world units) use a high value to raise the view range under water 102359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param underWaterFogDistance 102459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 102559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setUnderWaterFogDistance(float underWaterFogDistance) { 102659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.underWaterFogDistance = underWaterFogDistance; 102759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 102859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("UnderWaterFogDistance", underWaterFogDistance); 102959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 103059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 103159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 103259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 103359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * get the intensity of caustics under water 103459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @return 103559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 103659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public float getCausticsIntensity() { 103759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta return causticsIntensity; 103859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 103959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta 104059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta /** 104159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * sets the intensity of caustics under water. goes from 0 to 1, default is 0.5f 104259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @param causticsIntensity 104359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */ 104459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta public void setCausticsIntensity(float causticsIntensity) { 104559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta this.causticsIntensity = causticsIntensity; 104659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta if (material != null) { 104759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta material.setFloat("CausticsIntensity", causticsIntensity); 104859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 104959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta } 105059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta} 1051