#pragma once #include #include #include #include "common/common_types.h" #include "common/custom_data/Tfrag3Data.h" #include "common/math/Vector.h" #include "third-party/tiny_gltf/tiny_gltf.h" namespace gltf_util { /*! * Convert a GLTF index buffer to std::vector */ template std::vector index_list_to_u32(const u8* data, u32 num_verts, u32 offset, u32 stride) { std::vector result; result.reserve(num_verts); for (u32 i = 0; i < num_verts; i++) { T val; memcpy(&val, data, sizeof(T)); result.push_back(offset + val); data += stride; } return result; } std::vector extract_vec3f(const u8* data, u32 count, u32 stride); std::vector extract_vec2f(const u8* data, u32 count, u32 stride); std::vector> extract_color_from_vec4_u16(const u8* data, u32 count, u32 stride); std::vector gltf_index_buffer(const tinygltf::Model& model, int indices_idx, u32 index_offset); struct ExtractedVertices { std::vector vtx; std::vector> vtx_colors; std::vector normals; }; ExtractedVertices gltf_vertices(const tinygltf::Model& model, const std::map& attributes, const math::Matrix4f& w_T_local, bool get_colors, bool get_normals, const std::string& debug_name); DrawMode make_default_draw_mode(); struct TexturePool { std::unordered_map textures_by_name; std::vector textures_by_idx; }; int texture_pool_add_texture(TexturePool* pool, const tinygltf::Image& tex); int texture_pool_debug_checker(TexturePool* pool); struct NodeWithTransform { int node_idx; math::Matrix4f w_T_node; }; void dedup_vertices(const std::vector& vertices_in, std::vector& vertices_out, std::vector& old_to_new_out); std::vector flatten_nodes_from_all_scenes(const tinygltf::Model& model); DrawMode draw_mode_from_sampler(const tinygltf::Sampler& sampler); } // namespace gltf_util