Loading...
Searching...
No Matches
ImportResult.h
Go to the documentation of this file.
1//
2// Created by denzel on 08/12/2025.
3//
4
5#pragma once
6
7#include "glm/detail/type_vec.hpp"
8#include "glm/detail/type_vec3.hpp"
9#include "hellfire/assets/AssetRegistry.h"
10
11namespace hellfire {
12 /**
13 * @brief Represents a node in the imported model hierarchy
14 */
15 struct ImportedNode {
16 std::string name;
19 glm::vec3 scale{1.0f};
20
21 /// Indices into ImportResult::meshes
23 /// Indices into ImportResult::nodes
25 };
26
27 /**
28 * @brief Represents an imported mesh with its material binding
29 */
30 struct ImportedMesh {
31 AssetID mesh_asset; // Reference to .hfmesh file
32 AssetID material_asset; // Reference to .hfmat file
33 std::string name;
34 };
35
36 /**
37 * @brief Complete result of importing a model file
38 */
39 struct ImportResult {
40 bool success = false;
41 std::string error_message;
42
45 size_t root_node_index = 0;
46
47 // All assets created during import
51 };
52}
std::filesystem::path get_imported_path(const AssetMetadata &meta, const std::string &extension) const
std::filesystem::path get_import_output_dir() const
void import_all_pending()
Import all unprocessed assets in registry.
bool import_model(const AssetMetadata &meta)
bool needs_import(AssetID id) const
AssetImportManager(AssetRegistry &registry, AssetManager &asset_manager, const std::filesystem::path &project_root)
std::filesystem::path project_root_
bool has_imported_mesh(AssetID original_id) const
bool import_model_threaded(const AssetMetadata &meta, std::mutex &registry_mutex)
bool import_texture(const AssetMetadata &meta)
std::filesystem::path import_output_dir_
std::shared_ptr< Mesh > get_mesh(AssetID id)
Registry for storing assets.
std::filesystem::path get_absolute_path(AssetID uuid)
Converts external model formats (FBX, GLTF, OBJ) into internal assets this runs once during asset imp...
unsigned int build_import_flags(const ImportSettings &settings) const
std::filesystem::path output_dir_
std::filesystem::path source_path_
bool is_embedded_texture(const std::string &path) const
static glm::mat4 convert_matrix(const aiMatrix4x4 &m)
std::filesystem::path extract_embedded_texture(size_t index)
static bool is_identity(const aiMatrix4x4 &m)
AssetID process_texture(const std::string &texture_path, TextureType type)
std::optional< std::filesystem::path > resolve_texture_path(const std::string &texture_ref) const
std::string make_unique_name(const std::string &base, const std::string &suffix, size_t index) const
ImportedNode convert_node(const aiNode *node) const
const aiScene * ai_scene_
ModelImporter(AssetRegistry &registry, const std::filesystem::path &output_dir)
std::filesystem::path source_dir_
ImportResult import(const std::filesystem::path &source_path, const ImportSettings &settings={})
AssetID process_mesh(const aiMesh *mesh, size_t mesh_index)
void process_node_hierarchy(const aiNode *node, ImportResult &result, size_t parent_index=SIZE_MAX)
AssetID process_material(const aiMaterial *ai_mat, size_t material_index)
AssetRegistry & registry_
Serializes the ImportResult to a .hfmodel file.
static bool save(const std::filesystem::path &filepath, const ImportResult &result)
static bool save_metadata(const std::filesystem::path &texture_path, const TextureMetadata &meta)
TextureType infer_texture_type(const std::string &name)
TextureType
Definition Texture.h:13
std::filesystem::path filepath
Complete result of importing a model file.
std::vector< AssetID > created_material_assets
std::string error_message
std::vector< AssetID > created_texture_assets
std::vector< ImportedNode > nodes
std::vector< ImportedMesh > meshes
std::vector< AssetID > created_mesh_assets
Represents an imported mesh with its material binding.
Represents a node in the imported model hierarchy.
std::vector< size_t > child_indices
Indices into ImportResult::nodes.
std::vector< size_t > mesh_indices
Indices into ImportResult::meshes.
Metadata for texture assets.