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
7#include <base/basetypes.hpp>
8#include <context/context.hpp>
9#include <engine/ecs/ecs.h>
15
16#include <hpp/string_view.hpp>
17
18namespace unravel
19{
20
26{
32 static auto init(rtti::context& ctx) -> bool;
33
39 static auto deinit(rtti::context& ctx) -> bool;
40
46 static auto init_assets(rtti::context& ctx) -> bool;
47
55 static auto create_embedded_mesh_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
56
67 static auto create_prefab_at(rtti::context& ctx,
68 scene& scn,
69 const std::string& key,
70 const camera& cam,
71 math::vec2 pos,
72 bool align_to_surface = false) -> entt::handle;
73
82 static auto create_prefab_at(rtti::context& ctx,
83 scene& scn,
84 const std::string& key,
85 math::vec3 pos) -> entt::handle;
86
94 static auto create_prefab_at(rtti::context& ctx,
95 scene& scn,
96 const std::string& key) -> entt::handle;
107 static auto create_mesh_entity_at(rtti::context& ctx,
108 scene& scn,
109 const std::string& key,
110 const camera& cam,
111 math::vec2 pos,
112 bool align_to_surface = false) -> entt::handle;
113
122 static auto create_mesh_entity_at(rtti::context& ctx,
123 scene& scn,
124 const std::string& key,
125 math::vec3 pos = {0.0f, 0.0f, 0.0f}) -> entt::handle;
126
134 static auto create_terrain(rtti::context& ctx, scene& scn, math::vec3 pos = {0.0f, 0.0f, 0.0f}) -> entt::handle;
135
144 static auto create_light_entity(rtti::context& ctx, scene& scn, light_type type, const std::string& name)
145 -> entt::handle;
146
155 static auto create_reflection_probe_entity(rtti::context& ctx, scene& scn, probe_type type, const std::string& name)
156 -> entt::handle;
157
165 static auto create_camera_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
166
174 static auto create_volume_entity(rtti::context& ctx, scene& scn, const std::string& name, volume_mode mode = volume_mode::local) -> entt::handle;
182 static auto create_ui_document_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
183
191 static auto create_text_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
192
200 static auto create_particle_emitter_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
201
209 static auto create_audio_source_entity(rtti::context& ctx, scene& scn, const std::string& name) -> entt::handle;
210
214 enum class scene_preset
215 {
216 low,
217 medium,
218 high,
220 };
221
226 static auto parse_scene_preset(hpp::string_view value, scene_preset& out) -> bool;
227
229 static auto scene_preset_to_string(scene_preset preset) -> const char*;
230
236 static void create_default_3d_scene(rtti::context& ctx, scene& scn);
237
245
246
253 static void focus_camera_on_entities(entt::handle camera,
254 hpp::span<const entt::handle> entities,
255 float duration = 0.0f);
256
264 static void focus_camera_on_bounds(entt::handle camera,
265 const math::bsphere& bounds,
266 float duration = 0.0f);
267
275 static void focus_camera_on_bounds(entt::handle camera,
276 const math::bbox& bounds,
277 float duration = 0.0f);
278
289 {
290 entt::handle object;
291 entt::handle camera;
292 };
293 template<typename T>
295 scene& scn,
296 const asset_handle<T>& asset,
297 const usize32_t& size, bool focus_camera = true) -> asset_preview_result;
298
299
300 template<typename T>
302 const asset_preview_result& result);
303
310
316 static auto calc_bounds_global(entt::handle entity, int depth = -1) -> math::bbox;
317
323 static auto calc_bounds_sphere_global(entt::handle entity, bool use_bbox_diagonal = true) -> math::bsphere;
324
325private:
333 static auto create_default_3d_scene_for_preview(rtti::context& ctx, scene& scn, const usize32_t& size)
334 -> entt::handle;
335
336 static auto create_default_volume_entity_for_preview(rtti::context& ctx, scene& scn, const std::string& name, volume_mode mode) -> entt::handle;
337
338};
339
340} // namespace unravel
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:62
defaults::scene_preset preset
std::string name
Definition hub.cpp:33
texture_job_type type
probe_type
Enum class representing the type of reflection probe.
light_type
Enum representing the type of light.
Definition light.h:14
entt::handle entity
Thread-safe handle to an asset.
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:289
Provides default initialization and creation functions for various entities and assets.
Definition defaults.h:26
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:947
static void focus_camera_on_3d_scene_for_asset_preview(rtti::context &ctx, const asset_preview_result &result)
static auto parse_scene_preset(hpp::string_view value, scene_preset &out) -> bool
Parse a preset name (low|medium|high|showcase; aliases: standard/default -> medium)....
static void create_scene_from_preset(rtti::context &ctx, scene &scn, scene_preset preset)
Creates a 3D scene from a quality preset.
static auto init_assets(rtti::context &ctx) -> bool
Initializes default assets.
Definition defaults.cpp:633
scene_preset
Quality presets for new scene creation (low = less expensive, high = more expensive).
Definition defaults.h:215
static auto init(rtti::context &ctx) -> bool
Initializes default settings and assets.
Definition defaults.cpp:596
static auto create_ui_document_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a UI document entity.
static auto create_text_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a text entity.
static auto create_audio_source_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a audio source entity.
static auto create_terrain(rtti::context &ctx, scene &scn, math::vec3 pos={0.0f, 0.0f, 0.0f}) -> entt::handle
Creates a test heightfield terrain entity (embedded procedural mesh).
Definition defaults.cpp:910
static auto create_volume_entity(rtti::context &ctx, scene &scn, const std::string &name, volume_mode mode=volume_mode::local) -> entt::handle
Creates a post process volume entity.
Definition defaults.cpp:968
static auto scene_preset_to_string(scene_preset preset) -> const char *
Stable string for logging / MCP / UI ("low", "medium", "high", "showcase").
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:808
static auto create_mesh_entity_at(rtti::context &ctx, scene &scn, const std::string &key, const camera &cam, math::vec2 pos, bool align_to_surface=false) -> entt::handle
Creates a mesh entity at a specified position.
Definition defaults.cpp:897
static auto calc_bounds_sphere_global(entt::handle entity, bool use_bbox_diagonal=true) -> math::bsphere
Calculates the bounding sphere of an entity.
static void focus_camera_on_entities(entt::handle camera, hpp::span< const entt::handle > entities, float duration=0.0f)
Focuses a camera on a specified entity with a timed transition.
static auto create_particle_emitter_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a particle emitter entity.
static void focus_camera_on_bounds(entt::handle camera, const math::bsphere &bounds, float duration=0.0f)
Focuses a camera on bounds with a timed transition.
Definition defaults.cpp:797
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.
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:921
static void create_default_3d_scene_for_editing(rtti::context &ctx, scene &scn)
Creates a default 3D scene for editing.
static auto create_camera_entity(rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
Creates a camera entity.
Definition defaults.cpp:999
static void create_default_3d_scene(rtti::context &ctx, scene &scn)
Creates a default 3D scene.
static auto create_prefab_at(rtti::context &ctx, scene &scn, const std::string &key, const camera &cam, math::vec2 pos, bool align_to_surface=false) -> entt::handle
Creates a prefab entity at a specified position.
Definition defaults.cpp:842
static auto deinit(rtti::context &ctx) -> bool
Deinitializes default settings and assets.
Definition defaults.cpp:603
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:70