12 #ifndef hifi_ShapeInfo_h
13 #define hifi_ShapeInfo_h
18 #include <glm/glm.hpp>
19 #include <glm/gtx/norm.hpp>
21 const float MIN_SHAPE_OFFSET = 0.001f;
25 const int MAX_HULL_POINTS = 42;
28 const int32_t END_OF_MESH_PART = -1;
29 const int32_t END_OF_MESH = -2;
38 SHAPE_TYPE_CYLINDER_X,
39 SHAPE_TYPE_CYLINDER_Y,
40 SHAPE_TYPE_CYLINDER_Z,
44 SHAPE_TYPE_SIMPLE_HULL,
45 SHAPE_TYPE_SIMPLE_COMPOUND,
46 SHAPE_TYPE_STATIC_MESH,
49 SHAPE_TYPE_MULTISPHERE
56 using PointList = QVector<glm::vec3>;
57 using PointCollection = QVector<PointList>;
58 using TriangleIndices = QVector<int32_t>;
59 using SphereData = glm::vec4;
60 using SphereCollection = QVector<SphereData>;
62 static QString getNameForShapeType(ShapeType type);
63 static ShapeType getShapeTypeForName(QString
string);
67 void setParams(ShapeType type,
const glm::vec3& halfExtents, QString url=
"");
68 void setBox(
const glm::vec3& halfExtents);
69 void setSphere(
float radius);
70 void setPointCollection(
const PointCollection& pointCollection);
71 void setCapsuleY(
float radius,
float cylinderHalfHeight);
72 void setMultiSphere(
const std::vector<glm::vec3>& centers,
const std::vector<float>& radiuses);
73 void setOffset(
const glm::vec3& offset);
75 ShapeType getType()
const {
return _type; }
77 const glm::vec3& getHalfExtents()
const {
return _halfExtents; }
78 const glm::vec3& getOffset()
const {
return _offset; }
79 uint32_t getNumSubShapes()
const;
81 PointCollection& getPointCollection() {
return _pointCollection; }
82 const PointCollection& getPointCollection()
const {
return _pointCollection; }
83 const SphereCollection& getSphereCollection()
const {
return _sphereCollection; }
85 TriangleIndices& getTriangleIndices() {
return _triangleIndices; }
86 const TriangleIndices& getTriangleIndices()
const {
return _triangleIndices; }
88 int getLargestSubshapePointCount()
const;
90 float computeVolume()
const;
92 uint64_t getHash()
const;
95 void setHalfExtents(
const glm::vec3& halfExtents);
98 SphereCollection _sphereCollection;
99 PointCollection _pointCollection;
100 TriangleIndices _triangleIndices;
101 glm::vec3 _halfExtents = glm::vec3(0.0f);
102 glm::vec3 _offset = glm::vec3(0.0f);
103 mutable uint64_t _hash64;
104 ShapeType _type = SHAPE_TYPE_NONE;