|
AGXDynamics
2.31.1.0
|
An utility class for handling of pressure rendering and legend. More...
#include <PressureRenderer.h>
Inheritance diagram for agxOSG::PressureRenderer:Classes | |
| struct | MaxAvgData |
| struct | MaxAvgRecording |
Public Member Functions | |
| PressureRenderer (osg::Group *root, agxOSG::SceneDecorator *decorator, agxSDK::Simulation *simulation, osgSim::ColorRange *colorRange=new osgSim::ColorRange(0.0f, 1.0e5f), const agx::Real texelsPerMeter=agx::Real(50), const agx::Real rangeFactor=agx::Real(2.0e-5), agxOSG::PressureFromContacts::ForceType forceType=agxOSG::PressureFromContacts::TOTAL_FORCE) | |
| Constructor using osg color range directly. More... | |
| PressureRenderer (osg::Group *root, agxOSG::SceneDecorator *decorator, agxSDK::Simulation *simulation, const agx::Real minPressure, const agx::Real maxPressure, const agxRender::ColorVector &colors, const agx::Real texelsPerMeter=agx::Real(50), const agx::Real rangeFactor=agx::Real(2.0e-5), agxOSG::PressureFromContacts::ForceType forceType=agxOSG::PressureFromContacts::TOTAL_FORCE) | |
| Constructor using agx data. More... | |
| void | addFilter (agxSDK::ExecuteFilter *filter) |
| Add a contact filter. More... | |
| bool | addGeometry (agxCollide::Geometry *geometry, bool keepGeometryNode=false) |
| Adds all shapes in a geometry to the pressure rendering. More... | |
| bool | addTrimesh (agxCollide::Trimesh *trimesh, bool keepGeometryNode=false) |
| Adds a trimesh to the pressure rendering. More... | |
| template<typename T > | |
| T * | as () |
| Subclass casting. More... | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. More... | |
| template<typename T > | |
| const T * | asSafe () const |
| osgSim::ColorRange * | getColorRange () |
| Gets the color range. More... | |
| agx::Vec2 | getLegendPosition () const |
| Returns the legend center position in relative screen space (0 to 1). More... | |
| size_t | getNumRecordings () |
| agxOSG::PressureAtlasManager * | getPressureAtlasManager () |
| Gets the pressure atlas manager. More... | |
| int | getReferenceCount () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. More... | |
| bool | isRecording () |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| bool | renderAvgPressure (size_t recording) |
| Replace the texture data for measured geometries with a recorded average pressure. More... | |
| bool | renderMaxPressure (size_t recording) |
| Replace the texture data for measured geometries with a recorded maximum pressure. More... | |
| bool | restoreRendering () |
| Disable rendering of recorded maximum or average data. More... | |
| void | setEnableLegend (bool flag) |
| Enables/disables legend in HUD. More... | |
| void | setLegendPosition (const agx::Vec2 &pos) |
| Sets the legend center position in relative screen space (0 to 1). More... | |
| bool | startMaxAvgRecording () |
| Start recording of maximum and average pressure for each pressure atlas currently owned by this PressureRenderer. More... | |
| size_t | stopMaxAvgRecording () |
| Stop the current recording. More... | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
Static Public Member Functions | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Protected Types | |
| typedef agx::Vector< MaxAvgRecording > | MaxAvgRecordingVector |
Protected Member Functions | |
| virtual | ~PressureRenderer () |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
| bool | renderPressure (size_t recording, bool useMax) |
| void | unregisterRecorders () |
| void | updateTextureData () |
Static Protected Member Functions | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More... | |
Protected Attributes | |
| agxOSG::PressureAtlasManagerRef | m_atlasManager |
| osg::ref_ptr< osgSim::ColorRange > | m_colorRange |
| size_t | m_currentRecording |
| osg::observer_ptr< agxOSG::SceneDecorator > | m_decorator |
| agx::Vector< agxSDK::ExecuteFilterRef > | m_filters |
| const agxOSG::PressureFromContacts::ForceType | m_forceType |
| agx::Vec2 | m_legendPosition |
| osg::ref_ptr< agxOSG::Transform > | m_legendTransform |
| agx::Vector< MaxAvgData > | m_maxAvgData |
| agx::Vector< MaxAvgRecordingVector > | m_maxAvgRecordings |
| agx::Vector< agxCollide::TrimeshRef > | m_meshes |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| agx::Real | m_rangeFactor |
| AtomicValue | m_refCount |
| osg::observer_ptr< osg::Group > | m_root |
An utility class for handling of pressure rendering and legend.
Definition at line 50 of file PressureRenderer.h.
|
protected |
Definition at line 281 of file PressureRenderer.h.
| agxOSG::PressureRenderer::PressureRenderer | ( | osg::Group * | root, |
| agxOSG::SceneDecorator * | decorator, | ||
| agxSDK::Simulation * | simulation, | ||
| osgSim::ColorRange * | colorRange = new osgSim::ColorRange(0.0f, 1.0e5f), |
||
| const agx::Real | texelsPerMeter = agx::Real(50), |
||
| const agx::Real | rangeFactor = agx::Real(2.0e-5), |
||
| agxOSG::PressureFromContacts::ForceType | forceType = agxOSG::PressureFromContacts::TOTAL_FORCE |
||
| ) |
Constructor using osg color range directly.
| root | The scene root. |
| decorator | The scene decorator, used here for the hud-legend. |
| simulation | The simulation |
| colorRange | The color range, containing colors, and min and max pressure. |
| texelsPerMeter | The amount of texels per length unit (meter) |
| rangeFactor | Relationship between a contact force and area of the pressure circle. In m/N. |
| forceType | The type of the force to add. Tangential (friction) only, normal only, or both. |
| agxOSG::PressureRenderer::PressureRenderer | ( | osg::Group * | root, |
| agxOSG::SceneDecorator * | decorator, | ||
| agxSDK::Simulation * | simulation, | ||
| const agx::Real | minPressure, | ||
| const agx::Real | maxPressure, | ||
| const agxRender::ColorVector & | colors, | ||
| const agx::Real | texelsPerMeter = agx::Real(50), |
||
| const agx::Real | rangeFactor = agx::Real(2.0e-5), |
||
| agxOSG::PressureFromContacts::ForceType | forceType = agxOSG::PressureFromContacts::TOTAL_FORCE |
||
| ) |
Constructor using agx data.
| root | The scene root. |
| decorator | The scene decorator, used here for the hud-legend. |
| simulation | The simulation |
| minPressure | The min pressure for texturing |
| maxPressure | The max pressure for texturing |
| colors | A vector of colors for coloring. See osgSim::ColorRange for details. |
| texelsPerMeter | The amount of texels per length unit (meter) |
| rangeFactor | Relationship between a contact force and area of the pressure circle. In m/N. |
| forceType | The type of the force to add. Tangential (friction) only, normal only, or both. |
|
protectedvirtual |
| void agxOSG::PressureRenderer::addFilter | ( | agxSDK::ExecuteFilter * | filter | ) |
Add a contact filter.
A contact will only contribute pressure if it is accepted by all filters. Filters will only affect meshes and geometries which have been added after the filter has been added.
| filter |
| bool agxOSG::PressureRenderer::addGeometry | ( | agxCollide::Geometry * | geometry, |
| bool | keepGeometryNode = false |
||
| ) |
Adds all shapes in a geometry to the pressure rendering.
| geometry | The geometry. |
| keepGeometryNode | Should existing geometry nodes be kept? Interesting when blending render states. |
| bool agxOSG::PressureRenderer::addTrimesh | ( | agxCollide::Trimesh * | trimesh, |
| bool | keepGeometryNode = false |
||
| ) |
Adds a trimesh to the pressure rendering.
The trimesh's geometry has to be part of the simulation, and have an osg-node which is in the root's tree.
| trimesh | The trimesh. |
| keepGeometryNode | Should existing geometry nodes be kept? Interesting when blending render states. |
|
protectedinherited |
|
inherited |
Subclass casting.
Template type must match actual type, dynamic_cast assertion will fail otherwise.
Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
|
protectedinherited |
| osgSim::ColorRange* agxOSG::PressureRenderer::getColorRange | ( | ) |
Gets the color range.
|
staticprotectedinherited |
| agx::Vec2 agxOSG::PressureRenderer::getLegendPosition | ( | ) | const |
Returns the legend center position in relative screen space (0 to 1).
| size_t agxOSG::PressureRenderer::getNumRecordings | ( | ) |
| agxOSG::PressureAtlasManager* agxOSG::PressureRenderer::getPressureAtlasManager | ( | ) |
Gets the pressure atlas manager.
|
inherited |
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::EntityStorage::getInstances(), and agx::Object::getResource().
| bool agxOSG::PressureRenderer::isRecording | ( | ) |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
This method should be used with care, always balanced with the same number of calls to unreference.
| bool agxOSG::PressureRenderer::renderAvgPressure | ( | size_t | recording | ) |
Replace the texture data for measured geometries with a recorded average pressure.
Each measured trimesh must be part of a geometry rendered using the OSG mesh created by the owning PressureAtlas, and the geometry must have an associated texture.
Will change the osg::Image object held by the osg::Texture2D object that is part of the OSG render tree.
| recording | The recording ID from which the average pressure should be fetched. |
| bool agxOSG::PressureRenderer::renderMaxPressure | ( | size_t | recording | ) |
Replace the texture data for measured geometries with a recorded maximum pressure.
Each measured trimesh must be part of a geometry rendered using the OSG mesh created by the owning PressureAtlas, and the geometry must have an associated texture.
Will change the osg::Image object held by the osg::Texture2D object that is part of the OSG render tree.
| recording | The recording ID from which the maximum pressure should be fetched. |
|
protected |
| bool agxOSG::PressureRenderer::restoreRendering | ( | ) |
Disable rendering of recorded maximum or average data.
Each texture will be returned the osg::Image object it held when the recording started.
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
| void agxOSG::PressureRenderer::setEnableLegend | ( | bool | flag | ) |
Enables/disables legend in HUD.
Sets the legend center position in relative screen space (0 to 1).
| bool agxOSG::PressureRenderer::startMaxAvgRecording | ( | ) |
Start recording of maximum and average pressure for each pressure atlas currently owned by this PressureRenderer.
Should not be called while a recording is already in progress.
| size_t agxOSG::PressureRenderer::stopMaxAvgRecording | ( | ) |
Stop the current recording.
An ID for the recording is returned. The recorded data can be rendered on the geometries using 'renderMaxPressure(ID)' or 'renderAvgPressure(ID)'.
Should only be called while recording.
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
This method should be used with care, always balanced with the same number of calls to reference.
Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().
|
inherited |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.
|
protected |
|
protected |
|
staticinherited |
|
protected |
Definition at line 235 of file PressureRenderer.h.
|
protected |
Definition at line 236 of file PressureRenderer.h.
|
protected |
Definition at line 287 of file PressureRenderer.h.
|
protected |
Definition at line 234 of file PressureRenderer.h.
|
protected |
Definition at line 240 of file PressureRenderer.h.
|
protected |
Definition at line 290 of file PressureRenderer.h.
|
protected |
Definition at line 238 of file PressureRenderer.h.
|
protected |
Definition at line 237 of file PressureRenderer.h.
|
protected |
Definition at line 261 of file PressureRenderer.h.
|
protected |
Definition at line 284 of file PressureRenderer.h.
|
protected |
Definition at line 232 of file PressureRenderer.h.
|
mutableprotectedinherited |
Definition at line 240 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
protected |
Definition at line 239 of file PressureRenderer.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.
|
protected |
Definition at line 233 of file PressureRenderer.h.