aboutsummaryrefslogtreecommitdiffstats
path: root/include/gltf.hpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-08-15 23:17:06 +0200
committerladevieq <ladevie.quentin@gmail.com>2021-08-15 23:17:06 +0200
commite1cbdd1d61ffb04ae156fe67923ec5e0871021f1 (patch)
tree438b6aa8bcbd5d2a00a10b2805bf0d45ea82f5c9 /include/gltf.hpp
parent8c1e26e552556e36a5c1fecd9558d9ab9dd3d454 (diff)
Improve gltf loading
Diffstat (limited to 'include/gltf.hpp')
-rw-r--r--include/gltf.hpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/gltf.hpp b/include/gltf.hpp
index 0a34888..7008e8a 100644
--- a/include/gltf.hpp
+++ b/include/gltf.hpp
@@ -3,6 +3,7 @@
#include <filesystem>
#include <vector>
+#include <optional>
#include <nlohmann/json.hpp>
@@ -17,18 +18,25 @@ struct mesh_part {
};
struct mesh {
- std::vector<std::vector<mesh_part>> nodes;
+ std::vector<mesh_part> parts;
+};
+
+struct node {
+ std::vector<node> children;
+ std::optional<mesh> mesh;
};
class gltf {
public:
- static mesh load(std::filesystem::path &path, std::string &filename);
+ static node load(std::filesystem::path &path, std::string &filename);
private:
- static void load_node(json &gltf_json, json &node, std::vector<std::vector<uint8_t>> &buffers_content, mesh& gltf_mesh);
+ static void load_node(json &gltf_json, uint32_t index, node &parent, std::vector<mesh> &meshes);
+
+ static std::vector<mesh> load_meshes(json &gltf_json, std::vector<std::vector<uint8_t>> &buffers_content);
- static void load_primitive(json &gltf_json, json &primitive, std::vector<std::vector<uint8_t>> &buffers_content, mesh& gltf_mesh);
+ static mesh_part load_primitive(json &gltf_json, json &primitive, std::vector<std::vector<uint8_t>> &buffers_content);
};
#endif