Class WaterNode

All Implemented Interfaces:
Hintable, Savable

public class WaterNode extends Node
The WaterNode handles rendering of a water effect on all of it's children. What is reflected in the water is controlled through setReflectedScene/addReflectedScene. The skybox (if any) needs to be explicitly set through setSkybox since it needs to be relocated when rendering the reflection. The water is treated as a plane no matter what the geometry is, which is controlled through the water node plane equation settings.
  • Field Details

    • cam

      protected Camera cam
    • tpf

      protected double tpf
    • reflectionThrottle

      protected double reflectionThrottle
    • refractionThrottle

      protected double refractionThrottle
    • reflectionTime

      protected double reflectionTime
    • refractionTime

      protected double refractionTime
    • useFadeToFogColor

      protected boolean useFadeToFogColor
    • tRenderer

      protected TextureRenderer tRenderer
    • textureReflect

      protected Texture2D textureReflect
    • textureReflectBlur

      protected Texture2D textureReflectBlur
    • textureRefract

      protected Texture2D textureRefract
    • textureDepth

      protected Texture2D textureDepth
    • renderList

      protected List<Spatial> renderList
    • texArray

      protected List<Texture> texArray
    • skyBox

      protected Node skyBox
    • waterShader

      protected GLSLShaderObjectsState waterShader
    • cullBackFace

      protected CullState cullBackFace
    • textureState

      protected TextureState textureState
    • fallbackTextureState

      protected TextureState fallbackTextureState
    • as1

      protected BlendState as1
    • noFog

      protected FogState noFog
    • waterPlane

      protected Plane waterPlane
    • tangent

      protected Vector3 tangent
    • binormal

      protected Vector3 binormal
    • calcVect

      protected Vector3 calcVect
    • clipBias

      protected double clipBias
    • waterColorStart

      protected ColorRGBA waterColorStart
    • waterColorEnd

      protected ColorRGBA waterColorEnd
    • heightFalloffStart

      protected double heightFalloffStart
    • heightFalloffSpeed

      protected double heightFalloffSpeed
    • waterMaxAmplitude

      protected double waterMaxAmplitude
    • speedReflection

      protected double speedReflection
    • speedRefraction

      protected double speedRefraction
    • aboveWater

      protected boolean aboveWater
    • normalTranslation

      protected double normalTranslation
    • refractionTranslation

      protected double refractionTranslation
    • supported

      protected boolean supported
    • useProjectedShader

      protected boolean useProjectedShader
    • useRefraction

      protected boolean useRefraction
    • useReflection

      protected boolean useReflection
    • renderScale

      protected int renderScale
    • simpleShaderStr

      protected String simpleShaderStr
    • simpleShaderRefractionStr

      protected String simpleShaderRefractionStr
    • projectedShaderStr

      protected String projectedShaderStr
    • projectedShaderRefractionStr

      protected String projectedShaderRefractionStr
    • currentShaderStr

      protected String currentShaderStr
    • normalMapTextureString

      protected String normalMapTextureString
    • dudvMapTextureString

      protected String dudvMapTextureString
    • foamMapTextureString

      protected String foamMapTextureString
    • fallbackMapTextureString

      protected String fallbackMapTextureString
  • Constructor Details

    • WaterNode

      public WaterNode(Camera cam, int renderScale, boolean useProjectedShader, boolean useRefraction)
      Creates a new WaterRenderPass
      Parameters:
      cam - main rendercam to use for reflection settings etc
      renderScale - how many times smaller the reflection/refraction textures should be compared to the main display
      useProjectedShader - true - use the projected setup for variable height water meshes, false - use the flast shader setup
      useRefraction - enable/disable rendering of refraction textures
  • Method Details

    • resetParameters

      public void resetParameters()
      Resets water parameters to default values
    • cleanup

      public void cleanup()
      Release pbuffers in TextureRenderer's. Preferably called from user cleanup method.
    • isSupported

      public boolean isSupported()
    • setupTextures

      protected void setupTextures()
      Load water textures.
    • update

      public void update(double tpf)
    • draw

      public void draw(Renderer r)
      Description copied from class: Node
      draw calls the onDraw method for each child maintained by this node.
      Overrides:
      draw in class Node
      Parameters:
      r - the renderer to draw to.
      See Also:
    • updateTranslations

      protected void updateTranslations()
    • reloadShader

      public void reloadShader()
    • setWaterEffectOnSpatial

      public void setWaterEffectOnSpatial(Spatial spatial)
      Sets a spatial up for being rendered with the water effect
      Parameters:
      spatial - Spatial to use as base for the water effect
    • removeReflectedScene

      public void removeReflectedScene(Spatial renderNode)
    • clearReflectedScene

      public void clearReflectedScene()
    • addReflectedScene

      public void addReflectedScene(Spatial renderNode)
      Adds a spatial to the list of spatials used as reflection in the water
      Parameters:
      renderNode - Spatial to add to the list of objects used as reflection in the water
    • setSkybox

      public void setSkybox(Node skyBox)
      Sets up a node to be transformed and clipped for sky box usage
      Parameters:
      skyBox - Handle to a node to use as sky box
    • getCam

      public Camera getCam()
    • setCam

      public void setCam(Camera cam)
    • getWaterColorStart

      public ColorRGBA getWaterColorStart()
    • setWaterColorStart

      public void setWaterColorStart(ColorRGBA waterColorStart)
      Color to use when the incident angle to the surface is low
      Parameters:
      waterColorStart - the color to use when the incident angle to the surface is low
    • getWaterColorEnd

      public ColorRGBA getWaterColorEnd()
    • setWaterColorEnd

      public void setWaterColorEnd(ColorRGBA waterColorEnd)
      Color to use when the incident angle to the surface is high
      Parameters:
      waterColorEnd - the color to use when the incident angle to the surface is high
    • getHeightFalloffStart

      public double getHeightFalloffStart()
    • setHeightFalloffStart

      public void setHeightFalloffStart(double heightFalloffStart)
      Set at what distance the wave heights should start to fade out(for projected water only)
      Parameters:
      heightFalloffStart - the distance the wave heights should start to fade out
    • getHeightFalloffSpeed

      public double getHeightFalloffSpeed()
    • setHeightFalloffSpeed

      public void setHeightFalloffSpeed(double heightFalloffSpeed)
      Set the fadeout length of the waveheights, when over falloff start(for projected water only)
      Parameters:
      heightFalloffSpeed - the the fadeout length of the waveheights
    • getWaterHeight

      public double getWaterHeight()
    • setWaterHeight

      public void setWaterHeight(double waterHeight)
      Set base height of the water plane(Used for reflecting the camera for rendering reflection)
      Parameters:
      waterHeight - the water plane height
    • getNormal

      public ReadOnlyVector3 getNormal()
    • setNormal

      public void setNormal(Vector3 normal)
      Set the normal of the water plane(Used for reflecting the camera for rendering reflection)
      Parameters:
      normal - the water plane normal
    • getSpeedReflection

      public double getSpeedReflection()
    • setSpeedReflection

      public void setSpeedReflection(double speedReflection)
      Set the movement speed of the reflection texture
      Parameters:
      speedReflection - the speed of reflection texture
    • getSpeedRefraction

      public double getSpeedRefraction()
    • setSpeedRefraction

      public void setSpeedRefraction(double speedRefraction)
      Set the movement speed of the refraction texture
      Parameters:
      speedRefraction - the speed of refraction texture
    • getWaterMaxAmplitude

      public double getWaterMaxAmplitude()
    • setWaterMaxAmplitude

      public void setWaterMaxAmplitude(double waterMaxAmplitude)
      Maximum amplitude of the water, used for clipping correctly(projected water only)
      Parameters:
      waterMaxAmplitude - the maximum amplitude
    • getClipBias

      public double getClipBias()
    • setClipBias

      public void setClipBias(double clipBias)
    • getWaterPlane

      public Plane getWaterPlane()
    • setWaterPlane

      public void setWaterPlane(Plane waterPlane)
    • getTangent

      public Vector3 getTangent()
    • setTangent

      public void setTangent(Vector3 tangent)
    • getBinormal

      public Vector3 getBinormal()
    • setBinormal

      public void setBinormal(Vector3 binormal)
    • getTextureReflect

      public Texture getTextureReflect()
    • getTextureRefract

      public Texture getTextureRefract()
    • getTextureDepth

      public Texture getTextureDepth()
    • useFadeToFogColor

      public void useFadeToFogColor(boolean value)
      If true, fade to fog color. If false, fade to 100% reflective surface
      Parameters:
      value - true if fade to fog color
    • isUseFadeToFogColor

      public boolean isUseFadeToFogColor()
    • isUseReflection

      public boolean isUseReflection()
    • setUseReflection

      public void setUseReflection(boolean useReflection)
      Turn reflection on and off
      Parameters:
      useReflection - true if the reflection is turned on
    • isUseRefraction

      public boolean isUseRefraction()
    • setUseRefraction

      public void setUseRefraction(boolean useRefraction)
      Turn refraction on and off
      Parameters:
      useRefraction - true if the refraction is turned on
    • getRenderScale

      public int getRenderScale()
    • setRenderScale

      public void setRenderScale(int renderScale)
    • isUseProjectedShader

      public boolean isUseProjectedShader()
    • setUseProjectedShader

      public void setUseProjectedShader(boolean useProjectedShader)
    • getReflectionThrottle

      public double getReflectionThrottle()
    • setReflectionThrottle

      public void setReflectionThrottle(double reflectionThrottle)
    • getRefractionThrottle

      public double getRefractionThrottle()
    • setRefractionThrottle

      public void setRefractionThrottle(double refractionThrottle)
    • getTextureState

      public TextureState getTextureState()
    • setTextureState

      public void setTextureState(TextureState textureState)
    • updateCamera

      public void updateCamera()
    • setFallbackTexture

      public void setFallbackTexture(Texture fallbackTexture)
    • getFallbackTexture

      public Texture getFallbackTexture()
    • setNormalmapTexture

      public void setNormalmapTexture(Texture normalmapTexture)
    • getNormalmapTexture

      public Texture getNormalmapTexture()
    • setDudvTexture

      public void setDudvTexture(Texture dudvTexture)
    • getDudvTexture

      public Texture getDudvTexture()
    • setFoamTexture

      public void setFoamTexture(Texture foamTexture)
    • getFoamTexture

      public Texture getFoamTexture()
    • getNormalMapTextureString

      public String getNormalMapTextureString()
      Returns:
      the normalMapTextureString
    • setNormalMapTextureString

      public void setNormalMapTextureString(String normalMapTextureString)
      Parameters:
      normalMapTextureString - the normalMapTextureString to set
    • getDudvMapTextureString

      public String getDudvMapTextureString()
      Returns:
      the dudvMapTextureString
    • setDudvMapTextureString

      public void setDudvMapTextureString(String dudvMapTextureString)
      Parameters:
      dudvMapTextureString - the dudvMapTextureString to set
    • getFoamMapTextureString

      public String getFoamMapTextureString()
      Returns:
      the foamMapTextureString
    • setFoamMapTextureString

      public void setFoamMapTextureString(String foamMapTextureString)
      Parameters:
      foamMapTextureString - the foamMapTextureString to set
    • getFallbackMapTextureString

      public String getFallbackMapTextureString()
      Returns:
      the fallbackMapTextureString
    • setFallbackMapTextureString

      public void setFallbackMapTextureString(String fallbackMapTextureString)
      Parameters:
      fallbackMapTextureString - the fallbackMapTextureString to set
    • isDoBlurReflection

      public boolean isDoBlurReflection()
    • setDoBlurReflection

      public void setDoBlurReflection(boolean doBlurReflection)
    • getBlurSampleDistance

      public float getBlurSampleDistance()
    • setBlurSampleDistance

      public void setBlurSampleDistance(float blurSampleDistance)