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
float lowThreshold() const
Accessor for the level above which the shader renders.
HighShader(float threshold=default_threshold)
Constructor.
static const std::string key_lowThreshold
Key string used when specifying the low threshold parameter.
Surface shader that defines the surface between two levels.
float threshold() const
Accessor for level below which the shader renders.
Data store for terrain surface data.
Definition: Surface.h:23
float highThreshold() const
Accessor for the level below which the shader renders.
Surface shader that defines the surface below a given level.
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
Definition: Shader.h:59
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:37
static const float default_lowThreshold
Default level above which the shader renders.
static const float default_threshold
Default level below which the shader renders.
Base class for Shader objects which create surface data for use when rendering terrain.
Definition: Shader.h:25
static const float default_threshold
Default level above which the shader renders.
static const std::string key_highThreshold
Key string used when specifying the high threshold parameter.
Surface shader that defines the surface above a given level.
void shade(Surface &) const override
Populate a Surface with data.
static const float default_highThreshold
Default level below which the shader renders.
float threshold() const
Accessor for level above which the shader renders.
static const std::string key_threshold
Key string used when specifying the threshold parameter.
static const std::string key_threshold
Key string used when specifying the threshold parameter.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.