AGXDynamics  2.31.1.0
TerrainDataSource.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 
61  virtual TerrainHeightType fetchTerrainTile( const TileSpecification& ts, agxTerrain::TileId id ) = 0;
62 
72  virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& result );
73 
74  // Serialization
76  virtual void store( agxStream::OutputArchive& out ) const override;
77  virtual void restore( agxStream::InputArchive& in ) override;
78  };
79 
80 
81 
106  {
107  public:
108 
112  TerrainRasterizer( agx::Real sampleRayLength = 1000.0 );
113 
117  agx::Real getRayLength() const;
118 
119 
123  void setRayLength( agx::Real length );
124 
125 
136  bool addSourceGeometry( agxCollide::Geometry* geom );
137 
144  bool removeSourceGeometry( agxCollide::Geometry* geom );
145 
149  virtual TerrainHeightType fetchTerrainTile( const TileSpecification& ts, agxTerrain::TileId id ) override;
150 
154  virtual bool raycast( agx::Vec3 start, agx::Vec3 end, agx::Vec3& result ) override;
155 
156 
157  // Serialization methods
159 
160 
161  protected:
163 
164  private:
165  agxCollide::GeometryRefVector m_sourceGeometry;
166  agxCollide::LineRef m_line;
167  agx::Real m_sampleLength;
168 
169  agx::ReaderWriterLock m_rwLock;
170  };
171 
172 
173 
174 
176  {
177  return m_sampleLength;
178  }
179 
181  {
182  m_sampleLength = length;
183  }
184 
185 }
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
A TileSpecification determines where in the world a 2D TileId is located and contains utility methods...
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...
Copyright 2007 - 2018.
Definition: Geometry.h:56
GLenum GLuint GLenum GLsizei length
Definition: gl.h:5539
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGX_FORCE_INLINE
Definition: Object.h:63
Base class providing referencing counted objects.
Definition: Referenced.h:113
The geometry representation used by the collision detection engine.
Definition: Geometry.h:88
void setRayLength(agx::Real length)
Set the length of the ray.
agx::RealVector TerrainHeightType
Datatype used for returning height values.
#define AGXTERRAIN_EXPORT
This class performs raycasting against the source geometry to get height data for tiles...
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Abstract interface for requesting height data for a Terrain tile.
#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:206
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
#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:220
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
double Real
Definition: Real.h:42
ReaderWriterLock provides shared access for readers and exclusive access for writers.