AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
TerrainDataSource.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or
9having been advised so by Algoryx Simulation AB for a time limited evaluation,
10or having purchased a valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agx/config/AGX_USE_AGXTERRAIN.h>
20#include <agx/Referenced.h>
23
24#include <agxTerrain/export.h>
26
27#include <agxCollide/Geometry.h>
28#include <agxCollide/Line.h>
29
30
31namespace agxTerrain
32{
33
35
40 {
41 /*
42 The terrain materials are only identified by an Int index, see terrain->getTerrainMaterialIndex.
43 */
45
46 public:
51 /*
52 Datatype used for returning terrain material values
53 */
55
73
83
91
92 /*
93 Add a source geometry for a terrain material index.
94 \note The terrain material is only represented by a terrain material index. See Terrain::getTerrainMaterialIndex(TerrainMaterial*) for the relevant indices.
95 */
97
111 virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& raycastResult );
112
113 // Serialization
115 virtual void store( agxStream::OutputArchive& out ) const override;
116 virtual void restore( agxStream::InputArchive& in ) override;
117
118 private:
119 agxCollide::GeometryRefVector m_terrainMaterialSourceGeometry;
120 TerrainMaterialInGeometry m_terrainMaterial;
121
122 protected:
124 };
125
126
127
152 {
153 public:
154
158 TerrainRasterizer( agx::Real sampleRayLength = 1000.0 );
159
163 agx::Real getRayLength() const;
164
165
169 void setRayLength( agx::Real length );
170
171
183
191
199
208 virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& raycastResult ) override;
209
210
211 // Serialization methods
213
214
215 protected:
217
218 private:
219 agxCollide::GeometryRefVector m_sourceGeometry;
220
221 agxCollide::LineRef m_line;
222 agx::Real m_sampleLength;
223 };
224
237 {
238 public:
243
251
260 virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& raycastResult ) override;
261
262 // Serialization methods
264
265 protected:
267
268 private:
269 // When ExternalTerrainDataSource is loaded from the archive the base class is used by design. This means that
270 // ExternalTerrainDataSource::fetchTerrainTile/raycast will be called. This would normaly result in a warning.
271 // This flag keeps track of if this instance was loaded from an archive and, if so, supresses warnings.
272 bool m_loadedFromArchive;
273 };
274
276 {
277 return m_sampleLength;
278 }
279
281 {
282 m_sampleLength = length;
283 }
284
285}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXTERRAIN_EXPORT
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
Class for reading a binary stream of serialized data.
Class for writing serialized data in binary format to a stream.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
This class provides a concrete, serializable base class which classes written in other languages can ...
virtual bool raycast(agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult) override
Overload of TerrainDataSource::raycast for performing raycast against the data source.
virtual TerrainHeightType fetchTerrainTile(const TileSpecification &ts, agxTerrain::TileId id) override
Overload of TerrainDataSource::fetchTerrainTile for fetching terrain data.
Abstract interface for requesting height data for a Terrain tile.
agx::RealVector TerrainHeightType
Datatype used for returning height values.
virtual TerrainHeightType fetchTerrainTile(const TileSpecification &ts, agxTerrain::TileId id)=0
Return height data for requested tile according to the TileSpecification.
bool removeMaterialSourceGeometry(agxCollide::Geometry *geom)
Removes a geometry from the TerrainRasterizer.
agx::Vector< std::pair< agxCollide::Geometry *, agx::UInt32 > > TerrainMaterialsType
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxTerrain::TerrainDataSource)
virtual void store(agxStream::OutputArchive &out) const override
bool addTerrainMaterialSourceGeometry(agxCollide::Geometry *geom, agx::UInt32 terrainMaterialIndex)
virtual TerrainMaterialsType fetchTerrainMaterials(const TileSpecification &ts, agxTerrain::TileId id, agx::Real maxHeight)
Return assigned terrain material geometries in the requested tile.
virtual bool raycast(agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult)
Perform raycasting against the terrain.
virtual void restore(agxStream::InputArchive &in) override
This class performs raycasting against the source geometry to get height data for tiles.
bool removeSourceGeometry(agxCollide::Geometry *geom)
Removes a geometry from the TerrainRasterizer.
void setRayLength(agx::Real length)
Set the length of the ray.
virtual bool raycast(agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult) override
Overload of TerrainDataSource::raycast for testing against source geometry.
virtual TerrainHeightType fetchTerrainTile(const TileSpecification &ts, agxTerrain::TileId id) override
Return height data for requested tile according to the TileSpecification.
TerrainRasterizer(agx::Real sampleRayLength=1000.0)
Constructor.
bool addSourceGeometry(agxCollide::Geometry *geom)
The rasterizer can have one or more source geometries which are used when creating the terrain tiles.
A TileSpecification determines where in the world a 2D TileId is located and contains utility methods...
Inheritance with partial specialization due to bug with ref_ptr containers.
ReaderWriterLock provides shared access for readers and exclusive access for writers.
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
#define AGX_FORCE_INLINE
Definition macros.h:58
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition Geometry.h:59
uint32_t UInt32
Definition Integer.h:32
double Real
Definition Real.h:42