AGX Dynamics  2.35.0.1
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 
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 
145 
153 
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 
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 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#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
#define AGXTERRAIN_EXPORT
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
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.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxTerrain::TerrainDataSource)
virtual void store(agxStream::OutputArchive &out) const override
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...
ReaderWriterLock provides shared access for readers and exclusive access for writers.
Base class providing referencing counted objects.
Definition: Referenced.h:114
#define AGX_FORCE_INLINE
Definition: macros.h:58
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
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.
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
double Real
Definition: Real.h:42
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)