5 #ifndef MERCATOR_SEGMENT_H 6 #define MERCATOR_SEGMENT_H 8 #include <Mercator/Mercator.h> 9 #include <Mercator/Matrix.h> 10 #include <Mercator/BasePoint.h> 12 #include <wfmath/vector.h> 13 #include <wfmath/axisbox.h> 27 typedef std::set<const TerrainMod *> ModList;
72 explicit Segment(
int x,
int y,
unsigned int resolution);
99 return (m_points != 0);
111 void invalidate(
bool points =
true);
120 m_controlPoints(x, y) = bp;
126 return m_controlPoints;
131 return m_controlPoints;
165 float get(
int x,
int y)
const {
166 return m_points[y * (m_res + 1) + x];
169 void getHeightAndNormal(
float x,
float y,
float &h,
170 WFMath::Vector<3> &normal)
const;
171 bool clipToSegment(
const WFMath::AxisBox<2> &bbox,
int &lx,
int &hx,
int &ly,
int &hy)
const;
175 void populateNormals();
176 void populateSurfaces();
184 WFMath::AxisBox<2> getRect()
const;
187 WFMath::AxisBox<3> getBox()
const;
198 const ModList& getMods()
const 199 {
return m_modList; }
201 int addArea(
const Area* a);
202 int updateArea(
const Area* a);
203 int removeArea(
const Area* a);
205 void checkMaxMin(
float h);
212 float qRMD(WFMath::MTRand& rng,
float nn,
float fn,
float ff,
float nf,
213 float roughness,
float falloff,
float depth)
const;
217 void invalidateSurfaces();
223 #endif // MERCATOR_SEGMENT_H
const int m_yRef
Global y reference of this segment.
Definition: Segment.h:51
float m_max
Maximum height of any point in this segment.
Definition: Segment.h:59
Areastore m_areas
Areas which intersect this segment.
Definition: Segment.h:67
const int getYRef() const
Accessor for Global y reference of this segment.
Definition: Segment.h:91
ModList m_modList
List of TerrainMod objects that are applied to this Segment.
Definition: Segment.h:70
const int m_res
Distance between segments.
Definition: Segment.h:45
std::map< int, Surface * > Surfacestore
STL map of pointers to Surface objects.
Definition: Segment.h:39
Matrix< 2, 2, BasePoint > & getControlPoints()
Accessor for modifying 2D matrix of base points.
Definition: Segment.h:130
void setMinMax(float min, float max)
Set min and max height values for this Segment.
Definition: Segment.h:106
const Surfacestore & getSurfaces() const
Accessor for list of attached Surface objects.
Definition: Segment.h:135
Matrix< 2, 2, BasePoint > m_controlPoints
2x2 matrix of points which control this segment
Definition: Segment.h:53
const int getResolution() const
Accessor for resolution of this segment.
Definition: Segment.h:76
float getMin() const
Accessor for the minimum height value in this Segment.
Definition: Segment.h:181
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
float * m_normals
Pointer to buffer containing normals for height points.
Definition: Segment.h:57
const Areastore & getAreas() const
Accessor for multimap of Area objects.
Definition: Segment.h:195
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
const int getXRef() const
Accessor for Global x reference of this segment.
Definition: Segment.h:86
const int m_xRef
Global x reference of this segment.
Definition: Segment.h:49
const float * getNormals() const
Accessor for buffer containing surface normals.
Definition: Segment.h:155
Surfacestore m_surfaces
Store of surfaces which can be rendered on this terrain.
Definition: Segment.h:64
float getMax() const
Accessor for the maximum height value in this Segment.
Definition: Segment.h:179
float m_min
Minimum height of any point in this segment.
Definition: Segment.h:61
const bool isValid() const
Check whether this Segment contains valid point data.
Definition: Segment.h:98
Point on the fundamental grid that is used as the basis for terrain.
Definition: BasePoint.h:19
float * m_points
Pointer to buffer containing height points.
Definition: Segment.h:55
A fixed sized array of objects.
Definition: Matrix.h:14
const Matrix< 2, 2, BasePoint > & getControlPoints() const
Accessor for 2D matrix of base points.
Definition: Segment.h:125
const int getSize() const
Accessor for array size of this segment.
Definition: Segment.h:81
std::multimap< int, const Area * > Areastore
STL multimap of pointers to Area objects affecting this segment.
Definition: Segment.h:42
float * getNormals()
Accessor for write access to buffer containing surface normals.
Definition: Segment.h:160
const float * getPoints() const
Accessor for buffer containing height points.
Definition: Segment.h:145
float * getPoints()
Accessor for write access to buffer containing height points.
Definition: Segment.h:150
const int m_size
Size of segment, m_res + 1.
Definition: Segment.h:47
Surfacestore & getSurfaces()
Accessor for modifying list of attached Surface objects.
Definition: Segment.h:140
Region of terrain surface which is modified.
Definition: Area.h:28
Base class for modifiers to the procedurally generated terrain.
Definition: TerrainMod.h:20