Loading...
Searching...
No Matches
TextureSerializer.h
Go to the documentation of this file.
1//
2// Created by denzel on 08/12/2025.
3//
4
5#pragma once
6#include <filesystem>
7
8#include "hellfire/graphics/texture/Texture.h"
9
10namespace hellfire {
11 /**
12 * @brief Metadata for texture assets
13 *
14 * The actual pixel data is stored in standard formats (PNG, JPG)
15 */
18 bool generate_mipmaps = true;
19 bool srgb = true;
20
21 // Filtering
24
25 // Wrapping
26 enum class WrapMode { REPEAT, CLAMP, MIRROR };
29
30 // Compression (for baked assets)
31 bool compressed = false;
32 std::string compression_format; // "BC1", "BC3", "BC7", etc.
33 };
34
36 public:
37 static bool save_metadata(const std::filesystem::path& texture_path,
38 const TextureMetadata& meta);
39
40 static std::optional<TextureMetadata> load_metadata(
41 const std::filesystem::path& texture_path);
42 };
43} // hellfire
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 std::optional< ImportResult > load_json(const std::filesystem::path &filepath)
static constexpr uint32_t VERSION
static bool save(const std::filesystem::path &filepath, const ImportResult &result)
static constexpr uint32_t MAGIC
static bool save_json(const std::filesystem::path &filepath, const ImportResult &result)
static std::optional< ImportResult > load(const std::filesystem::path &filepath)
static bool save_metadata(const std::filesystem::path &texture_path, const TextureMetadata &meta)
static std::optional< TextureMetadata > load_metadata(const std::filesystem::path &texture_path)
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.