mercator
0.4.0
A terrain generation library for the Worldforge system.
|
11 #include "DepthShader.h"
30 m_waterLevel(waterLevel), m_murkyDepth(murkyDepth)
35 m_waterLevel(default_waterLevel), m_murkyDepth(default_murkyDepth)
38 auto Iend = params.end();
40 m_waterLevel = I->second;
44 m_murkyDepth = I->second;
48 DepthShader::~DepthShader() =
default;
52 if (s.
getMin() < m_waterLevel) {
63 unsigned int colors = channels - 1;
66 if (height_data == 0) {
67 std::cerr <<
"WARNING: Mercator: Attempting to shade empty segment."
68 << std::endl << std::flush;
73 unsigned int count = size * size;
75 for (
unsigned int i = 0; i < count; ++i) {
76 for (
unsigned int k = 0; k < colors; ++k) {
79 float depth = height_data[i];
80 if (depth > m_waterLevel) {
82 }
else if (depth < m_murkyDepth) {
85 data[++j] = colorMax - I_ROUND(colorMax * ((depth - m_murkyDepth)
86 / (m_waterLevel - m_murkyDepth)));
static const std::string key_murkyDepth
Key string used when specifying the murky depth parameter.
static const float default_waterLevel
Default level of the surface of the water.
float getMin() const
Accessor for the minimum height value in this Segment.
const Segment & getSegment() const
Accessor for the terrain height segment this surface is associated with.
unsigned int getChannels() const
Accessor for the number of data values per height point.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Data store for terrain surface data.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
int getSize() const
Accessor for array size of this segment.
void shade(Surface &) const override
Populate a Surface with data.
DataType * getData()
Accessor for a pointer to buffer containing data values.
static const std::string key_waterLevel
Key string used when specifying the water level parameter.
DepthShader(float waterLevel=default_waterLevel, float murkyDepth=default_murkyDepth)
Constructor.
static const float default_murkyDepth
Default depth at which the bottom becomes completely obscured.
A cache of random values.
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
const float * getPoints() const
Accessor for buffer containing height points.