#pragma once #include #include #include #include "glm/mat4x4.hpp" #include "util/result.hpp" #include "util/string_list.hpp" #include "assets/data_stores.hpp" #include "assets/path_id_lookups.hpp" #include "assets/data/point_cloud_data.hpp" #include "assets/data_stores/point_cloud_store.hpp" namespace assets { template struct generic_3dtk_loader { using data_type = point_cloud_data; using store_type = point_cloud_data; using lookup_type = point_cloud_id_lookup; [[nodiscard]] std::error_code prefetch( path_id_lookups& lookups ); [[nodiscard]] std::error_code load( path_id_lookups& lookups, data_stores& stores, bool pedantic = false ); protected: class parser_context { public: parser_context( path_id_lookups& m_id_lookups, data_stores& m_stores ); void operator()(lookup_type::const_pointer entry) noexcept; protected: void reset(); z3d::vertex_index find_or_push_vertex(const component_indices& vertex_comp_indices); [[nodiscard]] std::optional fetch_texture_id( const std::filesystem::path& mtl_dir, std::string_view filename, std::string_view texture_type_name ); private: path_id_lookups* m_id_lookups; data_stores* m_stores; data_type m_mesh{}; std::vector m_position_buffer{}; std::vector m_normal_buffer{}; std::vector m_tex_coord_buffer{}; std::unordered_map m_vertex_comp_indices_to_vertex_index{}; }; [[nodiscard]] static ztu::result parse_index( std::string_view filename ); ztu::result> analyze_component_format( std::string_view line ); void transform_point_cloud( std::span points, const glm::mat4& pose ); private: std::error_code read_point_file( const std::filesystem::path& filename, dynamic_point_cloud_buffer& point_cloud ); private: std::vector m_path_buffer; }; } #define INCLUDE_GENERIC_3DTK_LOADER_IMPLEMENTATION #include "assets/file_parsers/generic/generic_3dtk_loader.ipp" #undef INCLUDE_GENERIC_3DTK_LOADER_IMPLEMENTATION