Loading...
Searching...
No Matches
ModelInstantiator.h
Go to the documentation of this file.
1//
2// Created by denzel on 08/12/2025.
3//
4
5#pragma once
6#include "ImportResult.h"
7#include "hellfire/assets/AssetManager.h"
8#include "hellfire/scene/Scene.h"
9
10namespace hellfire {
11 /**
12 * @brief Creates scene entities from an ImportResult
13 */
15 public:
17
18 // Instantiate from AssetID (looks up .hfmodel file)
19 EntityID instantiate(Scene& scene, AssetID model_asset_id, EntityID parent = INVALID_ENTITY);
20
21 // Instantiate from path directly
22 EntityID instantiate(Scene& scene, const std::filesystem::path& hfmodel_path, EntityID parent = INVALID_ENTITY);
23
24 // Instantiate from already-loaded ImportResult
25 EntityID instantiate(Scene& scene, const ImportResult& model, EntityID parent = INVALID_ENTITY);
26
27 private:
30
31 EntityID instantiate_node(Scene& scene,
32 const ImportResult& model,
33 size_t node_index,
34 EntityID parent);
35
36 void attach_mesh_components(Entity *entity, const ImportedMesh &mesh_ref);
37 };
38
39
40}
static constexpr hellfire::EntityID INVALID_ENTITY
Definition Scene.h:10
Registry for storing assets.
std::filesystem::path get_absolute_path(AssetID uuid)
Creates scene entities from an ImportResult.
EntityID instantiate(Scene &scene, const ImportResult &model, EntityID parent=INVALID_ENTITY)
ModelInstantiator(AssetManager &assets, AssetRegistry &registry)
EntityID instantiate(Scene &scene, const std::filesystem::path &hfmodel_path, EntityID parent=INVALID_ENTITY)
EntityID instantiate(Scene &scene, AssetID model_asset_id, EntityID parent=INVALID_ENTITY)
void attach_mesh_components(Entity *entity, const ImportedMesh &mesh_ref)
EntityID instantiate_node(Scene &scene, const ImportResult &model, size_t node_index, EntityID parent)
Serializes the ImportResult to a .hfmodel file.
static std::optional< ImportResult > load(const std::filesystem::path &filepath)
Manages a collection of entities and their hierarchical relationships.
Definition Scene.h:24
void set_parent(EntityID child_id, EntityID parent_id)
Sets the parent of an entity.
Definition Scene.cpp:105
Entity * get_entity(EntityID id)
Retrieves an entity by its ID.
Definition Scene.cpp:81
constexpr AssetID INVALID_ASSET_ID
Complete result of importing a model file.
Represents an imported mesh with its material binding.