Files
Z3D/include/assets/data_loaders/mtl_loader.hpp
2024-12-22 16:58:40 +01:00

57 lines
1.4 KiB
C++

#pragma once
#include <filesystem>
#include <system_error>
#include "assets/dynamic_data_store.hpp"
#include "assets/prefetch_lookup.hpp"
#include "assets/prefetch_queue.hpp"
#include "assets/dynamic_read_buffers/dynamic_material_buffer.hpp"
#include "assets/dynamic_data_stores/dynamic_material_library_store.hpp"
#include "assets/dynamic_data_stores/dynamic_material_store.hpp"
#include "util/string_lookup.hpp"
#include "util/result.hpp"
namespace mtl_loader_error {
enum class codes {
ok = 0,
mtl_cannot_open_file,
mtl_cannot_open_texture,
mtl_malformed_ambient_color,
mtl_malformed_diffuse_color,
mtl_malformed_specular_color,
mtl_malformed_specular_exponent,
mtl_malformed_dissolve,
mlt_unknown_line_begin
};
} // namespace mtl_loader_error
class mtl_loader {
public:
static constexpr auto name = std::string_view("mtl");
std::optional<dynamic_material_store::id_type> find_id(std::string_view name);
void clear_name_lookup();
[[nodiscard]] static std::error_code prefetch(
const file_dir_list& paths,
prefetch_queue& queue
);
// THis is not very elegant, but right now I do not see a better solution...
[[nodiscard]] static std::error_code load(
dynamic_material_library_buffer& material_library_buffer,
const file_dir_list& paths,
prefetch_lookup& id_lookup,
dynamic_data_store& store,
bool pedantic = false
);
private:
ztu::string_lookup<dynamic_material_store::id_type> m_id_lookup;
};