AGX Dynamics  2.35.0.1
ConvexBuilder.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 #pragma once
17 
18 #include <agx/agxPhysics_export.h>
19 #include <agx/Referenced.h>
20 #include <agx/Vector.h>
21 #include <agxCollide/Convex.h>
22 #include <agxIO/MeshReader.h>
23 #include <agx/agx_vector_types.h>
24 #include <agx/debug.h>
25 
26 namespace agxCollide
27 {
28  namespace deprecated {
29 
31 
32  class ConvexBuilderImplementation;
44  {
45  public:
46 
49 
53  size_t build( const agx::Vec3Vector& vertices, const agx::UInt32Vector& indices, size_t numTriangles );
54 
60  size_t build(agxIO::MeshReader* reader);
61 
63  const ConvexRefVector& getConvexShapes() const { return m_convexShapes; }
64 
67  {
68  agxAssert(i < m_convexShapes.size());
69  if (i >= m_convexShapes.size())
70  return nullptr;
71  return m_convexShapes[i];
72  }
73 
75  size_t getNumShapes() const { return m_convexShapes.size(); }
76 
78  void setMaxVertices(unsigned int n = 32) { m_maxVertices = n; }
79 
81  unsigned int getMaxVertices() const { return m_maxVertices; }
82 
84  void setDepth(unsigned int depth = 5) { m_depth = depth; }
85  unsigned int getDepth() const { return m_depth; }
86 
88  void setConcavityPercent(unsigned int concPercent = 5) { m_concavityPercent = concPercent; }
89  unsigned int getConcavityPercent() const { return m_concavityPercent; }
90 
92  void setVolumePercent(unsigned int volumePercent = 5) { m_volumePercent = volumePercent; }
93  unsigned int getVolumePercent() const { return m_volumePercent; }
94 
96  void setSkinWidth(double swidth = 0.0) { m_skinWidth = swidth; }
97  double getSkinWidth() const { return m_skinWidth; }
98 
99  protected:
100  virtual ~ConvexBuilder();
101 
102  size_t buildConvexShapes(agxCollide::deprecated::ConvexBuilderImplementation* impl);
103 
104  private:
105 
106  agxIO::MeshReaderRef m_reader;
107 
108  double m_skinWidth;
109  unsigned int m_volumePercent;
110  unsigned int m_concavityPercent;
111  unsigned int m_maxVertices;
112  unsigned int m_depth;
113 
114  ConvexRefVector m_convexShapes;
115 
116  ConvexBuilderImplementation* m_impl;
117  };
118  }
119 }
#define AGXPHYSICS_EXPORT
Class for creating convex meshes from a set of vertices and indices.
Definition: ConvexBuilder.h:44
size_t buildConvexShapes(agxCollide::deprecated::ConvexBuilderImplementation *impl)
void setMaxVertices(unsigned int n=32)
Option: Set maximum number of vertices in the output hull. Recommended 32 or less.
Definition: ConvexBuilder.h:78
size_t getNumShapes() const
return num shapes
Definition: ConvexBuilder.h:75
agxCollide::ConvexRef getShape(size_t i)
Definition: ConvexBuilder.h:66
unsigned int getConcavityPercent() const
Definition: ConvexBuilder.h:89
void setDepth(unsigned int depth=5)
Option: Set the depth to split, a maximum of 10, generally not over 7.
Definition: ConvexBuilder.h:84
const ConvexRefVector & getConvexShapes() const
Definition: ConvexBuilder.h:63
void setSkinWidth(double swidth=0.0)
Option: Set the skin width to apply to the output hulls.
Definition: ConvexBuilder.h:96
void setVolumePercent(unsigned int volumePercent=5)
Option: Set the percentage volume conservation threshold to collapse hulls. 0-30 is reasonable.
Definition: ConvexBuilder.h:92
size_t build(agxIO::MeshReader *reader)
Constructs a number of Convex shapes from the triangles read with the MeshReader.
unsigned int getVolumePercent() const
Definition: ConvexBuilder.h:93
size_t build(const agx::Vec3Vector &vertices, const agx::UInt32Vector &indices, size_t numTriangles)
Constructs a number of Convex shapes from a triangle list.
void setConcavityPercent(unsigned int concPercent=5)
Option: Set the concavity threshold percentage. 0=20 is reasonable.
Definition: ConvexBuilder.h:88
Class for reading a mesh object from file and extracting vertices, normals and indices for collision ...
Definition: MeshReader.h:83
Base class providing referencing counted objects.
Definition: Referenced.h:114
#define agxAssert(expr)
Definition: debug.h:143
agx::Vector< agxCollide::ConvexRef > ConvexRefVector
Definition: ConvexBuilder.h:30
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGX_DECLARE_POINTER_TYPES(SpaceListener)