5 #ifndef MERCATOR_TERRAIN_H
6 #define MERCATOR_TERRAIN_H
8 #include <Mercator/Mercator.h>
9 #include <Mercator/BasePoint.h>
11 #include <wfmath/axisbox.h>
12 #include <wfmath/point.h>
38 typedef WFMath::AxisBox<2>
Rect;
105 unsigned int resolution = defaultResolution);
108 float get(
float x,
float y)
const;
186 #endif // MERCATOR_TERRAIN_H
Class storing centrally all data about an instance of some terrain.
Definition: Terrain.h:35
const bool isValid() const
Check whether this Segment contains valid point data.
Definition: Segment.h:98
void shadeSurfaces(Segment &)
Populate the Surface objects associated with a Segment.
Definition: Terrain.cpp:154
static const unsigned int DEFAULT
value provided for no flags set.
Definition: Terrain.h:57
void populateSurfaces()
Populate the surfaces associated with this Segment.
Definition: Segment.cpp:291
const Surfacestore & getSurfaces() const
Accessor for list of attached Surface objects.
Definition: Segment.h:135
const Segmentstore & getTerrain() const
Accessor for 2D sparse array of Segment pointers.
Definition: Terrain.h:143
virtual bool checkIntersect(const Segment &) const =0
Check whether this Shader has any effect on the given Segment.
void addSurfaces(Segment &)
Add the required Surface objects to a Segment.
Definition: Terrain.cpp:128
Surface * newSurface(const Segment &) const
Create a new Surface which matches the requirements of this shader.
Definition: Shader.cpp:29
std::map< int, Pointcolumn > Pointstore
STL map to store sparse array of BasePoint columns.
Definition: Terrain.h:46
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
const unsigned int m_options
Bitset of option flags controlling various aspects of terrain.
Definition: Terrain.h:64
std::map< int, Segmentcolumn > Segmentstore
STL map to store sparse array of Segment pointer columns.
Definition: Terrain.h:48
const Pointstore & getPoints() const
Accessor for 2D sparse array of BasePoint objects.
Definition: Terrain.h:148
int getLayer() const
Accessor for the layer number.
Definition: Area.h:52
A fixed sized array of objects.
Definition: Matrix.h:14
bool getBasePoint(int x, int y, BasePoint &z) const
Get the BasePoint at a given base point coordinate.
Definition: Terrain.cpp:223
void setBasePoint(int x, int y, const BasePoint &z)
Set the BasePoint value at a given base point coordinate.
Definition: Terrain.cpp:249
void addArea(const Area *a)
Add an area modifier to the terrain.
Definition: Terrain.cpp:471
void setBasePoint(int x, int y, float z)
Set the height of the basepoint at x,y to z.
Definition: Terrain.h:115
std::map< int, BasePoint > Pointcolumn
STL map to store sparse array of BasePoints.
Definition: Terrain.h:41
bool isShaded() const
Determine whether this terrain object has shading enabled.
Definition: Terrain.h:97
Region of terrain surface which is modified.
Definition: Area.h:28
std::map< int, Surface * > Surfacestore
STL map of pointers to Surface objects.
Definition: Segment.h:39
Segmentstore m_segments
2D spatial container with pointers to all Segments.
Definition: Terrain.h:73
Terrain(unsigned int options=DEFAULT, unsigned int resolution=defaultResolution)
Construct a new Terrain object with optional options and resolution.
Definition: Terrain.cpp:36
void addEffector(const Effector *effector)
Add an effector to the terrain.
Definition: Terrain.cpp:325
float getSpacing() const
Accessor for base point spacing.
Definition: Terrain.h:138
void addMod(const TerrainMod *mod)
Add a modifier to the terrain.
Definition: Terrain.cpp:452
static const float defaultLevel
Height value used when no data is available.
Definition: Terrain.h:102
Point on the fundamental grid that is used as the basis for terrain.
Definition: BasePoint.h:19
Pointstore m_basePoints
2D spatial container with all BasePoints.
Definition: Terrain.h:71
std::map< int, const Shader * > Shaderstore
STL map to store sparse array of Shader pointers.
Definition: Terrain.h:51
std::map< const Effector *, Rect > Effectorstore
STL map to store terrain effectors.
Definition: Terrain.h:54
const Shaderstore & getShaders() const
Accessor for list of Shader pointers.
Definition: Terrain.h:153
void removeArea(const Area *a)
Remove an area modifier from the terrain.
Definition: Terrain.cpp:493
void getHeightAndNormal(float x, float y, float &h, WFMath::Vector< 3 > &normal) const
Get an accurate height and normal vector at a given coordinate relative to this segment.
Definition: Segment.cpp:529
Device which effects a change in the terrain.
Definition: Effector.h:25
void setCornerPoint(unsigned int x, unsigned int y, const BasePoint &bp)
Set the BasePoint data for one of the four that define this Segment.
Definition: Segment.h:119
std::map< int, Segment * > Segmentcolumn
STL map to store sparse array of Segment pointers.
Definition: Terrain.h:43
const int m_res
BasePoint resolution, or distance between adjacent points.
Definition: Terrain.h:66
Rect updateEffector(const Effector *effector)
Updates the terrain affected by an Effector.
Definition: Terrain.cpp:349
bool getHeightAndNormal(float x, float y, float &, WFMath::Vector< 3 > &) const
Get an accurate height and normal vector at a given coordinate x,y.
Definition: Terrain.cpp:199
float get(float x, float y) const
Get the height value at a given coordinate x,y.
Definition: Terrain.cpp:169
Rect updateArea(const Area *a)
Updates the terrain affected by an area.
Definition: Terrain.cpp:484
Base class for Shader objects which create surface data for use when rendering terrain.
Definition: Shader.h:29
void removeEffector(const Effector *effector)
Remove an effector from the terrain.
Definition: Terrain.cpp:424
Effectorstore m_effectors
List of effectors be applied to the terrain.
Definition: Terrain.h:78
void removeShader(const Shader *t, int id)
remove a Shader from the list for this terrain.
Definition: Terrain.cpp:93
const Matrix< 2, 2, BasePoint > & getControlPoints() const
Accessor for 2D matrix of base points.
Definition: Segment.h:125
Rect updateMod(const TerrainMod *mod)
Updates the terrain affected by a mod.
Definition: Terrain.cpp:457
Segment * getSegment(float x, float y) const
Get a pointer to the segment which contains the coord x,y.
Definition: Terrain.h:124
const WFMath::AxisBox< 2 > & bbox() const
Accessor for the bounding box of the geometric shape.
Definition: Effector.h:46
Shaderstore m_shaders
List of shaders to be applied to terrain.
Definition: Terrain.h:75
void setMinMax(float min, float max)
Set min and max height values for this Segment.
Definition: Segment.h:106
float get(int x, int y) const
Get the height at a relative integer position in the Segment.
Definition: Segment.h:165
const float height() const
Accessor for the height at the base point.
Definition: BasePoint.h:47
~Terrain()
Desctruct Terrain object, deleting contained objects.
Definition: Terrain.cpp:47
Base class for modifiers to the procedurally generated terrain.
Definition: TerrainMod.h:20
WFMath::AxisBox< 2 > Rect
Bounding box.
Definition: Terrain.h:38
static const unsigned int SHADED
set if shaders are going to be used on this terrain.
Definition: Terrain.h:59
void addShader(const Shader *t, int id)
Add a new Shader to the list for this terrain.
Definition: Terrain.cpp:65
int getResolution() const
Accessor for base point resolution.
Definition: Terrain.h:133
const float m_spacing
BasePoints spacing, same as m_res in float form for efficiency.
Definition: Terrain.h:68