mercator  0.4.0
A terrain generation library for the Worldforge system.
Mercator::DepthShader Class Reference

Shader to give the appearance of deep murky water. More...

#include <DepthShader.h>

Inheritance diagram for Mercator::DepthShader:
Collaboration diagram for Mercator::DepthShader:

Public Types

typedef std::map< std::string, float > Parameters
 STL map of parameter values for a shader constructor. More...
 

Public Member Functions

 DepthShader (float waterLevel=default_waterLevel, float murkyDepth=default_murkyDepth)
 Constructor. More...
 
 DepthShader (const Parameters &params)
 Constructor. More...
 
float waterLevel () const
 Accessor for the level of the surface of the water. More...
 
float murkyDepth () const
 Accessor for the depth at which the bottom becomes completely obscured. More...
 
bool checkIntersect (const Segment &) const override
 Check whether this Shader has any effect on the given Segment. More...
 
void shade (Surface &) const override
 Populate a Surface with data. More...
 
bool getColor () const
 Accessor for color flag. More...
 
bool getAlpha () const
 Accessor for alpha flag. More...
 
std::unique_ptr< SurfacenewSurface (const Segment &) const
 Create a new Surface which matches the requirements of this shader. More...
 

Static Public Attributes

static const std::string key_waterLevel
 Key string used when specifying the water level parameter. More...
 
static const std::string key_murkyDepth
 Key string used when specifying the murky depth parameter. More...
 
static const float default_waterLevel = 0.f
 Default level of the surface of the water. More...
 
static const float default_murkyDepth = -64.f
 Default depth at which the bottom becomes completely obscured. More...
 

Detailed Description

Shader to give the appearance of deep murky water.

Areas of terrain covered by water should be darker as less distinct as they get deeper. This shader adds a uniform alpha blended surface below water level which becomes more opaque as it gets deeper concealing the underlying appearance of the terrain from a viewer at the surface.

Definition at line 19 of file DepthShader.h.

Member Typedef Documentation

typedef std::map<std::string, float> Mercator::Shader::Parameters
inherited

STL map of parameter values for a shader constructor.

Definition at line 59 of file Shader.h.

Constructor & Destructor Documentation

Mercator::DepthShader::DepthShader ( float  waterLevel = default_waterLevel,
float  murkyDepth = default_murkyDepth 
)
explicit

Constructor.

Parameters
waterLevellevel of the surface of the water.
murkyDepthdepth at which the bottom becomes completely obscured.

Definition at line 29 of file DepthShader.cpp.

Mercator::DepthShader::DepthShader ( const Parameters params)
explicit

Constructor.

Parameters
paramsa map of parameters for the shader.

Definition at line 34 of file DepthShader.cpp.

References key_murkyDepth, and key_waterLevel.

Member Function Documentation

bool Mercator::DepthShader::checkIntersect ( const Segment ) const
overridevirtual

Check whether this Shader has any effect on the given Segment.

Returns
true if the given Segment height range is within the range that this Shader uses. e.g. A high altitude snow shader will have no effect on low level terrain.

Implements Mercator::Shader.

Definition at line 50 of file DepthShader.cpp.

References Mercator::Segment::getMin().

Referenced by murkyDepth().

bool Mercator::Shader::getAlpha ( ) const
inlineinherited

Accessor for alpha flag.

Definition at line 42 of file Shader.h.

References Mercator::Shader::checkIntersect(), Mercator::Shader::newSurface(), and Mercator::Shader::shade().

bool Mercator::Shader::getColor ( ) const
inlineinherited

Accessor for color flag.

Definition at line 37 of file Shader.h.

float Mercator::DepthShader::murkyDepth ( ) const
inline

Accessor for the depth at which the bottom becomes completely obscured.

Definition at line 51 of file DepthShader.h.

References checkIntersect(), and shade().

std::unique_ptr< Surface > Mercator::Shader::newSurface ( const Segment segment) const
inherited

Create a new Surface which matches the requirements of this shader.

Called by terrain when creating a new Segment to add the necessary Surface objects to that Segment.

Definition at line 27 of file Shader.cpp.

Referenced by Mercator::Terrain::addShader(), Mercator::Segment::clearMods(), and Mercator::Shader::getAlpha().

void Mercator::DepthShader::shade ( Surface ) const
overridevirtual
float Mercator::DepthShader::waterLevel ( ) const
inline

Accessor for the level of the surface of the water.

Definition at line 49 of file DepthShader.h.

Member Data Documentation

const float Mercator::DepthShader::default_murkyDepth = -64.f
static

Default depth at which the bottom becomes completely obscured.

Definition at line 34 of file DepthShader.h.

const float Mercator::DepthShader::default_waterLevel = 0.f
static

Default level of the surface of the water.

Definition at line 32 of file DepthShader.h.

const std::string Mercator::DepthShader::key_murkyDepth
static

Key string used when specifying the murky depth parameter.

Definition at line 29 of file DepthShader.h.

Referenced by DepthShader().

const std::string Mercator::DepthShader::key_waterLevel
static

Key string used when specifying the water level parameter.

Definition at line 27 of file DepthShader.h.

Referenced by DepthShader().


The documentation for this class was generated from the following files: