Unravel Engine C++ Reference
Loading...
Searching...
No Matches
asset_reader.h
Go to the documentation of this file.
1#pragma once
2#include "asset_extensions.h"
4#include "../asset_handle.h"
5#include <graphics/shader.h>
6
7namespace gfx
8{
9struct texture;
10struct shader;
11} // namespace gfx
12
13namespace unravel
14{
15class mesh;
16class material;
17struct prefab;
18struct scene_prefab;
19struct animation_clip;
20struct physics_material;
21struct audio_clip;
22struct script;
23struct font;
24struct ui_tree;
25struct style_sheet;
26} // namespace unravel
27
29{
30
31auto resolve_compiled_key(const std::string& key) -> std::string;
32auto resolve_compiled_path(const std::string& key) -> fs::path;
33
34template<typename T>
35auto load_from_file(tpp::thread_pool& pool, asset_handle<T>& output, const std::string& key) -> bool;
36
37#define DECLARE_LOADER_SPEC(T)\
38template<>\
39auto load_from_file<T>(tpp::thread_pool& pool, asset_handle<T>& output, const std::string& key) -> bool
40
54
55template<typename T>
56inline auto get_job_name() -> std::string
57{
58 return fmt::format("Loading {}", ex::get_type<T>());
59}
60
61template<typename T>
62inline auto load_from_instance(tpp::thread_pool& pool, asset_handle<T>& output, std::shared_ptr<T> instance) -> bool
63{
64 auto job = pool.schedule(get_job_name<T>(),
65 [](std::shared_ptr<T> instance)
66 {
67 return instance;
68 },
69 instance)
70 .share();
71
72 output.set_internal_job(job);
73
74 return true;
75}
76} // namespace unravel::asset_reader
#define DECLARE_LOADER_SPEC(T)
Base class for materials used in rendering.
Definition material.h:32
Main class representing a 3D mesh with support for different LODs, submeshes, and skinning.
Definition mesh.h:310
ImGui::Font::Enum font
Definition hub.cpp:24
auto get_type() -> const std::string &
auto load_from_file(tpp::thread_pool &pool, asset_handle< T > &output, const std::string &key) -> bool
auto resolve_compiled_path(const std::string &key) -> fs::path
auto resolve_compiled_key(const std::string &key) -> std::string
auto load_from_instance(tpp::thread_pool &pool, asset_handle< T > &output, std::shared_ptr< T > instance) -> bool
auto get_job_name() -> std::string
Represents a handle to an asset, providing access and management functions.
Struct representing an animation.
Definition animation.h:99
Struct representing an audio clip.
Definition audio_clip.h:16
Represents the physical properties of a material.
Represents a generic prefab with a buffer for serialized data.
Definition prefab.h:18
Represents a scene-specific prefab. Inherits from the generic prefab structure.
Definition prefab.h:31
Represents a UI style sheet asset (CSS/RCSS document).
Definition style_sheet.h:26
Represents a UI visual tree asset (HTML/RML document).
Definition ui_tree.h:25