com.jmex.effects.water
Class WaterRenderPass

java.lang.Object
  extended by com.jme.renderer.pass.Pass
      extended by com.jmex.effects.water.WaterRenderPass
All Implemented Interfaces:
java.io.Serializable

public class WaterRenderPass
extends Pass

WaterRenderPass Water effect pass.

Version:
$Id: WaterRenderPass.java 4133 2009-03-19 20:40:11Z blaine.dev $
Author:
Rikard Herlitz (MrCoder)
See Also:
Serialized Form

Field Summary
protected  boolean aboveWater
           
protected  BlendState as1
           
protected  Vector3f binormal
           
protected  Vector3f calcVect
           
protected  Camera cam
           
protected  float clipBias
           
protected  ClipState clipState
           
protected  CullState cullBackFace
           
protected  java.lang.String currentShaderStr
           
static java.lang.String dudvMapTextureString
           
static java.lang.String fallbackMapTextureString
           
protected  TextureState fallbackTextureState
           
static java.lang.String foamMapTextureString
           
protected  float heightFalloffSpeed
           
protected  float heightFalloffStart
           
protected  FogState noFog
           
static java.lang.String normalMapTextureString
           
protected  float normalTranslation
           
static java.lang.String projectedShaderRefractionStr
           
static java.lang.String projectedShaderStr
           
protected  float reflectionThrottle
           
protected  float reflectionTime
           
protected  float refractionThrottle
           
protected  float refractionTime
           
protected  float refractionTranslation
           
protected  java.util.ArrayList<Spatial> renderList
           
protected  int renderScale
           
static java.lang.String simpleShaderRefractionStr
           
static java.lang.String simpleShaderStr
           
protected  Node skyBox
           
protected  float speedReflection
           
protected  float speedRefraction
           
protected  boolean supported
           
protected  Vector3f tangent
           
protected  java.util.ArrayList<Texture> texArray
           
protected  Texture2D textureDepth
           
protected  Texture2D textureReflect
           
protected  Texture2D textureRefract
           
protected  TextureState textureState
           
protected  float tpf
           
protected  TextureRenderer tRenderer
           
protected  boolean useFadeToFogColor
           
protected  boolean useProjectedShader
           
protected  boolean useReflection
           
protected  boolean useRefraction
           
protected  ColorRGBA waterColorEnd
           
protected  ColorRGBA waterColorStart
           
protected  float waterMaxAmplitude
           
protected  Plane waterPlane
           
protected  GLSLShaderObjectsState waterShader
           
 
Fields inherited from class com.jme.renderer.pass.Pass
context, enabled, passStates, savedStates, spatials, zFactor, zOffset
 
Constructor Summary
WaterRenderPass(Camera cam, int renderScale, boolean useProjectedShader, boolean useRefraction)
          Creates a new WaterRenderPass
 
Method Summary
 void addReflectedScene(Spatial renderNode)
          Adds a spatial to the list of spatials used as reflection in the water
 void cleanup()
          Release pbuffers in TextureRenderer's.
 void clearReflectedScene()
           
 void doRender(Renderer r)
           
protected  void doUpdate(float tpf)
           
 Vector3f getBinormal()
           
 Camera getCam()
           
 float getClipBias()
           
 Texture getDudvTexture()
           
 Texture getFallbackTexture()
           
 Texture getFoamTexture()
           
 float getHeightFalloffSpeed()
           
 float getHeightFalloffStart()
           
 Vector3f getNormal()
           
 Texture getNormalmapTexture()
           
 float getReflectionThrottle()
           
 float getRefractionThrottle()
           
 int getRenderScale()
           
 float getSpeedReflection()
           
 float getSpeedRefraction()
           
 Vector3f getTangent()
           
 Texture getTextureDepth()
           
 Texture getTextureReflect()
           
 Texture getTextureRefract()
           
 TextureState getTextureState()
           
 ColorRGBA getWaterColorEnd()
           
 ColorRGBA getWaterColorStart()
           
 float getWaterHeight()
           
 float getWaterMaxAmplitude()
           
 Plane getWaterPlane()
           
 boolean isSupported()
           
 boolean isUseFadeToFogColor()
           
 boolean isUseProjectedShader()
           
 boolean isUseReflection()
           
 boolean isUseRefraction()
           
 void reloadShader()
           
 void removeReflectedScene(Spatial renderNode)
           
 void resetParameters()
          Resets water parameters to default values
 void setBinormal(Vector3f binormal)
           
 void setCam(Camera cam)
           
 void setClipBias(float clipBias)
           
 void setDudvTexture(Texture dudvTexture)
           
 void setFallbackEffectOnSpatial(Spatial spatial)
           
 void setFallbackTexture(Texture fallbackTexture)
           
 void setFoamTexture(Texture foamTexture)
           
 void setHeightFalloffSpeed(float heightFalloffSpeed)
          Set the fadeout length of the waveheights, when over falloff start(for projected water only)
 void setHeightFalloffStart(float heightFalloffStart)
          Set at what distance the waveheights should start to fade out(for projected water only)
 void setNormal(Vector3f normal)
          Set the normal of the waterplane(Used for reflecting the camera for rendering reflection)
 void setNormalmapTexture(Texture normalmapTexture)
           
 void setReflectedScene(Spatial renderNode)
          Sets spatial to be used as reflection in the water(clears previously set)
 void setReflectionThrottle(float reflectionThrottle)
           
 void setRefractionThrottle(float refractionThrottle)
           
 void setRenderScale(int renderScale)
           
 void setSkybox(Node skyBox)
          Sets up a node to be transformed and clipped for skybox usage
 void setSpeedReflection(float speedReflection)
          Set the movement speed of the reflectiontexture
 void setSpeedRefraction(float speedRefraction)
          Set the movement speed of the refractiontexture
 void setTangent(Vector3f tangent)
           
 void setTextureState(TextureState textureState)
           
