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;
98 return ((m_options & SHADED) == SHADED);
104 explicit Terrain(
unsigned int options = DEFAULT,
105 unsigned int resolution = defaultResolution);
108 float get(
float x,
float y)
const;
125 int ix = (int)floor(x / m_spacing);
126 int iy = (int)floor(y / m_spacing);
186 #endif // MERCATOR_TERRAIN_H void addSurfaces(Segment &)
Add the required Surface objects to a Segment.
Definition: Terrain.cpp:128
Device which effects a change in the terrain.
Definition: Effector.h:25
void removeShader(const Shader *t, int id)
remove a Shader from the list for this terrain.
Definition: Terrain.cpp:93
std::map< int, Pointcolumn > Pointstore
STL map to store sparse array of BasePoint columns.
Definition: Terrain.h:46
std::map< const Effector *, Rect > Effectorstore
STL map to store terrain effectors.
Definition: Terrain.h:54
Terrain(unsigned int options=DEFAULT, unsigned int resolution=defaultResolution)
Construct a new Terrain object with optional options and resolution.
Definition: Terrain.cpp:36
static const unsigned int DEFAULT
value provided for no flags set.
Definition: Terrain.h:57
const Segmentstore & getTerrain() const
Accessor for 2D sparse array of Segment pointers.
Definition: Terrain.h:143
void shadeSurfaces(Segment &)
Populate the Surface objects associated with a Segment.
Definition: Terrain.cpp:154
void addMod(const TerrainMod *mod)
Add a modifier to the terrain.
Definition: Terrain.cpp:452
Rect updateArea(const Area *a)
Updates the terrain affected by an area.
Definition: Terrain.cpp:484
~Terrain()
Desctruct Terrain object, deleting contained objects.
Definition: Terrain.cpp:47
void setBasePoint(int x, int y, float z)
Set the height of the basepoint at x,y to z.
Definition: Terrain.h:115
Rect updateMod(const TerrainMod *mod)
Updates the terrain affected by a mod.
Definition: Terrain.cpp:457
std::map< int, Segment * > Segmentcolumn
STL map to store sparse array of Segment pointers.
Definition: Terrain.h:43
Segmentstore m_segments
2D spatial container with pointers to all Segments.
Definition: Terrain.h:73
WFMath::AxisBox< 2 > Rect
Bounding box.
Definition: Terrain.h:38
void addEffector(const Effector *effector)
Add an effector to the terrain.
Definition: Terrain.cpp:325
void addArea(const Area *a)
Add an area modifier to the terrain.
Definition: Terrain.cpp:471
void addShader(const Shader *t, int id)
Add a new Shader to the list for this terrain.
Definition: Terrain.cpp:65
const Pointstore & getPoints() const
Accessor for 2D sparse array of BasePoint objects.
Definition: Terrain.h:148
std::map< int, const Shader * > Shaderstore
STL map to store sparse array of Shader pointers.
Definition: Terrain.h:51
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
Rect updateEffector(const Effector *effector)
Updates the terrain affected by an Effector.
Definition: Terrain.cpp:349
const Shaderstore & getShaders() const
Accessor for list of Shader pointers.
Definition: Terrain.h:153
const int m_res
BasePoint resolution, or distance between adjacent points.
Definition: Terrain.h:66
Base class for Shader objects which create surface data for use when rendering terrain.
Definition: Shader.h:29
float getSpacing() const
Accessor for base point spacing.
Definition: Terrain.h:138
void setBasePoint(int x, int y, const BasePoint &z)
Set the BasePoint value at a given base point coordinate.
Definition: Terrain.cpp:249
bool getBasePoint(int x, int y, BasePoint &z) const
Get the BasePoint at a given base point coordinate.
Definition: Terrain.cpp:223
Pointstore m_basePoints
2D spatial container with all BasePoints.
Definition: Terrain.h:71
Point on the fundamental grid that is used as the basis for terrain.
Definition: BasePoint.h:19
Shaderstore m_shaders
List of shaders to be applied to terrain.
Definition: Terrain.h:75
std::map< int, Segmentcolumn > Segmentstore
STL map to store sparse array of Segment pointer columns.
Definition: Terrain.h:48
bool isShaded() const
Determine whether this terrain object has shading enabled.
Definition: Terrain.h:97
Class storing centrally all data about an instance of some terrain.
Definition: Terrain.h:35
std::map< int, BasePoint > Pointcolumn
STL map to store sparse array of BasePoints.
Definition: Terrain.h:41
Segment * getSegment(float x, float y) const
Get a pointer to the segment which contains the coord x,y.
Definition: Terrain.h:124
static const unsigned int SHADED
set if shaders are going to be used on this terrain.
Definition: Terrain.h:59
const unsigned int m_options
Bitset of option flags controlling various aspects of terrain.
Definition: Terrain.h:64
Effectorstore m_effectors
List of effectors be applied to the terrain.
Definition: Terrain.h:78
int getResolution() const
Accessor for base point resolution.
Definition: Terrain.h:133
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
void removeArea(const Area *a)
Remove an area modifier from the terrain.
Definition: Terrain.cpp:493
Region of terrain surface which is modified.
Definition: Area.h:28
const float m_spacing
BasePoints spacing, same as m_res in float form for efficiency.
Definition: Terrain.h:68
static const float defaultLevel
Height value used when no data is available.
Definition: Terrain.h:102
Base class for modifiers to the procedurally generated terrain.
Definition: TerrainMod.h:20
void removeEffector(const Effector *effector)
Remove an effector from the terrain.
Definition: Terrain.cpp:424