mercator  0.4.0
A terrain generation library for the Worldforge system.
ThresholdShader.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2003 Alistair Riddoch
4 
5 #ifndef MERCATOR_FILL_THRESHOLD_SHADER_H
6 #define MERCATOR_FILL_THRESHOLD_SHADER_H
7 
8 #include "Shader.h"
9 
10 namespace Mercator {
11 
13 class HighShader : public Shader {
14  private:
16  float m_threshold;
17  public:
19  static const std::string key_threshold;
20 
22  static const float default_threshold;
23 
27  explicit HighShader(float threshold = default_threshold);
31  explicit HighShader(const Parameters & params);
32 
33  ~HighShader() override;
34 
36  float threshold() const { return m_threshold; }
37 
38  bool checkIntersect(const Segment &) const override;
39 
40  void shade(Surface &) const override;
41 };
42 
44 class LowShader : public Shader {
45  private:
47  float m_threshold;
48  public:
50  static const std::string key_threshold;
51 
53  static const float default_threshold;
54 
58  explicit LowShader(float threshold = default_threshold);
62  explicit LowShader(const Parameters & params);
63 
64  ~LowShader() override;
65 
67  float threshold() const { return m_threshold; }
68 
69  bool checkIntersect(const Segment &) const override;
70 
71  void shade(Surface &) const override;
72 };
73 
75 class BandShader : public Shader {
76  private:
78  float m_lowThreshold;
80  float m_highThreshold;
81  public:
83  static const std::string key_lowThreshold;
85  static const std::string key_highThreshold;
86 
88  static const float default_lowThreshold;
90  static const float default_highThreshold;
91 
96  explicit BandShader(float low_threshold = default_lowThreshold,
97  float high_threshold = default_highThreshold);
101  explicit BandShader(const Parameters & params);
102 
103  ~BandShader() override;
104 
106  float lowThreshold() const { return m_lowThreshold; }
108  float highThreshold() const { return m_highThreshold; }
109 
110  bool checkIntersect(const Segment &) const override;
111 
112  void shade(Surface &) const override;
113 };
114 
115 } // namespace Mercator
116 
117 #endif // MERCATOR_FILL_THRESHOLD_SHADER_H
Mercator::BandShader::default_lowThreshold
static const float default_lowThreshold
Default level above which the shader renders.
Definition: ThresholdShader.h:88
Mercator::LowShader::shade
void shade(Surface &) const override
Populate a Surface with data.
Definition: ThresholdShader.cpp:94
Mercator::LowShader
Surface shader that defines the surface below a given level.
Definition: ThresholdShader.h:44
Mercator::Segment
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:37
Mercator::Surface
Data store for terrain surface data.
Definition: Surface.h:23
Mercator::BandShader::key_highThreshold
static const std::string key_highThreshold
Key string used when specifying the high threshold parameter.
Definition: ThresholdShader.h:85
Mercator::HighShader::default_threshold
static const float default_threshold
Default level above which the shader renders.
Definition: ThresholdShader.h:22
Mercator::HighShader
Surface shader that defines the surface above a given level.
Definition: ThresholdShader.h:13
Mercator::HighShader::shade
void shade(Surface &) const override
Populate a Surface with data.
Definition: ThresholdShader.cpp:42
Mercator::HighShader::threshold
float threshold() const
Accessor for level above which the shader renders.
Definition: ThresholdShader.h:36
Mercator::LowShader::default_threshold
static const float default_threshold
Default level below which the shader renders.
Definition: ThresholdShader.h:53
Mercator::BandShader::default_highThreshold
static const float default_highThreshold
Default level below which the shader renders.
Definition: ThresholdShader.h:90
Mercator::LowShader::threshold
float threshold() const
Accessor for level below which the shader renders.
Definition: ThresholdShader.h:67
Mercator::HighShader::key_threshold
static const std::string key_threshold
Key string used when specifying the threshold parameter.
Definition: ThresholdShader.h:19
Mercator::BandShader::checkIntersect
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
Definition: ThresholdShader.cpp:145
Mercator::LowShader::LowShader
LowShader(float threshold=default_threshold)
Constructor.
Definition: ThresholdShader.cpp:70
Mercator::BandShader::lowThreshold
float lowThreshold() const
Accessor for the level above which the shader renders.
Definition: ThresholdShader.h:106
Mercator::LowShader::checkIntersect
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
Definition: ThresholdShader.cpp:85
Mercator::BandShader::key_lowThreshold
static const std::string key_lowThreshold
Key string used when specifying the low threshold parameter.
Definition: ThresholdShader.h:83
Mercator::BandShader
Surface shader that defines the surface between two levels.
Definition: ThresholdShader.h:75
Mercator::HighShader::checkIntersect
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
Definition: ThresholdShader.cpp:33
Mercator::HighShader::HighShader
HighShader(float threshold=default_threshold)
Constructor.
Definition: ThresholdShader.cpp:18
Mercator::Shader
Base class for Shader objects which create surface data for use when rendering terrain.
Definition: Shader.h:25
Mercator::BandShader::highThreshold
float highThreshold() const
Accessor for the level below which the shader renders.
Definition: ThresholdShader.h:108
Mercator::BandShader::BandShader
BandShader(float low_threshold=default_lowThreshold, float high_threshold=default_highThreshold)
Constructor.
Definition: ThresholdShader.cpp:124
Mercator::Shader::Parameters
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
Definition: Shader.h:59
Mercator::LowShader::key_threshold
static const std::string key_threshold
Key string used when specifying the threshold parameter.
Definition: ThresholdShader.h:50
Mercator::BandShader::shade
void shade(Surface &) const override
Populate a Surface with data.
Definition: ThresholdShader.cpp:155