protected  void setupTextures()
           
 void setUseProjectedShader(boolean useProjectedShader)
           
 void setUseReflection(boolean useReflection)
          Turn reflection on and off
 void setUseRefraction(boolean useRefraction)
          Turn refraction on and off
 void setWaterColorEnd(ColorRGBA waterColorEnd)
          Color to use when the incident angle to the surface is high
 void setWaterColorStart(ColorRGBA waterColorStart)
          Color to use when the incident angle to the surface is low
 void setWaterEffectOnSpatial(Spatial spatial)
          Sets a spatial up for being rendered with the watereffect
 void setWaterEffectOnSpatial(Spatial spatial, boolean useTransparency)
           
 void setWaterHeight(float waterHeight)
          Set base height of the waterplane(Used for reflecting the camera for rendering reflection)
 void setWaterMaxAmplitude(float waterMaxAmplitude)
          Maximum amplitude of the water, used for clipping correctly(projected water only)
 void setWaterPlane(Plane waterPlane)
           
 void updateCamera()
           
protected  void updateTranslations()
           
 void useFadeToFogColor(boolean value)
          If true, fade to fogcolor.
 
Methods inherited from class com.jme.renderer.pass.Pass
add, applyPassStates, cleanUp, clearPassState, clearPassState, clearPassStates, contains, get, getRenderState, getRenderState, getZFactor, getZOffset, isEnabled, remove, removeAll, renderPass, resetOldStates, setEnabled, setPassState, setZFactor, setZOffset, size, updatePass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cam

protected Camera cam

tpf

protected float tpf

reflectionThrottle

protected float reflectionThrottle

refractionThrottle

protected float refractionThrottle

reflectionTime

protected float reflectionTime

refractionTime

protected float refractionTime

useFadeToFogColor

protected boolean useFadeToFogColor

tRenderer

protected TextureRenderer tRenderer

textureReflect

protected Texture2D textureReflect

textureRefract

protected Texture2D textureRefract

textureDepth

protected Texture2D textureDepth

renderList

protected java.util.ArrayList<Spatial> renderList

texArray

protected java.util.ArrayList<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

clipState

protected ClipState clipState

noFog

protected FogState noFog

waterPlane

protected Plane waterPlane

tangent

protected Vector3f tangent

binormal

protected Vector3f binormal

calcVect

protected Vector3f calcVect

clipBias

protected float clipBias

waterColorStart

protected ColorRGBA waterColorStart

waterColorEnd

protected ColorRGBA waterColorEnd

heightFalloffStart

protected float heightFalloffStart

heightFalloffSpeed

protected float heightFalloffSpeed

waterMaxAmplitude

protected float waterMaxAmplitude

speedReflection

protected float speedReflection

speedRefraction

protected float speedRefraction

aboveWater

protected boolean aboveWater

normalTranslation

protected float normalTranslation

refractionTranslation

protected float refractionTranslation

supported

protected boolean supported

useProjectedShader

protected boolean useProjectedShader

useRefraction

protected boolean useRefraction

useReflection

protected boolean useReflection

renderScale

protected int renderScale

simpleShaderStr

public static java.lang.String simpleShaderStr

simpleShaderRefractionStr

public static java.lang.String simpleShaderRefractionStr

projectedShaderStr

public static java.lang.String projectedShaderStr

projectedShaderRefractionStr

public static java.lang.String projectedShaderRefractionStr

currentShaderStr

protected java.lang.String currentShaderStr

normalMapTextureString

public static java.lang.String normalMapTextureString

dudvMapTextureString

public static java.lang.String dudvMapTextureString

foamMapTextureString

public static java.lang.String foamMapTextureString

fallbackMapTextureString

public static java.lang.String fallbackMapTextureString
Constructor Detail

