public class WaterFilter extends Filter implements JmeCloneable, java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
WaterFilter.AreaShape |
Filter.Pass
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CAUSTICS |
static java.lang.String |
DEFAULT_FOAM |
static java.lang.String |
DEFAULT_HEIGHT_MAP |
static java.lang.String |
DEFAULT_NORMAL_MAP |
protected Spatial |
reflectionScene |
protected ViewPort |
reflectionView |
protected Spatial |
rootScene |
defaultPass, enabled, material, postRenderPasses, processor
Constructor and Description |
---|
WaterFilter()
Create a Water Filter
|
WaterFilter(Node reflectionScene,
Vector3f lightDirection) |
Modifier and Type | Method and Description |
---|---|
protected void |
cleanUpFilter(Renderer r)
override this method if you have some cleanup to do
|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Implemented to perform deep cloning for this object, resolving
local cloned references using the specified cloner.
|
float |
getCausticsIntensity()
get the intensity of caustics under water
|
Texture2D |
getCausticsTexture()
Gets the texture which is used to render caustics on the ground underwater.
|
Vector3f |
getCenter()
returns the center of this effect
|
Vector3f |
getColorExtinction()
Returns the color extinction vector of the water
|
ColorRGBA |
getDeepWaterColor()
returns the deep water color
|
Vector3f |
getFoamExistence()
returns the foam existence vector
|
float |
getFoamHardness()
returns the foam hardness
|
float |
getFoamIntensity()
returns the foam intensity
|
Texture2D |
getFoamTexture()
Gets the foam texture.
|
Texture2D |
getHeightTexture()
Gets the height texture.
|
ColorRGBA |
getLightColor()
returns the light color
|
Vector3f |
getLightDirection()
gets the light direction
|
protected Material |
getMaterial()
Must return the material used for this filter.
|
float |
getMaxAmplitude()
return the maximum wave amplitude
|
float |
getNormalScale()
Returns the normal scales applied to the normal map
|
Texture2D |
getNormalTexture()
Gets the normal texture.
|
float |
getRadius()
returns the radius of this effect
|
float |
getReflectionDisplace()
returns the reflection displace
see
setReflectionDisplace(float) |
int |
getReflectionMapSize()
returns the size of the reflection map
|
Spatial |
getReflectionScene()
Gets the scene which is used to render in the reflection map.
|
float |
getRefractionConstant()
returns the refraction constant
|
float |
getRefractionStrength()
returns the refractionStrength
|
WaterFilter.AreaShape |
getShapeType()
returns the shape of the water area
|
float |
getShininess()
return the shininess factor of the water
|
float |
getShoreHardness()
Return the shore hardness.
|
float |
getSpeed()
returns the speed of the waves
|
float |
getSunScale()
gets the scale of the sun
|
float |
getUnderWaterFogDistance()
returns the distance of the fog when under water
|
ColorRGBA |
getWaterColor()
returns the color of the water
|
float |
getWaterHeight()
gets the height of the water plane
|
float |
getWaterTransparency()
returns the waterTransparency value
|
float |
getWaveScale()
returns the scale factor of the waves height map
|
Vector2f |
getWindDirection()
returns the wind direction
|
protected void |
initFilter(AssetManager manager,
RenderManager renderManager,
ViewPort vp,
int w,
int h)
Initialization of sub classes filters
This method is called once when the filter is added to the FilterPostProcessor
It should contain Material initializations and extra passes initialization
|
boolean |
isNeedSaveReflectionScene() |
protected boolean |
isRequiresDepthTexture()
Override this method and return true if your Filter needs the depth texture
|
boolean |
isUnderWater()
Whether or not the camera is under the water level
|
boolean |
isUseCaustics()
Whether or not caustics are rendered
|
boolean |
isUseFoam()
Whether or not the water uses foam
|
boolean |
isUseHQShoreline()
Whether or not the shader is set to use high-quality shoreline.
|
boolean |
isUseRefraction()
Whether or not the water uses the refraction
|
boolean |
isUseRipples()
Whether or not the water uses ripples
|
boolean |
isUseSpecular()
Whether or not the water is using specular
|
java.lang.Object |
jmeClone()
Performs a regular shallow clone of the object.
|
protected void |
preFrame(float tpf)
Override this method if you want to modify parameters according to tpf before the rendering of the frame.
|
void |
read(JmeImporter im)
Override this method if you want to load extra properties when the filter
is loaded else only basic properties of the filter will be loaded
This method should always begin by super.read(im);
|
void |
setCausticsIntensity(float causticsIntensity)
sets the intensity of caustics under water.
|
void |
setCausticsTexture(Texture2D causticsTexture)
Sets the texture to use to render caustics on the ground underwater.
|
void |
setCenter(Vector3f center)
Set the center of the effect.
|
void |
setColorExtinction(Vector3f colorExtinction)
Return at what depth the refraction color extinct
the first value is for red
the second is for green
the third is for blue
Play with those parameters to "trouble" the water
default is (5.0, 20.0, 30.0f);
|
void |
setDeepWaterColor(ColorRGBA deepWaterColor)
sets the deep water color
see setWaterColor for general color
default is (0.0039f, 0.00196f, 0.145f,1.0f) (very dark blue)
|
void |
setFoamExistence(Vector3f foamExistence)
Describes at what depth foam starts to fade out and
at what it is completely invisible.
|
void |
setFoamHardness(float foamHardness)
Sets the foam hardness : How much the foam will blend with the shore to avoid hard edged water plane.
|
void |
setFoamIntensity(float foamIntensity)
sets the foam intensity default is 0.5f
|
void |
setFoamTexture(Texture2D foamTexture)
Sets the foam texture.
|
void |
setHeightTexture(Texture2D heightTexture)
Sets the height texture
|
void |
setLightColor(ColorRGBA lightColor)
Sets the light color to use
default is white
|
void |
setLightDirection(Vector3f lightDirection)
Sets the light direction
|
void |
setMaxAmplitude(float maxAmplitude)
Sets the maximum waves amplitude
default is 1.5
|
void |
setNeedSaveReflectionScene(boolean needSaveReflectionScene)
Sets the flag.
|
void |
setNormalScale(float normalScale)
Sets the normal scaling factors to apply to the normal map.
|
void |
setNormalTexture(Texture2D normalTexture)
Sets the normal texture.
|
void |
setRadius(float radius)
Set the radius of the effect.
|
void |
setReflectionDisplace(float reflectionDisplace)
Sets the reflection displace.
|
void |
setReflectionMapSize(int reflectionMapSize)
Sets the size of the reflection map
default is 512, the higher, the better quality, but the slower the effect.
|
void |
setReflectionScene(Spatial reflectionScene)
Sets the scene to render in the reflection map.
|
void |
setRefractionConstant(float refractionConstant)
This is a constant related to the index of refraction (IOR) used to compute the fresnel term.
|
void |
setRefractionStrength(float refractionStrength)
This value modifies current fresnel term.
|
void |
setShapeType(WaterFilter.AreaShape shapeType)
Set the shape of the water area (Circular (default) or Square).
|
void |
setShininess(float shininess)
Sets the shininess factor of the water
default is 0.7f
|
void |
setShoreHardness(float shoreHardness)
The smaller this value is, the softer the transition between
shore and water.
|
void |
setSpeed(float speed)
Set the speed of the waves (0.0 is still) default is 1.0
|
void |
setSunScale(float sunScale)
Sets the scale of the sun for specular effect
|
void |
setUnderWaterFogDistance(float underWaterFogDistance)
sets the distance of the fog when under water.
|
void |
setUseCaustics(boolean useCaustics)
set to true if you want caustics to be rendered on the ground underwater, false otherwise
|
void |
setUseFoam(boolean useFoam)
set to true to use foam with water
default true
|
void |
setUseHQShoreline(boolean useHQShoreline) |
void |
setUseRefraction(boolean useRefraction)
set to true to use refraction (default is true)
|
void |
setUseRipples(boolean useRipples)
Set to true to use ripples
|
void |
setUseSpecular(boolean useSpecular)
Set to true to use specular lightings on the water
|
void |
setWaterColor(ColorRGBA waterColor)
Sets the color of the water
see setDeepWaterColor for deep water color
default is (0.0078f, 0.3176f, 0.5f,1.0f) (greenish blue)
|
void |
setWaterHeight(float waterHeight)
Sets the height of the water plane
default is 0.0
|
void |
setWaterTransparency(float waterTransparency)
Sets how fast will colours fade out.
|
void |
setWaveScale(float waveScale)
Sets the scale factor of the waves height map
the smaller the value the bigger the waves
default is 0.005f
|
void |
setWindDirection(Vector2f windDirection)
sets the wind direction
the direction where the waves move
default is (0.0f, -1.0f)
|
protected boolean |
useDirectionLightFromScene() |
void |
write(JmeExporter ex)
Override this method if you want to save extra properties when the filter is saved else only basic properties of the filter will be saved
This method should always begin by super.write(ex);
|
cleanup, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresSceneTexture, postFilter, postFrame, postQueue, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer
public static final java.lang.String DEFAULT_NORMAL_MAP
public static final java.lang.String DEFAULT_FOAM
public static final java.lang.String DEFAULT_CAUSTICS
public static final java.lang.String DEFAULT_HEIGHT_MAP
protected Spatial reflectionScene
protected Spatial rootScene
protected ViewPort reflectionView
protected boolean isRequiresDepthTexture()
Filter
isRequiresDepthTexture
in class Filter
protected void preFrame(float tpf)
Filter
protected Material getMaterial()
Filter
getMaterial
in class Filter
protected boolean useDirectionLightFromScene()
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h)
Filter
initFilter
in class Filter
manager
- the assetManagerrenderManager
- the renderManagervp
- the viewPort where this filter is renderedw
- the width of the filterh
- the height of the filterprotected void cleanUpFilter(Renderer r)
Filter
cleanUpFilter
in class Filter
r
- the rendererpublic void write(JmeExporter ex) throws java.io.IOException
Filter
public void read(JmeImporter im) throws java.io.IOException
Filter
public float getWaterHeight()
public void setWaterHeight(float waterHeight)
waterHeight
- the desired height (default=0)public void setReflectionScene(Spatial reflectionScene)
reflectionScene
- the refraction scene.public Spatial getReflectionScene()
public float getWaterTransparency()
public void setWaterTransparency(float waterTransparency)
waterTransparency
- the desired muddiness (default=0.1)public float getNormalScale()
public void setNormalScale(float normalScale)
normalScale
- the scaling factor (default=3)public float getRefractionConstant()
public void setRefractionConstant(float refractionConstant)
refractionConstant
- the desired R0 value (default=0.5)public float getMaxAmplitude()
public void setMaxAmplitude(float maxAmplitude)
maxAmplitude
- the desired maximum amplitude (default=1.5)public Vector3f getLightDirection()
public void setLightDirection(Vector3f lightDirection)
lightDirection
- the direction vector to use (alias created,
default=(0,-1,0))public ColorRGBA getLightColor()
public void setLightColor(ColorRGBA lightColor)
lightColor
- the color to use (alias created, default=(1,1,1,1))public float getShoreHardness()
public void setShoreHardness(float shoreHardness)
shoreHardness
- the desired hardness (default=0.1)public float getFoamHardness()
public void setFoamHardness(float foamHardness)
foamHardness
- the desired hardness (default=1)public float getRefractionStrength()
public void setRefractionStrength(float refractionStrength)
refractionStrength
- the desired strength (default=0)public float getWaveScale()
public void setWaveScale(float waveScale)
waveScale
- the desired scale factor (default=0.005)public Vector3f getFoamExistence()
public void setFoamExistence(Vector3f foamExistence)
foamExistence
- the desired parameters (alias created)public float getSunScale()
public void setSunScale(float sunScale)
sunScale
- the desired scale factor (default=3)public Vector3f getColorExtinction()
public void setColorExtinction(Vector3f colorExtinction)
colorExtinction
- the desired depth for each color component (alias
created, default=(5,20,30))public void setFoamTexture(Texture2D foamTexture)
foamTexture
- the foam texture.public Texture2D getFoamTexture()
public void setHeightTexture(Texture2D heightTexture)
heightTexture
- the texture to use (alias created)public Texture2D getHeightTexture()
public void setNormalTexture(Texture2D normalTexture)
normalTexture
- the normal texture.public Texture2D getNormalTexture()
public float getShininess()
public void setShininess(float shininess)
shininess
- the desired factor (default=0.7)public float getSpeed()
public void setSpeed(float speed)
speed
- the desired speedup factor (default=1)public ColorRGBA getWaterColor()
public void setWaterColor(ColorRGBA waterColor)
waterColor
- the color to use (alias created,
default=(0.0078,0.3176,0.5,1))public ColorRGBA getDeepWaterColor()
public void setDeepWaterColor(ColorRGBA deepWaterColor)
deepWaterColor
- the color to use (alias created,
default=(0.0039,0.00196,0.145,1))public Vector2f getWindDirection()
public void setWindDirection(Vector2f windDirection)
windDirection
- the direction vector to use (alias created,
default=(0,-1))public int getReflectionMapSize()
public void setReflectionMapSize(int reflectionMapSize)
reflectionMapSize
- the desired size (in pixels per side,
default=512)public boolean isUseFoam()
public void setUseFoam(boolean useFoam)
useFoam
- true for foam, false for no foam (default=true)public void setCausticsTexture(Texture2D causticsTexture)
causticsTexture
- the caustics texture.public Texture2D getCausticsTexture()
public boolean isUseCaustics()
public void setUseCaustics(boolean useCaustics)
useCaustics
- true to enable rendering fo caustics, false to disable
it (default=true)public boolean isUseHQShoreline()
public void setUseHQShoreline(boolean useHQShoreline)
public boolean isUseRefraction()
public void setUseRefraction(boolean useRefraction)
useRefraction
- true to enable refraction, false to disable it
(default=true)public boolean isUseRipples()
public void setUseRipples(boolean useRipples)
useRipples
- true to enable ripples, false to disable them
(default=true)public boolean isUseSpecular()
public void setUseSpecular(boolean useSpecular)
useSpecular
- true to enable the specular effect, false to disable
it (default=true)public float getFoamIntensity()
public void setFoamIntensity(float foamIntensity)
foamIntensity
- the desired intensity (default=0.5)public float getReflectionDisplace()
setReflectionDisplace(float)
public void setReflectionDisplace(float reflectionDisplace)
reflectionDisplace
- the desired displacement (default=30)public boolean isUnderWater()
public float getUnderWaterFogDistance()
public void setUnderWaterFogDistance(float underWaterFogDistance)
underWaterFogDistance
- the desired distance (in world units,
default=120)public float getCausticsIntensity()
public void setCausticsIntensity(float causticsIntensity)
causticsIntensity
- the desired intensity (≥0, ≤1,
default=0.5)public Vector3f getCenter()
public void setCenter(Vector3f center)
center
- the center of the effectpublic float getRadius()
public void setRadius(float radius)
radius
- the radius of the effectpublic WaterFilter.AreaShape getShapeType()
public void setShapeType(WaterFilter.AreaShape shapeType)
shapeType
- the shape typepublic java.lang.Object jmeClone()
JmeCloneable
This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.
jmeClone
in interface JmeCloneable
public void cloneFields(Cloner cloner, java.lang.Object original)
JmeCloneable
Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.
cloneFields
in interface JmeCloneable
cloner
- The cloner that is performing the cloning operation. The
cloneFields method can call back into the cloner to make
clones of its subordinate fields.original
- The original object from which this object was cloned.
This is provided for the very rare case that this object needs
to refer to its original for some reason. In general, all of
the relevant values should have been transferred during the
shallow clone and this object need merely clone what it wants.public void setNeedSaveReflectionScene(boolean needSaveReflectionScene)
needSaveReflectionScene
- true if need to save reflection scene.public boolean isNeedSaveReflectionScene()