AGX Dynamics  2.37.2.0
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 
66  IndexVec3HashVector m_affectedVertices;
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 
233  TrimeshDeformerSetVector m_deformers;
234 
235  virtual ~ParallelTrimeshDeformer();
236 
238  };
239 }
240 
agx::FrameRef m_interpolationFrame2
Derive from this class to implement a listener for simulation step events.
const agx::RigidBody * m_body
agx::Vector< agx::Vec3 > m_verticesRelative1
This namespace consists of a set of classes for handling geometric intersection tests including boole...
agx::HashVector< size_t, agx::Vec3 > IndexVec3HashVector
agx::SetVector< TrimeshDeformerRef > TrimeshDeformerSetVector
#define AGXPHYSICS_EXPORT
IndexVec3HashVector m_affectedVertices
agx::Real TimeStamp
Definition: TimeStamp.h:26
BodyLocalOffsetRefVector m_localOffsets
agx::Vec3 m_relativeRelativeTranslate
Base class providing referencing counted objects.
Definition: Referenced.h:119
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Templated vector class.
Definition: Vector.h:52
agx::FrameRef m_interpolationFrame1
agxCollide::GeometryObserver m_trimeshGeometry
const agx::RigidBody * m_relativeBody
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
TrimeshDeformerSetVector m_deformers
agxCollide::TrimeshObserver m_trimesh
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agx::observer_ptr< ParallelTrimeshDeformer > m_owner
agx::Vector< agx::Vec3 > m_verticesRelative2
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
#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
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agx::AffineMatrix4x4 m_localFrame1VertexRotation
Local scope vector.
Definition: LocalVector.h:43
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agx::Vector< agx::Vec3 > m_originalVertices
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
The agxUtil namespace contain classes and methods for utility functionality.
AGX_DECLARE_POINTER_TYPES(SpaceListener)