WaterRenderPass

public WaterRenderPass(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 Detail

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()

doUpdate

protected void doUpdate(float tpf)
Overrides:
doUpdate in class Pass

doRender

public void doRender(Renderer r)
Specified by:
doRender in class Pass

updateTranslations

protected void updateTranslations()

reloadShader

public void reloadShader()

setWaterEffectOnSpatial

public void setWaterEffectOnSpatial(Spatial spatial,
                                    boolean useTransparency)

setWaterEffectOnSpatial

public void setWaterEffectOnSpatial(Spatial spatial)
Sets a spatial up for being rendered with the watereffect

Parameters:
spatial - Spatial to use as base for the watereffect

setFallbackEffectOnSpatial

public void setFallbackEffectOnSpatial(Spatial spatial)

removeReflectedScene

public void removeReflectedScene(Spatial renderNode)

clearReflectedScene

public void clearReflectedScene()

setReflectedScene

public void setReflectedScene(Spatial renderNode)
Sets spatial to be used as reflection in the water(clears previously set)

Parameters:
renderNode - Spatial to use as reflection in the water

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 skybox usage

Parameters:
skyBox - Handle to a node to use as skybox

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


getWaterColorEnd

public ColorRGBA getWaterColorEnd()

setWaterColorEnd

public void setWaterColorEnd(ColorRGBA waterColorEnd)
Color to use when the incident angle to the surface is high


getHeightFalloffStart

public float getHeightFalloffStart()

setHeightFalloffStart

public void setHeightFalloffStart(float heightFalloffStart)
Set at what distance the waveheights should start to fade out(for projected water only)

Parameters:
heightFalloffStart -

getHeightFalloffSpeed

public float getHeightFalloffSpeed()

setHeightFalloffSpeed

public void setHeightFalloffSpeed(float heightFalloffSpeed)
Set the fadeout length of the waveheights, when over falloff start(for projected water only)

Parameters:
heightFalloffStart -

getWaterHeight

public float getWaterHeight()

setWaterHeight

public void setWaterHeight(float waterHeight)
Set base height of the waterplane(Used for reflecting the camera for rendering reflection)

Parameters:
waterHeight - Waterplane height

getNormal

public Vector3f getNormal()

setNormal

public void setNormal(Vector3f normal)
Set the normal of the waterplane(Used for reflecting the camera for rendering reflection)

Parameters:
normal - Waterplane normal

getSpeedReflection

public float getSpeedReflection()

setSpeedReflection

public void setSpeedReflection(float speedReflection)
Set the movement speed of the reflectiontexture

Parameters:
speedReflection - Speed of reflectiontexture

getSpeedRefraction

public float getSpeedRefraction()

setSpeedRefraction

public void setSpeedRefraction(float speedRefraction)
Set the movement speed of the refractiontexture

Parameters:
speedRefraction - Speed of refractiontexture

getWaterMaxAmplitude

public float getWaterMaxAmplitude()

setWaterMaxAmplitude

public void setWaterMaxAmplitude(float waterMaxAmplitude)
Maximum amplitude of the water, used for clipping correctly(projected water only)

Parameters:
waterMaxAmplitude - Maximum amplitude

getClipBias

public float getClipBias()

setClipBias

public void setClipBias(float clipBias)

getWaterPlane

public Plane getWaterPlane()

setWaterPlane

public void setWaterPlane(Plane waterPlane)

getTangent

public Vector3f getTangent()

setTangent

public void setTangent(Vector3f tangent)

getBinormal

public Vector3f getBinormal()

setBinormal

public void setBinormal(Vector3f binormal)

getTextureReflect

public Texture getTextureReflect()

getTextureRefract

public Texture getTextureRefract()

getTextureDepth

public Texture getTextureDepth()

useFadeToFogColor

public void useFadeToFogColor(boolean value)
If true, fade to fogcolor. If false, fade to 100% reflective surface

Parameters:
value -

isUseFadeToFogColor

public boolean isUseFadeToFogColor()

isUseReflection

public boolean isUseReflection()

setUseReflection

public void setUseReflection(boolean useReflection)
Turn reflection on and off

Parameters:
useReflection -

isUseRefraction

public boolean isUseRefraction()

setUseRefraction

public void setUseRefraction(boolean useRefraction)
Turn refraction on and off

Parameters:
useRefraction -

getRenderScale

public int getRenderScale()

setRenderScale

public void setRenderScale(int renderScale)

isUseProjectedShader

public boolean isUseProjectedShader()

setUseProjectedShader

public void setUseProjectedShader(boolean useProjectedShader)

getReflectionThrottle

public float getReflectionThrottle()

setReflectionThrottle

public void setReflectionThrottle(float reflectionThrottle)

getRefractionThrottle

public float getRefractionThrottle()

setRefractionThrottle

public void setRefractionThrottle(float 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()