Ported the obj parser.

This commit is contained in:
zy4n
2025-04-01 21:51:56 +02:00
parent bc065bc657
commit 27977c1738
34 changed files with 1676 additions and 1554 deletions

View File

@@ -7,31 +7,63 @@
#include "glm/mat4x4.hpp"
#include "util/result.hpp"
#include "util/string_list.hpp"
#include "assets/prefetch_queue.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"
#include "assets/prefetch_lookup.hpp"
namespace assets
{
template<bool Normal, bool Color, bool Reflectance>
struct generic_3dtk_loader
{
[[nodiscard]] static std::error_code prefetch(
const ztu::string_list& filenames,
prefetch_queue& queue
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]] static std::error_code load(
dynamic_point_cloud_buffer& buffer,
const file_dir_list& paths,
dynamic_point_cloud_store& store,
prefetch_lookup& id_lookup,
[[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<texture_id> 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<mesh_vertex_components::position> m_position_buffer{};
std::vector<mesh_vertex_components::normal> m_normal_buffer{};
std::vector<mesh_vertex_components::tex_coord> m_tex_coord_buffer{};
std::unordered_map<component_indices, z3d::vertex_index> m_vertex_comp_indices_to_vertex_index{};
};
[[nodiscard]] static ztu::result<pose_prefetch_lookup::index_type> parse_index(
std::string_view filename
@@ -51,8 +83,13 @@ private:
const std::filesystem::path& filename,
dynamic_point_cloud_buffer& point_cloud
);
private:
std::vector<lookup_type::const_pointer> m_path_buffer;
};
}
#define INCLUDE_GENERIC_3DTK_LOADER_IMPLEMENTATION
#include "../../data_parsers"
#include "assets/file_parsers/generic/generic_3dtk_loader.ipp"
#undef INCLUDE_GENERIC_3DTK_LOADER_IMPLEMENTATION