| 90 | } |
| 91 | |
| 92 | glm::vec3 genDimensions(std::vector<glm::vec3> model_vertices) { |
| 93 | glm::vec3 bottom_left = glm::vec3(model_vertices[0].x, model_vertices[0].y, model_vertices[0].z); |
| 94 | glm::vec3 top_right = glm::vec3(model_vertices[0].x, model_vertices[0].y, model_vertices[0].z); |
| 95 | |
| 96 | |
| 97 | for (auto &vertex : model_vertices) { |
| 98 | if (vertex.x < bottom_left.x) { |
| 99 | bottom_left.x = vertex.x; |
| 100 | } |
| 101 | if (vertex.y < bottom_left.y) { |
| 102 | bottom_left.y = vertex.y; |
| 103 | } |
| 104 | if (vertex.z < bottom_left.z) { |
| 105 | bottom_left.z = vertex.z; |
| 106 | } |
| 107 | if (vertex.x > top_right.x) { |
| 108 | top_right.x = vertex.x; |
| 109 | } |
| 110 | if (vertex.y > top_right.y) { |
| 111 | top_right.y = vertex.y; |
| 112 | } |
| 113 | if (vertex.z > top_right.z) { |
| 114 | top_right.z = vertex.z; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return glm::vec3((top_right.x - bottom_left.x) / 2, (top_right.y - bottom_left.y) / 2, |
| 119 | (top_right.z - bottom_left.z) / 2); |
| 120 | } |
| 121 | |
| 122 | unsigned int endian_swap(unsigned int x) { |
| 123 | int swapped; |