AGX Dynamics  2.37.2.0
ConvexFactory.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/agxPhysics_export.h>
20 #include <agx/Referenced.h>
21 #include <agx/Vector.h>
22 #include <agxCollide/Convex.h>
23 #include <agxIO/MeshReader.h>
24 #include <agx/agx_vector_types.h>
25 #include <agx/debug.h>
26 
27 namespace agxCollide
28 {
29 
31 
41  {
42  public:
43 
44  struct Parameters : public agx::Referenced
45  {
46  };
49 
50  struct VHACDParameters : public Parameters
51  {
53  uint32_t resolution = 50;
54 
56  double concavity = 0.0025;
57 
59  uint32_t planeDownsampling = 4;
60 
62  uint32_t convexhullDownsampling = 4;
63 
65  double alpha = 0.05;
66 
68  double beta = 0.05;
69 
71  bool pca = false;
72 
74  uint32_t mode = 0; // 0: voxel-based (recommended), 1: tetrahedron-based
75 
76  // Controls the maximum number of triangles per convex - hull. Default 64, range: [0, 1024]
77  uint32_t maxNumVerticesPerConvex = 64;
78 
80  double minVolumePerConvex = 0.0001;
81 
82  bool convexhullApproximation = true;
83 
85  uint32_t maxConvexHulls = 1024;
86  };
89 
90 
92  ConvexFactory( );
93 
97  size_t build( const agx::Vec3Vector& vertices,
98  const agx::UInt32Vector& indices,
99  const Parameters* parameters = nullptr,
100  const agx::Matrix3x3& transformation = agx::Matrix3x3(),
101  const agx::Vec3& translation = agx::Vec3()
102  );
103 
109  size_t build( const agxIO::MeshReader *reader,
110  const Parameters* parameters = nullptr,
111  const agx::Matrix3x3& transformation = agx::Matrix3x3(),
112  const agx::Vec3& translation = agx::Vec3()
113  );
114 
116  const ConvexRefVector& getConvexShapes() const;
117 
119  agxCollide::ConvexRef getShape(size_t i);
120 
122  size_t getNumShapes() const;
123 
124  protected:
125  virtual ~ConvexFactory( );
126 
127  private:
128 
129  size_t buildImplementation(const agx::Vec3Vector& vertices,
130  const agx::UInt32Vector& indices,
131  const VHACDParameters* parameters,
132  const agx::Matrix3x3& transformation = agx::Matrix3x3(),
133  const agx::Vec3& translation = agx::Vec3()
134  );
135 
136  agxIO::MeshReaderRef m_reader;
137 
138  ConvexRefVector m_convexShapes;
139 
140  ParametersConstRef m_parameters;
141  };
142 }
143 
144 
145 
Class for creating convex meshes from a set of vertices and indices.
Definition: ConvexFactory.h:40
agx::ref_ptr< const Parameters > ParametersConstRef
Definition: ConvexFactory.h:48
This namespace consists of a set of classes for handling geometric intersection tests including boole...
#define AGXPHYSICS_EXPORT
Base class providing referencing counted objects.
Definition: Referenced.h:119
agx::ref_ptr< VHACDParameters > VHACDParametersRef
Definition: ConvexFactory.h:87
agx::ref_ptr< Parameters > ParametersRef
Definition: ConvexFactory.h:47
agx::Vector< agxCollide::ConvexRef > ConvexRefVector
Definition: ConvexFactory.h:30
Class for reading a mesh object from file and extracting vertices, normals and indices for collision ...
Definition: MeshReader.h:82
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::ref_ptr< const VHACDParameters > VHACDParametersConstRef
Definition: ConvexFactory.h:88
AGX_DECLARE_POINTER_TYPES(SpaceListener)