Unravel Engine C++ Reference
Loading...
Searching...
No Matches
defaults.h
Go to the documentation of this file.
1#pragma once
2#include <engine/engine_export.h>
3
6#include <base/basetypes.hpp>
7#include <context/context.hpp>
8#include <engine/ecs/ecs.h>
14
15namespace unravel
16{
17
23{
29 static auto init(rtti::context& ctx) -> bool;
30
36 static auto deinit(rtti::context& ctx) -> bool;
37
43 static auto init_assets(rtti::context& ctx) -> bool;
44
52 static auto create_embedded_mesh_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
53
63 static auto create_prefab_at(rtti::context& ctx,
64 scene& scn,
65 const std::string& key,
66 const camera& cam,
67 math::vec2 pos) -> entt::handle;
68
77 static auto create_prefab_at(rtti::context& ctx,
78 scene& scn,
79 const std::string& key,
80 math::vec3 pos) -> entt::handle;
81
89 static auto create_prefab_at(rtti::context& ctx,
90 scene& scn,
91 const std::string& key) -> entt::handle;
101 static auto create_mesh_entity_at(rtti::context& ctx,
102 scene& scn,
103 const std::string& key,
104 const camera& cam,
105 math::vec2 pos) -> entt::handle;
106
115 static auto create_mesh_entity_at(rtti::context& ctx,
116 scene& scn,
117 const std::string& key,
118 math::vec3 pos = {0.0f, 0.0f, 0.0f}) -> entt::handle;
119
128 static auto create_light_entity(rtti::context& ctx, scene& scn, light_type type, const std::string& name)
129 -> entt::handle;
130
139 static auto create_reflection_probe_entity(rtti::context& ctx, scene& scn, probe_type type, const std::string& name)
140 -> entt::handle;
141
149 static auto create_camera_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
150
158 static auto create_ui_document_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
159
167 static auto create_text_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
168
176 static auto create_particle_emitter_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
177
185 static auto create_audio_source_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
186
192 static void create_default_3d_scene(rtti::context& ctx, scene& scn);
193
199 static void focus_camera_on_entities(entt::handle camera, hpp::span<const entt::handle> entities);
200
207 static void focus_camera_on_entities(entt::handle camera,
208 hpp::span<const entt::handle> entities,
209 float duration);
210
218 static void focus_camera_on_bounds(entt::handle camera,
219 const math::bsphere& bounds,
220 float duration);
221
229 static void focus_camera_on_bounds(entt::handle camera,
230 const math::bbox& bounds,
231 float duration);
232
243 {
244 entt::handle object;
245 entt::handle camera;
246 };
247 template<typename T>
249 scene& scn,
250 const asset_handle<T>& asset,
251 const usize32_t& size, bool focus_camera = true) -> asset_preview_result;
252
259
265 static auto calc_bounds_global(entt::handle entity, int depth = -1) -> math::bbox;
266
272 static auto calc_bounds_sphere_global(entt::handle entity, bool use_bbox_diagonal = true) -> math::bsphere;
273
274private:
282 static auto create_default_3d_scene_for_preview(rtti::context& ctx, scene& scn, const usize32_t& size)
283 -> entt::handle;
284
285 // Internal helper for timed focus transitions (shared between bbox and bsphere variants)
286 static void run_camera_focus_transition(entt::handle camera,
287 const math::vec3& target_center,
288 float radius,
289 bool keep_rotation,
290 float duration);
291};
292
293} // namespace unravel
manifold_type type
Provides storage for common representation of spherical bounding volume, and wraps up common function...
Definition bsphere.h:18
Class representing a camera. Contains functionality for manipulating and updating a camera....
Definition camera.h:35
std::string name
Definition hub.cpp:27
probe_type
Enum class representing the type of reflection probe.
light_type
Enum representing the type of light.
Definition light.h:14
entt::entity entity
Represents a handle to an asset, providing access and management functions.
Storage for box vector values and wraps up common functionality.
Definition bbox.h:21
Creates a default 3D scene for asset preview.
Definition defaults.h:243
Provides default initialization and creation functions for various entities and assets.
Definition defaults.h:23
static auto create_reflection_probe_entity(rtti::context &ctx, scene &scn, probe_type type, const std::string &name) -> entt::handle
Creates a reflection probe entity.
Definition defaults.cpp:570
static void focus_camera_on_bounds(entt::handle camera, const math::bsphere &bounds, float duration)
Focuses a camera on bounds with a timed transition.
static auto init_assets(rtti::context &ctx) -> bool
Initializes default assets.
Definition defaults.cpp:301
static auto init(rtti::context &ctx) -> bool
Initializes default settings and assets.
Definition defaults.cpp:265
static auto create_ui_document_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a UI document entity.
Definition defaults.cpp:608
static auto create_text_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a text entity.
Definition defaults.cpp:615
static auto create_audio_source_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a audio source entity.
Definition defaults.cpp:632
static auto create_embedded_mesh_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates an embedded mesh entity.
Definition defaults.cpp:433
static auto calc_bounds_sphere_global(entt::handle entity, bool use_bbox_diagonal=true) -> math::bsphere
Calculates the bounding sphere of an entity.
Definition defaults.cpp:893
static void focus_camera_on_entities(entt::handle camera, hpp::span< const entt::handle > entities)
Focuses a camera on a specified entity.
Definition defaults.cpp:822
static auto create_particle_emitter_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a particle emitter entity.
Definition defaults.cpp:625
static auto create_default_3d_scene_for_asset_preview(rtti::context &ctx, scene &scn, const asset_handle< T > &asset, const usize32_t &size, bool focus_camera=true) -> asset_preview_result
static auto calc_bounds_global(entt::handle entity, int depth=-1) -> math::bbox
Calculates the bounding box of an entity.
Definition defaults.cpp:876
static auto create_light_entity(rtti::context &ctx, scene &scn, light_type type, const std::string &name) -> entt::handle
Creates a light entity.
Definition defaults.cpp:538
static auto create_prefab_at(rtti::context &ctx, scene &scn, const std::string &key, const camera &cam, math::vec2 pos) -> entt::handle
Creates a prefab entity at a specified position.
Definition defaults.cpp:479
static void focus_camera_on_bounds(entt::handle camera, const math::bbox &bounds, float duration)
Focuses a camera on bounds with a timed transition.
static void create_default_3d_scene_for_editing(rtti::context &ctx, scene &scn)
Creates a default 3D scene for editing.
Definition defaults.cpp:659
static auto create_camera_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a camera entity.
Definition defaults.cpp:592
static auto create_mesh_entity_at(rtti::context &ctx, scene &scn, const std::string &key, const camera &cam, math::vec2 pos) -> entt::handle
Creates a mesh entity at a specified position.
Definition defaults.cpp:523
static void create_default_3d_scene(rtti::context &ctx, scene &scn)
Creates a default 3D scene.
Definition defaults.cpp:639
static auto deinit(rtti::context &ctx) -> bool
Deinitializes default settings and assets.
Definition defaults.cpp:272
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:21