mercator  0.4.0
A terrain generation library for the Worldforge system.
Mercator::Shader Class Referenceabstract

Base class for Shader objects which create surface data for use when rendering terrain. More...

#include <Shader.h>

Inheritance diagram for Mercator::Shader:

Public Types

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

Public Member Functions

virtual ~Shader ()
 Destructor does nothing interesting. 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...
 
virtual bool checkIntersect (const Segment &) const =0
 Check whether this Shader has any effect on the given Segment. More...
 
virtual void shade (Surface &) const =0
 Populate a Surface with data. More...
 

Protected Member Functions

 Shader (bool color=false, bool alpha=true)
 Protected constructor for classes which inherit from this one. More...
 

Detailed Description

Base class for Shader objects which create surface data for use when rendering terrain.

Shader objects take heightfield data for a terrain Segment, and use it to populate a Surface with data that can then be used to define the appearance of the terrain when rendering. The Shader is used both to create the Surface object of the right type, and to populate the Surface with data once the Segment heightfield has been generated.

Definition at line 25 of file Shader.h.

Member Typedef Documentation

◆ Parameters

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

STL map of parameter values for a shader constructor.

Definition at line 59 of file Shader.h.

Constructor & Destructor Documentation

◆ Shader()

Mercator::Shader::Shader ( bool  color = false,
bool  alpha = true 
)
explicitprotected

Protected constructor for classes which inherit from this one.

Permanently sets the color and alpha flags.

Definition at line 16 of file Shader.cpp.

References ~Shader().

◆ ~Shader()

Mercator::Shader::~Shader ( )
virtualdefault

Destructor does nothing interesting.

Referenced by Shader().

Member Function Documentation

◆ checkIntersect()

virtual bool Mercator::Shader::checkIntersect ( const Segment ) const
pure virtual

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.

Implemented in Mercator::GrassShader, Mercator::BandShader, Mercator::LowShader, Mercator::DepthShader, Mercator::HighShader, Mercator::TileShader, Mercator::AreaShader, and Mercator::FillShader.

Referenced by getAlpha().

◆ getAlpha()

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

Accessor for alpha flag.

Definition at line 42 of file Shader.h.

References checkIntersect(), newSurface(), and shade().

◆ getColor()

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

Accessor for color flag.

Definition at line 37 of file Shader.h.

◆ newSurface()

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

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

◆ shade()

virtual void Mercator::Shader::shade ( Surface ) const
pure virtual

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