From e1cbdd1d61ffb04ae156fe67923ec5e0871021f1 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sun, 15 Aug 2021 23:17:06 +0200 Subject: Improve gltf loading --- include/gltf.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include/gltf.hpp') 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 #include +#include #include @@ -17,18 +18,25 @@ struct mesh_part { }; struct mesh { - std::vector> nodes; + std::vector parts; +}; + +struct node { + std::vector children; + std::optional 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> &buffers_content, mesh& gltf_mesh); + static void load_node(json &gltf_json, uint32_t index, node &parent, std::vector &meshes); + + static std::vector load_meshes(json &gltf_json, std::vector> &buffers_content); - static void load_primitive(json &gltf_json, json &primitive, std::vector> &buffers_content, mesh& gltf_mesh); + static mesh_part load_primitive(json &gltf_json, json &primitive, std::vector> &buffers_content); }; #endif -- cgit v1.3