|
AGX Dynamics 2.42.3.1
|
Abstract interface for requesting height data for a Terrain tile. More...
#include <TerrainDataSource.h>
Inheritance diagram for agxTerrain::TerrainDataSource:Public Types | |
| typedef agx::RealVector | TerrainHeightType |
| Datatype used for returning height values. | |
| typedef std::pair< agxCollide::Geometry *, agxTerrain::TerrainMaterial * > | TerrainMaterialDomain |
| typedef agx::Vector< TerrainMaterialDomain > | TerrainMaterialDomainVector |
Public Member Functions | |
| bool | addTerrainMaterial (agxTerrain::TerrainMaterial *terrainMaterial) |
| Add a TerrainMaterial to the TerrainDataSource, without designating where it is. | |
| bool | addTerrainMaterial (agxTerrain::TerrainMaterial *terrainMaterial, agxCollide::Geometry *geometry) |
| Add a source geometry for the given TerrainMaterial. | |
| AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE (agxTerrain::TerrainDataSource) | |
| bool | exchangeTerrainMaterial (agxTerrain::TerrainMaterial *oldTerrainMaterial, agxTerrain::TerrainMaterial *newTerrainMaterial) |
| Swap out an already added TerrainMaterial for another. | |
| virtual TerrainMaterialDomainVector | fetchTerrainMaterials (const TileSpecification &ts, agxTerrain::TileId id, agx::Real maxHeight) |
| Return assigned terrain material patches in the requested tile. | |
| virtual TerrainHeightType | fetchTerrainTile (const TileSpecification &ts, agxTerrain::TileId id)=0 |
| Return height data for requested tile according to the TileSpecification. | |
| agx::Material * | getAssociatedMaterial (agxTerrain::TerrainMaterial *terrainMaterial) |
| agx::Vector< agx::Material * > | getAssociatedMaterials () |
| const agxCollide::GeometryRefVector & | getSourceGeometries () |
| const agx::HashTable< agxCollide::Geometry *, agxTerrain::TerrainMaterial * > & | getTerrainMaterialLookup () |
| MaterialPairVector | getTerrainMaterialPairs () |
| agx::Vector< agxTerrain::TerrainMaterial * > | getTerrainMaterials () |
| bool | isDirty () const |
| virtual void | onReset () |
| Let the external dataSource know we're doing a reset of the terrain so it can reset as well. | |
| virtual bool | raycast (agx::Vec3 start, agx::Vec3 end, agx::Vec3 &raycastResult) |
| Perform raycasting against the terrain. | |
| bool | removeTerrainMaterial (agxTerrain::TerrainMaterial *terrainMaterial) |
| Remove the specified TerrainMaterial from the TerrainDataSource. | |
| virtual void | restore (agxStream::InputArchive &in) override |
| bool | setAssociatedMaterial (agx::Material *associatedMaterial, agxTerrain::TerrainMaterial *terrainMaterial) |
| Set the associated Material to a given TerrainMaterial. | |
| void | setDefaultTerrainMaterial (agxTerrain::TerrainMaterial *terrainMaterial) |
| Set the default terrain material for the terrain data source. | |
| void | setDirty (bool dirty) |
| virtual void | store (agxStream::OutputArchive &out) const override |
Public Member Functions inherited from agx::Referenced | |
| Referenced () | |
| Default constructor. | |
| Referenced (const Referenced &) | |
| template<typename T > | |
| T * | as () |
| Subclass casting. | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. | |
| template<typename T > | |
| const T * | asSafe () const |
| int | getReferenceCount () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. | |
| Referenced & | operator= (const Referenced &) |
| Assignment operator. Will increment the number of references to the referenced object. | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. | |
Public Member Functions inherited from agxStream::Serializable | |
| virtual | ~Serializable () |
| Destructor for normal C++ use but hidden from SWIG bindings. | |
| virtual const char * | getClassName () const |
| bool | getEnableSerialization () const |
| bool | getEnableUuidGeneration () |
| agx::UInt32 | getIndex () const |
| This index is given at creation of this object. | |
| virtual StorageAgent * | getStorageAgent () const =0 |
| agx::Uuid | getUuid () const |
| bool | isFinished () const |
| void | setEnableSerialization (bool flag) |
| Set to false to disable serialization of this object. | |
| void | setFinished () |
| Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. | |
| void | setUuid (const agx::Uuid &uuid) |
| Explicitly set a Uuid on a serializable object. | |
Protected Attributes | |
| bool | m_dirty = false |
| TerrainMaterialLookup | m_lookupTerrainMaterial |
| agx::ReaderWriterLock | m_rwLock |
| agxCollide::GeometryRefVector | m_terrainMaterialGeometries |
| agxTerrain::MaterialPairVector | m_terrainMaterialsAndAssociatedMaterials |
Protected Attributes inherited from agx::Referenced | |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
Additional Inherited Members | |
Static Public Member Functions inherited from agx::Referenced | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Static Public Member Functions inherited from agxStream::Serializable | |
| static void | setEnableUuidGeneration (bool flag) |
| Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. | |
Protected Member Functions inherited from agx::Referenced | |
| virtual | ~Referenced () |
| Destructor. | |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
Protected Member Functions inherited from agxStream::Serializable | |
| Serializable () | |
| Default constructor. | |
| Serializable (const Serializable &other) | |
| Copy constructor. | |
| void | generateUuid () |
Static Protected Member Functions inherited from agx::Referenced | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. | |
Abstract interface for requesting height data for a Terrain tile.
Definition at line 44 of file TerrainDataSource.h.
Datatype used for returning height values.
Definition at line 52 of file TerrainDataSource.h.
| typedef std::pair<agxCollide::Geometry*, agxTerrain::TerrainMaterial*> agxTerrain::TerrainDataSource::TerrainMaterialDomain |
Definition at line 59 of file TerrainDataSource.h.
| typedef agx::Vector<TerrainMaterialDomain> agxTerrain::TerrainDataSource::TerrainMaterialDomainVector |
Definition at line 65 of file TerrainDataSource.h.
| bool agxTerrain::TerrainDataSource::addTerrainMaterial | ( | agxTerrain::TerrainMaterial * | terrainMaterial | ) |
Add a TerrainMaterial to the TerrainDataSource, without designating where it is.
This is necessary for the TerrainPager to be able to set
| terrainMaterial | - the TerrainMaterial that should be added to the TerrainDataSource. |
| bool agxTerrain::TerrainDataSource::addTerrainMaterial | ( | agxTerrain::TerrainMaterial * | terrainMaterial, |
| agxCollide::Geometry * | geometry | ||
| ) |
Add a source geometry for the given TerrainMaterial.
If the TerrainMaterial isn't in the TerrainDataSource, it will be added (see addTerrainMaterial). New tiles will load the specified terrain material if they overlap with the geometry.
terrainMaterial or geometry were nullptr or if geometry was already used to assign another domain. | agxTerrain::TerrainDataSource::AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE | ( | agxTerrain::TerrainDataSource | ) |
| bool agxTerrain::TerrainDataSource::exchangeTerrainMaterial | ( | agxTerrain::TerrainMaterial * | oldTerrainMaterial, |
| agxTerrain::TerrainMaterial * | newTerrainMaterial | ||
| ) |
Swap out an already added TerrainMaterial for another.
The new terrain material will keep the old terrain materials associated material.
|
virtual |
Return assigned terrain material patches in the requested tile.
The assignment of the TerrainMaterial It is possible to override this method in a custom implementation of a TerrainDataSource, just make sure that any returned TerrainMaterial* in the TerrainMaterialDomain has been added to the TerrainDataSource (via either of the addTerrainMaterial methods) before the fetchTerrainMaterials returns the TerrainMaterialDomainVector.
| ts | - The specification of how new tiles are created by the data source |
| id | - The id or position of the tile relative to other paged terrain tiles |
| maxHeight | - The maximum sampling height of the tile. terrain materials beneath this value will not be added to the simulation. |
|
pure virtual |
Return height data for requested tile according to the TileSpecification.
The returned vector should have ts.getTileResolution squared number of height values. If the TerrainDataSource is not able to provide data, an empty vector can be returned.
Upon no data returned, the TerrainCache will reply to the TerrainPager with the requested TileId id but having no terrain instance signaling that the request was processed but could not be fullfilled. In this scenario, there will be an empty tile where it should have been a terrain instance and the same tile will be requested again on the next stepForward.
| ts | - The specification of how new tiles are created by the data source |
| id | - The id or position of the tile relative to other paged terrain tiles |
Implemented in agxTerrain::TerrainRasterizer, and agxTerrain::ExternalTerrainDataSource.
| agx::Material * agxTerrain::TerrainDataSource::getAssociatedMaterial | ( | agxTerrain::TerrainMaterial * | terrainMaterial | ) |
| agx::Vector< agx::Material * > agxTerrain::TerrainDataSource::getAssociatedMaterials | ( | ) |
| const agxCollide::GeometryRefVector & agxTerrain::TerrainDataSource::getSourceGeometries | ( | ) |
| const agx::HashTable< agxCollide::Geometry *, agxTerrain::TerrainMaterial * > & agxTerrain::TerrainDataSource::getTerrainMaterialLookup | ( | ) |
| MaterialPairVector agxTerrain::TerrainDataSource::getTerrainMaterialPairs | ( | ) |
| agx::Vector< agxTerrain::TerrainMaterial * > agxTerrain::TerrainDataSource::getTerrainMaterials | ( | ) |
| bool agxTerrain::TerrainDataSource::isDirty | ( | ) | const |
|
virtual |
Let the external dataSource know we're doing a reset of the terrain so it can reset as well.
Reimplemented in agxTerrain::ExternalTerrainDataSource.
|
virtual |
Perform raycasting against the terrain.
This can be called by the TerrainPager when TerrainPager::raycast is used and no active tile is hit.
Default implementation returns false. Classes inheriting from TerrainDataSource can overload this method and add support if possible.
| start | - The start position of the raycast |
| end | - The end position of the raycast |
| raycastResult | - A reference to a Vec3 in which to store the point where the raycast hits the data source, |
Reimplemented in agxTerrain::TerrainRasterizer, and agxTerrain::ExternalTerrainDataSource.
| bool agxTerrain::TerrainDataSource::removeTerrainMaterial | ( | agxTerrain::TerrainMaterial * | terrainMaterial | ) |
Remove the specified TerrainMaterial from the TerrainDataSource.
This will also remove the associated material to the terrain material from the TerrainDataSource, and any added geometries that assigned the given terrain material from the TerrainDataSource. WARNING: Doing this during simulation runtime, may result in undefined behavior and possibly, crashes.
| terrainMaterial | - the TerrainMaterial which will be removed from the TerrainDataSource. |
|
overridevirtual |
| bool agxTerrain::TerrainDataSource::setAssociatedMaterial | ( | agx::Material * | associatedMaterial, |
| agxTerrain::TerrainMaterial * | terrainMaterial | ||
| ) |
Set the associated Material to a given TerrainMaterial.
This can replace the current associated material.
| void agxTerrain::TerrainDataSource::setDefaultTerrainMaterial | ( | agxTerrain::TerrainMaterial * | terrainMaterial | ) |
Set the default terrain material for the terrain data source.
The default terrain material is used in all TerrainPager tiles, except where a TerrainMaterial has been added with the addTerrainMaterial method. If not specified on the TerrainDataSource, TerrainPager tiles will use the default terrain material from the given template terrain instead (if not changed, this is the dirt_1 preset).
| terrainMaterial | - the new default TerrainMaterial. |
| void agxTerrain::TerrainDataSource::setDirty | ( | bool | dirty | ) |
|
overridevirtual |
|
protected |
Definition at line 217 of file TerrainDataSource.h.
|
protected |
Definition at line 211 of file TerrainDataSource.h.
|
protected |
Definition at line 216 of file TerrainDataSource.h.
|
protected |
Definition at line 209 of file TerrainDataSource.h.
|
protected |
Definition at line 213 of file TerrainDataSource.h.