AGXDynamics  2.35.0.3
TerrainDataSource.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/config/AGX_USE_AGXTERRAIN.h>
20 #include <agx/Referenced.h>
21 #include <agxStream/Serializable.h>
23 
24 #include <agxTerrain/export.h>
26 
27 #include <agxCollide/Geometry.h>
28 #include <agxCollide/Line.h>
29 
30 
31 namespace agxTerrain
32 {
33 
35 
40  {
41 
42  public:
47 
48 
65  virtual TerrainHeightType fetchTerrainTile( const TileSpecification& ts, agxTerrain::TileId id ) = 0;
66 
80  virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& raycastResult );
81 
82  // Serialization
84  virtual void store( agxStream::OutputArchive& out ) const override;
85  virtual void restore( agxStream::InputArchive& in ) override;
86  };
87 
88 
89 
114  {
115  public:
116 
120  TerrainRasterizer( agx::Real sampleRayLength = 1000.0 );
121 
125  agx::Real getRayLength() const;
126 
127 
131  void setRayLength( agx::Real length );
132 
133 
144  bool addSourceGeometry( agxCollide::Geometry* geom );
145 
152  bool removeSourceGeometry( agxCollide::Geometry* geom );
153 
160  virtual TerrainHeightType fetchTerrainTile( const TileSpecification& ts, agxTerrain::TileId id ) override;
161 
170  virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& raycastResult ) override;
171 
172 
173  // Serialization methods
175 
176 
177  protected:
179 
180  private:
181  agxCollide::GeometryRefVector m_sourceGeometry;
182  agxCollide::LineRef m_line;
183  agx::Real m_sampleLength;
184 
185  agx::ReaderWriterLock m_rwLock;
186  };
187 
200  {
201  public:
206 
213  virtual TerrainHeightType fetchTerrainTile( const TileSpecification& ts, agxTerrain::TileId id ) override;
214 
223  virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& raycastResult ) override;
224 
225  // Serialization methods
227 
228  protected:
230 
231  private:
232  // When ExternalTerrainDataSource is loaded from the archive the base class is used by design. This means that
233  // ExternalTerrainDataSource::fetchTerrainTile/raycast will be called. This would normaly result in a warning.
234  // This flag keeps track of if this instance was loaded from an archive and, if so, supresses warnings.
235  bool m_loadedFromArchive;
236  };
237 
239  {
240  return m_sampleLength;
241  }
242 
244  {
245  m_sampleLength = length;
246  }
247 
248 }
agx::end
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Definition: LinearProbingHashSet.h:612
Referenced.h
agxTerrain::TerrainRasterizer::getRayLength
agx::Real getRayLength() const
Definition: TerrainDataSource.h:238
agx::Real
double Real
Definition: Real.h:42
agx::Vector< agx::ref_ptr< Geometry > >
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition: OutputArchive.h:412
agxTerrain
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
agxTerrain::TileSpecification
A TileSpecification determines where in the world a 2D TileId is located and contains utility methods...
Definition: TileSpecification.h:69
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
TileSpecification.h
agxTerrain::TerrainRasterizer
This class performs raycasting against the source geometry to get height data for tiles.
Definition: TerrainDataSource.h:113
Geometry.h
agx::ReaderWriterLock
ReaderWriterLock provides shared access for readers and exclusive access for writers.
Definition: ThreadSynchronization.h:154
agxTerrain::ExternalTerrainDataSource
This class provides a concrete, serializable base class which classes written in other languages can ...
Definition: TerrainDataSource.h:199
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
AGXSTREAM_DECLARE_SERIALIZABLE
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
agx::VectorPOD< Real >
export.h
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
agxTerrain::TerrainRasterizer::setRayLength
void setRayLength(agx::Real length)
Set the length of the ray.
Definition: TerrainDataSource.h:243
agxTerrain::TerrainDataSource
Abstract interface for requesting height data for a Terrain tile.
Definition: TerrainDataSource.h:39
agx::ref_ptr< Line >
Line.h
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
agx::Vec2T
Definition: Vec2Template.h:30
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Serializable.h
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
AGXTERRAIN_EXPORT
#define AGXTERRAIN_EXPORT
Definition: agxTerrain/export.h:41
ThreadSynchronization.h
agx::Vec3T< Real >
agxTerrain::TerrainDataSource::TerrainHeightType
agx::RealVector TerrainHeightType
Datatype used for returning height values.
Definition: TerrainDataSource.h:46
agxTerrain::ExternalTerrainDataSource::~ExternalTerrainDataSource
~ExternalTerrainDataSource()
Definition: TerrainDataSource.h:229
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58