#ifndef __GLTF_HPP_ #define __GLTF_HPP_ #include #include #include #include using json = nlohmann::json; #include "material.hpp" #include "vec3.hpp" #include "vk-renderer.hpp" struct mesh_part { std::vector indices; std::vector positions; std::vector normals; std::vector uvs; material mat; }; struct mesh { std::vector parts; }; struct node { std::vector children; std::optional mesh; }; class gltf { public: static node load(std::filesystem::path &path, std::string &filename, vkrenderer &renderer); private: 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, std::vector &materials); static std::vector load_textures(json &gltf_json, std::filesystem::path &path, vkrenderer &renderer); static std::vector load_materials(json &gltf_json, std::vector &textures); static mesh_part load_primitive(json &gltf_json, json &primitive, std::vector> &buffers_content, std::vector &materials); }; #endif