AGX Dynamics  2.38.0.2
TrimeshDeformer.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 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/agx.h>
20 #include <agxUtil/agxUtil.h>
21 
22 namespace agxCollide {
23  class Trimesh;
24 }
25 
26 namespace agxUtil {
27 
28  class ParallelTrimeshDeformer;
29 
32 
34  {
35  public:
36  BodyLocalOffset(const agx::RigidBody* relativeBody,
37  const agx::RigidBody* body,
38  agx::Real offsetReach,
39  agx::Real fullOffsetPercent,
40  agx::Vec3* relativePosition);
41  agx::Vec3 getWorldOffsetVector() const;
42  const agx::RigidBody* getBody() const;
43  agx::Real getOffsetReach() const;
44  void setFullOffsetPercent(agx::Real percent);
45  agx::Real getFullOffsetPercent();
46  agx::Real getFullOffsetReach() const;
47  agx::Vec3 calculateRelativeTranslate() const;
48  agx::Vec3 getOriginalRelativeTranslate() const;
49 
51 
52  const IndexVec3HashVector& getAffectedVertices() const;
53  void collectAffectedVertices(const agxData::LocalVector<agx::Vec3>& worldVertices);
54 
56 
57  protected:
59  virtual ~BodyLocalOffset();
65 
67  };
68 
69 
75  {
76  public:
77 
83  agxCollide::Geometry* trimeshGeometry);
84 
108  bool activateDualFrameInterapolation( agx::Frame* interpolationFrame1,
109  agx::Frame* interpolationFrame2,
110  agx::Vec3 localMeshDir);
111 
116  void activateLocalOffsetInterpolation();
117 
128  bool addLocalDeformation(const agx::RigidBody* relativeBody,
129  const agx::RigidBody* body,
130  agx::Real offsetReach,
131  agx::Real fullOffsetPercent,
132  agx::Vec3* relativePosition = nullptr);
133 
137  void update();
138 
139  void last(const agx::TimeStamp&) override;
140 
144  agxCollide::Geometry* getGeometry();
145 
149  agxCollide::Trimesh* getTrimesh();
150 
154  bool isValid() const;
155 
161  void setEnableUpdateCollisionGeometry(bool enable);
162 
168  bool getEnableUpdateCollisionGeometry() const;
169 
171 
172 
173  void updateCollisionGeometry();
174 
175 
176  protected:
177  TrimeshDeformer();
178  virtual ~TrimeshDeformer();
179 
181  void setOwner(ParallelTrimeshDeformer* deformer);
182 
183  void removeNotification() override;
184 
185 
186  void updateDualFrameInterpolation();
187  void updateLocalOffset(const BodyLocalOffsetRef offset);
196 #ifndef SWIG
201 
203 #endif
204 
205  };
206 
207 
208 
214  {
215  public:
216 
218  void add(TrimeshDeformer* deformer);
219  bool remove(TrimeshDeformer* deformer);
220 
221  void setParallel(bool flag);
222  bool getParallel() const;
223 
224  protected:
225 
226  void last(const agx::TimeStamp& time);
227 
228  void addNotification();
229  void removeNotification();
230 
231 
234 
235  virtual ~ParallelTrimeshDeformer();
236 
238  };
239 }
240 
agxUtil::BodyLocalOffset::IndexVec3HashVector
agx::HashVector< size_t, agx::Vec3 > IndexVec3HashVector
Definition: TrimeshDeformer.h:50
agxUtil::TrimeshDeformer
Definition: TrimeshDeformer.h:74
agx::Real
double Real
Definition: Real.h:42
agxUtil::ParallelTrimeshDeformer::m_deformers
TrimeshDeformerSetVector m_deformers
Definition: TrimeshDeformer.h:233
agxSDK::StepEventListener
Derive from this class to implement a listener for simulation step events.
Definition: StepEventListener.h:37
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxUtil::TrimeshDeformer::m_enableUpdate
bool m_enableUpdate
Definition: TrimeshDeformer.h:194
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agxUtil::BodyLocalOffset::m_relativeBody
const agx::RigidBody * m_relativeBody
Definition: TrimeshDeformer.h:60
agx::AffineMatrix4x4T< Real >
agxUtil::TrimeshDeformer::m_localOffsets
BodyLocalOffsetRefVector m_localOffsets
Definition: TrimeshDeformer.h:200
agxUtil::TrimeshDeformer::m_trimeshGeometry
agxCollide::GeometryObserver m_trimeshGeometry
Definition: TrimeshDeformer.h:189
agxUtil::TrimeshDeformer::m_verticesRelative1
agx::Vector< agx::Vec3 > m_verticesRelative1
Definition: TrimeshDeformer.h:198
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agx::observer_ptr< Trimesh >
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxUtil::ParallelTrimeshDeformer::m_parallel
bool m_parallel
Definition: TrimeshDeformer.h:237
agxUtil::BodyLocalOffset::m_relativeRelativeTranslate
agx::Vec3 m_relativeRelativeTranslate
Definition: TrimeshDeformer.h:64
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agxUtil::TrimeshDeformer::m_owner
agx::observer_ptr< ParallelTrimeshDeformer > m_owner
Definition: TrimeshDeformer.h:202
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxUtil::BodyLocalOffset
Definition: TrimeshDeformer.h:33
agx::SetVector< TrimeshDeformerRef >
agxUtil::TrimeshDeformer::m_fullInterpolationLength
agx::Real m_fullInterpolationLength
Definition: TrimeshDeformer.h:192
agxUtil::BodyLocalOffset::m_offsetReach
agx::Real m_offsetReach
Definition: TrimeshDeformer.h:62
agxUtil::BodyLocalOffset::m_affectedVertices
IndexVec3HashVector m_affectedVertices
Definition: TrimeshDeformer.h:66
agxUtil::ParallelTrimeshDeformer
Definition: TrimeshDeformer.h:213
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:91
agx.h
agxUtil::TrimeshDeformer::m_trimesh
agxCollide::TrimeshObserver m_trimesh
Definition: TrimeshDeformer.h:188
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agx::TimeStamp
agx::Real TimeStamp
Definition: TimeStamp.h:26
agxUtil::TrimeshDeformer::m_localMeshNormal
agx::Vec3 m_localMeshNormal
Definition: TrimeshDeformer.h:193
agxUtil::TrimeshDeformer::m_interpolationFrame1
agx::FrameRef m_interpolationFrame1
Definition: TrimeshDeformer.h:190
agx::Vec3T< Real >
agxCollide::Trimesh
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
agxUtil::BodyLocalOffset::m_fullOffsetPercent
agx::Real m_fullOffsetPercent
Definition: TrimeshDeformer.h:63
agxUtil::TrimeshDeformer::m_verticesRelative2
agx::Vector< agx::Vec3 > m_verticesRelative2
Definition: TrimeshDeformer.h:199
agxUtil::ParallelTrimeshDeformer::TrimeshDeformerSetVector
agx::SetVector< TrimeshDeformerRef > TrimeshDeformerSetVector
Definition: TrimeshDeformer.h:232
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
agxUtil::BodyLocalOffset::m_body
const agx::RigidBody * m_body
Definition: TrimeshDeformer.h:61
agxUtil::TrimeshDeformer::m_originalVertices
agx::Vector< agx::Vec3 > m_originalVertices
Definition: TrimeshDeformer.h:197
agxUtil::TrimeshDeformer::m_interpolationFrame2
agx::FrameRef m_interpolationFrame2
Definition: TrimeshDeformer.h:191
agx::HashVector< size_t, agx::Vec3 >
agxUtil
The agxUtil namespace contain classes and methods for utility functionality.
Definition: CylindricalJoint.h:20
agxUtil::TrimeshDeformer::m_localFrame1VertexRotation
agx::AffineMatrix4x4 m_localFrame1VertexRotation
Definition: TrimeshDeformer.h:195
agxData::LocalVector
Local scope vector.
Definition: LocalVector.h:43
agxUtil.h