aboutsummaryrefslogtreecommitdiffstats
path: root/include/gltf.hpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-07-25 11:58:01 +0200
committerladevieq <ladevie.quentin@gmail.com>2021-07-25 11:58:01 +0200
commit3dd870b001bef62aaa501257352d968d1346c7f2 (patch)
treee82abc32ace01af978071b32db40e5c07c991529 /include/gltf.hpp
parent6bdf3ab65a7c1e98595ad167479b94a82184a444 (diff)
Use a different buffer for scene info, geometry, bvh and load gltf
Diffstat (limited to 'include/gltf.hpp')
-rw-r--r--include/gltf.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/gltf.hpp b/include/gltf.hpp
new file mode 100644
index 0000000..80f2749
--- /dev/null
+++ b/include/gltf.hpp
@@ -0,0 +1,34 @@
+#ifndef __GLTF_HPP_
+#define __GLTF_HPP_
+
+#include <filesystem>
+#include <vector>
+
+#include <nlohmann/json.hpp>
+
+using json = nlohmann::json;
+
+#include <vec3.hpp>
+
+struct mesh_part {
+ std::vector<uint16_t> indices;
+ std::vector<vec3> positions;
+ std::vector<vec3> normals;
+};
+
+struct mesh {
+ std::vector<std::vector<mesh_part>> nodes;
+};
+
+class gltf {
+public:
+ static mesh 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_primitive(json &gltf_json, json &primitive, std::vector<std::vector<uint8_t>> &buffers_content, mesh& gltf_mesh);
+};
+
+#endif