AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
PressureAtlas.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXOSG_PRESSURE_ATLAS
18#define AGXOSG_PRESSURE_ATLAS
19
20#include <agx/Referenced.h>
21
22#include <agxCollide/Trimesh.h>
23
24#include <agxOSG/export.h>
27
28#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
29#include <osg/Geometry>
30#include <agx/PopDisableWarnings.h> // End of disabled warnings.
31
32namespace agxOSG
33{
34 class GeometryNode;
36
37
44 {
45 public:
46 PressureAtlas(const agxCollide::Trimesh* mesh, agx::Real texelsPerMeter);
47
49
59
60
77 void addPressure(const agx::Vec3& point, agx::UInt32 triangleIndex, agx::Real magnitude, agx::Real radius);
78
84
85
93 bool isDirty() const;
94
95
102 bool isPressurized() const;
103
104
106
107
118
119
131
132
137
144 osg::Image* getPressureMap();
145
147
152 osg::Geometry* getGraphicsMesh();
153
157 osg::Vec2Array& getTextureCoordinates();
158
159
161
162
164 size_t getNumTriangles() const;
165
170 size_t getNumVertices() const;
171
172 size_t getVertexIndex(size_t triangleIndex, size_t localVertexIndex) const;
173
174 protected:
175 virtual ~PressureAtlas() {}
176
177 private:
178 void createGraphicsMesh();
179 osg::Geometry* createOsgMesh(const agxCollide::Trimesh* mesh);
180 void createAtlas();
181 // Hiding assignment
182 PressureAtlas& operator=(const PressureAtlas&) {return *this;}
183
184
185 agx::UInt32 nextTriangle();
186 void queuePartnersInRange(agxCollide::Mesh::Triangle& triangle, const agx::Vec3& point, agx::Real radiusSquared);
187 bool isInRange(const agx::Vec3& point, const agxCollide::Mesh::Triangle& triangle, agx::Real radiusSquared);
188 bool colorTriangle(const agxCollide::Mesh::Triangle& triangle, const agx::Vec3& point,
189 const agx::Real radius, const agx::Real radiusSquared,
190 const agx::Real centerMagnitude);
191
192
193 private:
194
196 const agxCollide::TrimeshConstRef m_physicsMesh;
197
199 osg::ref_ptr<osg::Geometry> m_graphicsMesh;
200
202 agx::Real m_texelsPerMeter;
203
209 osg::ref_ptr<osg::Image> m_pressureMap;
210
215 PressureGeneratorRefVector m_pressureGenerators;
216
221 PressureToColorConverterRefVector m_colorGenerators;
222
223
225 agx::HashSet<agx::UInt32> m_consideredTriangles;
226
228 agx::Vector<agx::UInt32> m_queuedTriangles;
229
234 bool m_dirty;
235
240 bool m_pressurized;
241 };
242
243}
244
245#endif
246
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXOSG_EXPORT
Class for more intuitive access to the Mesh's mesh data.
Definition Mesh.h:79
Triangle mesh for geometric intersection tests.
Definition Trimesh.h:43
A node that can be associated with a collision geometry so that the transformation of this node is up...
A pressure map for a single trimesh.
bool isDirty() const
Check if the pressure map is dirty.
PressureAtlas(const agxCollide::Trimesh *mesh, agx::Real texelsPerMeter)
const agxCollide::Trimesh * getPhysicsMesh()
void clearPressure()
Fill the pressure map with zeros.
bool registerPressureGenerator(agxOSG::PressureGenerator *generator)
Let this PressureAtlas take over overship of the given pressure generator.
void updateColorImages()
Trigger a color conversion on all converters, if the pressure map is dirty.
osg::Image * getPressureMap()
Returns the pressure map.
bool registerColorConverter(agxOSG::PressureToColorConverter *colorConverter)
Make the given color converter perform color conversion on this atlas' pressure map when PressureAtla...
osg::Geometry * getGraphicsMesh()
Returns an OSG Geometry that can be used to render the collected pressure.
size_t getVertexIndex(size_t triangleIndex, size_t localVertexIndex) const
void addPressure(const agx::Vec3 &point, agx::UInt32 triangleIndex, agx::Real magnitude, agx::Real radius)
Add a pressure sphere centered at 'point', given in the mesh's coordinate system, The given 'magnitud...
agxOSG::GeometryNode * createAtlasRendering()
osg::Vec2Array & getTextureCoordinates()
size_t getNumVertices() const
bool unregisterColorConverter(agxOSG::PressureToColorConverter *colorConverter)
Cause the given color converter to no longer receive update calls from PressureAtlas::updateColorImag...
bool isPressurized() const
Check if the pressure map is pressurized.
size_t getNumTriangles() const
Base class for types that want to supply force updates to a PressureAtlas.
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
uint32_t UInt32
Definition Integer.h:32
double Real
Definition Real.h:42