8#include "hellfire/graphics/Skybox.h"
15 ambient_light_ = glm::vec3(intensity);
22 skybox_.reset(&skybox);
#define MODEL_LOADER_DEBUG
static constexpr hellfire::EntityID INVALID_ENTITY
static std::shared_ptr< Texture > load_cached_texture(const std::string &path, TextureType type)
static void print_cache_stats()
static void process_mesh_vertices(aiMesh *mesh, std::vector< Vertex > &vertices, std::vector< unsigned int > &indices)
static bool is_identity_transform(const aiMatrix4x4 &matrix)
static std::shared_ptr< Mesh > process_mesh(aiMesh *mesh, const aiScene *scene, const std::string &filepath)
static EntityID process_node(Scene *scene, aiNode *node, const aiScene *ai_scene, const std::string &filepath, EntityID parent_id=0)
static std::string create_material_key(const aiMaterial *ai_material, const std::string &filepath, unsigned int material_index)
static void load_material_textures(const aiMaterial *ai_material, Material &material, const aiScene *scene, const std::string &filepath)
static std::vector< std::string > get_texture_search_paths(const std::string &filepath)
static std::string create_mesh_key(aiMesh *mesh, const std::string &filepath)
static std::unordered_map< std::string, std::shared_ptr< Texture > > texture_cache
static bool try_load_external_texture_unified(const std::string &path_str, const std::string &filepath, TextureType type, Material &material)
static bool try_load_embedded_texture_unified(const std::string &path_str, const aiScene *scene, TextureType type, Material &material)
static bool try_load_embedded_texture(const std::string &path_str, const aiScene *scene, TextureType dcr_type, Material &material, const std::string &property_name)
static std::shared_ptr< Material > create_material(const aiMaterial *ai_material, const aiScene *scene, const std::string &filepath)
static std::unordered_map< std::string, std::shared_ptr< Mesh > > mesh_cache
static void clear_cache()
static std::string capitalize_first(const std::string &str)
static std::unordered_map< std::string, std::shared_ptr< Material > > material_cache
static bool try_load_external_texture(const std::string &path_str, const std::string &filepath, TextureType dcr_type, Material &material, const std::string &property_name)
static void debug_scene_info(const aiScene *scene, const std::string &filepath)
static EntityID load_model(Scene *scene, const std::filesystem::path &filepath, unsigned int import_flags=0)
static void load_essential_material_properties(const aiMaterial *ai_material, Material &material)
static void preprocess_materials(const aiScene *scene, const std::string &filepath)
virtual ~Component()=default
virtual void on_added(Entity *owner)
virtual void on_removed()
Entity & get_owner() const
const std::string & get_name() const
const TransformComponent * transform() const
TransformComponent * transform()
T * add_component(Args &&... args)
const std::vector< ScriptComponent * > & get_script_components() const
void initialize_scripts() const
void cleanup_scripts() const
bool has_component() const
virtual ~Entity()=default
std::vector< ScriptComponent * > script_components_
std::unordered_map< std::type_index, std::unique_ptr< Component > > components_
void send_event_to_script(const std::string &event_name, void *data=nullptr)
void set_name(const std::string &name)
T * get_component() const
Entity(const EntityID id, const std::string &name)
void update_scripts(float delta_time) const
Entity(const std::string &name)
void broadcast_event(const std::string &event_name, void *data=nullptr) const
static void bind_property(const Material::Property &property, uint32_t shader_program, int &texture_unit)
static void bind_property_to_shader(const Material::Property &property, uint32_t shader_program, int &texture_unit)
static void bind_material(const Material &material)
void set_roughness(float roughness)
void set_metallic(float metallic)
void set_opacity(float opacity)
void set_shininess(float shininess)
void set_mesh_asset(AssetID id)
void set_mesh(std::shared_ptr< Mesh > mesh)
AssetID get_mesh_asset() const
MeshComponent(std::shared_ptr< Mesh > mesh)
MeshInternalType internal_type
std::shared_ptr< Mesh > get_mesh() const
MeshSource get_source() const
std::shared_ptr< Mesh > mesh_
void set_source(const MeshSource source, MeshInternalType type=MeshInternalType::NONE)
std::shared_ptr< Material > get_material() const
void set_material_asset(AssetID id)
RenderableComponent()=default
std::shared_ptr< Material > material_
void set_material(const std::shared_ptr< Material > &material)
bool get_cast_shadows() const
bool has_material() const
bool get_receive_shadows() const
AssetID material_asset_id_
void set_cast_shadows(bool cast)
AssetID get_material_asset() const
void set_receive_shadows(bool receive)
std::unique_ptr< Skybox > skybox_
Skybox * get_skybox() const
void set_ambient_light(const float intensity)
void set_skybox(Skybox &skybox)
glm::vec3 get_ambient_light() const
Manages a collection of entities and their hierarchical relationships.
Entity * find_entity_by_name(const std::string &name)
Finds an entity by its name.
Scene(std::string name="Unnamed")
Constructs a new Scene with an optional name.
const Entity * get_entity(EntityID id) const
Retrieves an entity by its ID (const version)
std::vector< EntityID > root_entities_
virtual void initialize()
Initializes the scene Called once when the scene is first loaded or created.
void set_playing(bool active)
size_t get_entity_count() const
void set_as_root(EntityID entity_id)
Makes an entity a root entity (removes parent)
const std::string & get_name() const
bool was_loaded_from_file() const
virtual void update(float delta_time)
Updates all entities in the scene.
EntityID get_parent(EntityID entity_id) const
Gets the parent ID of an entity.
bool has_parent(EntityID entity_id) const
Checks if an entity has a parent.
std::unique_ptr< SceneEnvironment > environment_
EntityID default_camera_entity_id_
std::filesystem::path source_filename_
void set_default_camera(EntityID camera_id)
Sets the default camera for the scene.
std::unordered_map< EntityID, std::unique_ptr< Entity > > & get_all_entities()
std::unordered_map< EntityID, EntityID > parent_map_
CameraComponent * get_default_camera() const
std::unordered_map< EntityID, std::unique_ptr< Entity > > entities_
void set_parent(EntityID child_id, EntityID parent_id)
Sets the parent of an entity.
std::unordered_map< std::string, int > name_counters_
void update_world_matrices()
Updates world transformation matrices for all entities Propagates transformations through the entity ...
void set_source_filename(const std::filesystem::path &filename)
virtual ~Scene()
Destructor.
std::unordered_map< EntityID, std::vector< EntityID > > children_map_
const std::filesystem::path & get_source_filename() const
std::vector< EntityID > find_entities_with_component()
Finds all entities that have a specific component type.
std::string generate_unique_name(const std::string &base_name)
Entity * get_entity(EntityID id)
Retrieves an entity by its ID.
void destroy_entity(EntityID id)
Destroys an entity and removes it from the scene.
EntityID get_default_camera_entity_id() const
const std::vector< EntityID > & get_root_entities() const
Gets all root entities in the scene.
std::vector< EntityID > get_children(EntityID parent_id) const
Gets all children of a parent entity.
std::vector< EntityID > get_camera_entities() const
SceneEnvironment * environment() const
void set_name(const std::string &name)
void find_entities_recursive(EntityID entity_id, const std::function< bool(Entity *)> &predicate, std::vector< EntityID > &results)
bool is_descendant(EntityID potential_descendant, EntityID potential_ancestor)
Checks if one entity is a descendant of another.
void update_world_matrices_recursive(unsigned int entity_id, const glm::mat4 &parent_world)
void update_hierarchy(EntityID entity_id, float delta_time)
EntityID create_entity(const std::string &name="GameObject")
Creates a new entity in the scene.
glm::mat4 aiMatrix4x4ToGlm(const aiMatrix4x4 &from)
constexpr AssetID INVALID_ASSET_ID
static constexpr unsigned int PREVIEW
static constexpr unsigned int OPTIMIZED
static constexpr unsigned int HIGH_QUALITY
static constexpr unsigned int RUNTIME