7 #ifndef CAFU_TERRAIN_HPP_INCLUDED
8 #define CAFU_TERRAIN_HPP_INCLUDED
10 #include "Templates/Array.hpp"
11 #include "Math3D/BoundingBox.hpp"
12 #include "Math3D/Brush.hpp"
13 #include "Math3D/Plane3.hpp"
59 TerrainT(
const char* FileNameHeightMap,
const Vector3fT& Resolution,
bool FailSafe=
true) ;
77 void UpdateHeights(
const unsigned short* HeightData,
unsigned long PosX,
unsigned long PosY,
unsigned long SizeX,
unsigned long SizeY);
84 unsigned long GetSize()
const {
return Size; }
121 unsigned long Child00Index;
122 unsigned long Child01Index;
123 unsigned long Child10Index;
124 unsigned long Child11Index;
129 unsigned long LowerLeftVertexIndex;
130 unsigned long UpperRightVertexIndex;
136 QuadTreeT(
TerrainT& Terrain,
unsigned long LowerLeftVertIdx,
unsigned long UpperRightVertIdx,
unsigned long Level);
140 friend class QuadTreeT;
146 unsigned long Levels;
155 mutable bool mCVS_LeftOnly;
156 mutable bool mCVS_First;
157 mutable unsigned long mCVS_CurrentLevel;
161 const VertexT& GetVertex(
unsigned long i,
unsigned long j)
const {
return Vertices[i+Size*j]; }
162 VertexT& GetVertex(
unsigned long i,
unsigned long j) {
return Vertices[i+Size*j]; }
163 void ComputeVertexLoD(
unsigned long i,
unsigned long j,
int di,
int dj,
unsigned long n);
164 void Init(
const char* FileNameHeightMap,
const BoundingBox3fT* BB_,
const Vector3fT* Resolution,
bool FailSafe);
168 void CVS_GetVertex(CVS_VertexT& v)
const;
169 bool CVS_Active(CVS_VertexT& v,
float zEdge,
unsigned long& planes)
const;
170 void CVS_Append(
const CVS_VertexT& v)
const;
171 void CVS_TurnCorner()
const;
172 void CVS_RefineTop()
const;
173 void CVS_Refine(
const CVS_VertexT& i,
const CVS_VertexT& j,
float zA,
float zB,
bool in,
bool out,
unsigned long planes)
const;
174 void CVS_RefineL(
const CVS_VertexT& i,
const CVS_VertexT& j,
float zA,
bool in,
unsigned long planes)
const;
175 void CVS_RefineR(CVS_VertexT i, CVS_VertexT j,
float zB,
bool out,
unsigned long planes)
const;
178 void Refine_AppendStripIndex(
unsigned long VertexIndex,
bool Parity)
const;
179 void Refine_SubMesh(
unsigned long l,
unsigned long i,
unsigned long j,
unsigned long k)
const;
180 void Refine_SubMeshVisible(
unsigned long l,
unsigned long i,
unsigned long j,
unsigned long k,
unsigned long m)
const;
183 void Morph_AppendStripVector(
unsigned long VertexIndex,
bool Parity,
float z)
const;
184 void Morph_SubMesh(
unsigned long l,
unsigned long i,
unsigned long j,
unsigned long k,
float za,
float zl,
float zr)
const;
185 void Morph_SubMeshVisible(
unsigned long l,
unsigned long i,
unsigned long j,
unsigned long k,
float za,
float zl,
float zr,
unsigned long m)
const;
float nu_max
Upper morph parameter.
Definition: Terrain.hpp:34
This classes describes the trace (Verfolgungsergebnis) of a vector or a bounding box with regards to ...
Definition: Brush.hpp:18
This class represents terrains, offering methods for LoD rendering and collision detection.
Definition: Terrain.hpp:17
ArrayT< unsigned long > & ComputeIndexStripByRefinement(const ViewInfoT &VI) const
This function computes a triangle strip that approximates the terrain according to the parameters in ...
Definition: Terrain.cpp:1023
const BoundingBox3fT & GetBB() const
Returns the bounding-box (i.e. the lateral dimensions) of the terrain/heightmap.
Definition: Terrain.hpp:87
Vector3fT viewpoint
The viewpoint. Corresponds to Camera::m_position in the original code by Andras Balogh.
Definition: Terrain.hpp:35
bool cull
Perform view culling when set.
Definition: Terrain.hpp:31
An error class that is thrown upon init errors in the constructor.
Definition: Terrain.hpp:40
const VertexT * GetVertices() const
This functions returns a pointer to the vertices of the terrain, intended for use with the ComputeInd...
Definition: Terrain.cpp:125
TerrainT()
Constructor for creating a simple dummy terrain.
Definition: Terrain.cpp:481
void TraceBoundingBox(const BoundingBox3dT &TraceBB, const VectorT &Origin, const VectorT &Dir, VB_Trace3T< double > &Trace) const
Traces the (relative) bounding box TraceBB from the (absolute) Origin along Dir towards the end posit...
Definition: Terrain.cpp:1182
float r
Bounding sphere radius.
Definition: Terrain.hpp:26
ArrayT< Vector3fT > & ComputeVectorStripByMorphing(const ViewInfoT &VI) const
This function computes a triangle strip of vectors that approximates the terrain according to the par...
Definition: Terrain.cpp:1150
float nu
Inverse of error tolerance in radians. Note that this is equivalent to the "magic" number in the orig...
Definition: Terrain.hpp:32
Definition: Terrain.hpp:23
Plane3fT viewplanes[5]
View frustum planes (without the "far" plane). Corresponds to Camera::m_frustum_planes in the origina...
Definition: Terrain.hpp:36
unsigned long GetSize() const
Returns the number of vertices along one side of the terrain/heightmap, e.g. 257, 513...
Definition: Terrain.hpp:84
void UpdateHeights(const unsigned short *HeightData, unsigned long PosX, unsigned long PosY, unsigned long SizeX, unsigned long SizeY)
Updates the vertices in the given rectangle with new heights from the given height field...
Definition: Terrain.cpp:542
float e
Error.
Definition: Terrain.hpp:25
ArrayT< Vector3fT > & ComputeVectorStrip(const TerrainT::ViewInfoT &VI) const
This function computes a triangle strip of vertices that approximates the terrain according to the pa...
Definition: Terrain.cpp:558
Definition: Terrain.hpp:29
float nu_min
Lower morph parameter.
Definition: Terrain.hpp:33
Definition: Renderer.hpp:16