10 #ifndef hifi_shared_shapes
11 #define hifi_shared_shapes
18 #include <glm/glm.hpp>
22 using Index = uint32_t;
23 using Vec = glm::vec3;
24 using VertexVector = std::vector<Vec>;
25 using TexCoordVector = std::vector<glm::vec2>;
26 using IndexVector = std::vector<Index>;
29 using Face = std::array<Index, N>;
32 using FaceVector = std::vector<Face<N>>;
36 VertexVector vertices;
37 TexCoordVector texCoords;
41 std::vector<T> getIndices()
const {
42 size_t count = faces.size() * N;
44 std::vector<T> indices;
45 indices.reserve(count);
46 for (
const auto& face : faces) {
47 for (
const auto& index : face) {
48 indices.push_back((T)index);
54 Solid<N>& fitDimension(
float newMaxDimension) {
55 float maxDimension = 0;
56 for (
const auto& vertex : vertices) {
57 maxDimension = std::max(maxDimension, std::max(std::max(vertex.x, vertex.y), vertex.z));
59 float multiplier = newMaxDimension / maxDimension;
60 for (
auto& vertex : vertices) {
66 Vec getFaceNormal(
size_t faceIndex)
const {
68 const auto& face = faces[faceIndex];
69 for (
size_t i = 0; i < N; ++i) {
70 result += vertices[face[i]];
73 return glm::normalize(result);
78 size_t triangulatedFaceTriangleCount() {
83 size_t triangulatedFaceIndexCount() {
84 return triangulatedFaceTriangleCount<N>() * 3;
87 Solid<3> tesselate(
const Solid<3>& solid,
int count);
88 const Solid<3>& tetrahedron();
89 const Solid<4>& cube();
90 const Solid<3>& octahedron();
91 const Solid<5>& dodecahedron();
92 const Solid<3>& icosahedron();