Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::defaults Struct Reference

Provides default initialization and creation functions for various entities and assets. More...

#include <defaults.h>

Classes

struct  asset_preview_result
 Creates a default 3D scene for asset preview. More...
 

Public Types

enum class  scene_preset { low , medium , high , showcase }
 Quality presets for new scene creation (low = less expensive, high = more expensive). More...
 

Public Member Functions

template<>
auto create_default_3d_scene_for_asset_preview (rtti::context &ctx, scene &scn, const asset_handle< material > &asset, const usize32_t &size, bool focus_camera) -> asset_preview_result
 
template<>
auto create_default_3d_scene_for_asset_preview (rtti::context &ctx, scene &scn, const asset_handle< prefab > &asset, const usize32_t &size, bool focus_camera) -> asset_preview_result
 
template<>
auto create_default_3d_scene_for_asset_preview (rtti::context &ctx, scene &scn, const asset_handle< mesh > &asset, const usize32_t &size, bool focus_camera) -> asset_preview_result
 

Static Public Member Functions

static auto init (rtti::context &ctx) -> bool
 Initializes default settings and assets.
 
static auto deinit (rtti::context &ctx) -> bool
 Deinitializes default settings and assets.
 
static auto init_assets (rtti::context &ctx) -> bool
 Initializes default assets.
 
static auto create_embedded_mesh_entity (rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
 Creates an embedded mesh entity.
 
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.
 
static auto create_prefab_at (rtti::context &ctx, scene &scn, const std::string &key, math::vec3 pos) -> entt::handle
 Creates a prefab entity at a specified position.
 
static auto create_prefab_at (rtti::context &ctx, scene &scn, const std::string &key) -> entt::handle
 Creates a prefab entity.
 
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.
 
static auto create_mesh_entity_at (rtti::context &ctx, scene &scn, const std::string &key, math::vec3 pos={0.0f, 0.0f, 0.0f}) -> entt::handle
 Creates a mesh entity at a specified position.
 
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).
 
static auto create_light_entity (rtti::context &ctx, scene &scn, light_type type, const std::string &name) -> entt::handle
 Creates a light entity.
 
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.
 
static auto create_camera_entity (rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
 Creates a camera entity.
 
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.
 
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_particle_emitter_entity (rtti::context &ctx, scene &scn, const std::string &name) -> entt::handle
 Creates a particle emitter 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 parse_scene_preset (hpp::string_view value, scene_preset &out) -> bool
 Parse a preset name (low|medium|high|showcase; aliases: standard/default -> medium). Empty string resolves to medium.
 
static auto scene_preset_to_string (scene_preset preset) -> const char *
 Stable string for logging / MCP / UI ("low", "medium", "high", "showcase").
 
static void create_default_3d_scene (rtti::context &ctx, scene &scn)
 Creates a default 3D scene.
 
static void create_scene_from_preset (rtti::context &ctx, scene &scn, scene_preset preset)
 Creates a 3D scene from a quality preset.
 
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 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.
 
static void focus_camera_on_bounds (entt::handle camera, const math::bbox &bounds, float duration=0.0f)
 Focuses a camera on bounds with a timed transition.
 
template<typename T >
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
 
template<typename T >
static void focus_camera_on_3d_scene_for_asset_preview (rtti::context &ctx, const asset_preview_result &result)
 
static void create_default_3d_scene_for_editing (rtti::context &ctx, scene &scn)
 Creates a default 3D scene for editing.
 
static auto calc_bounds_global (entt::handle entity, int depth=-1) -> math::bbox
 Calculates the bounding box of an entity.
 
static auto calc_bounds_sphere_global (entt::handle entity, bool use_bbox_diagonal=true) -> math::bsphere
 Calculates the bounding sphere of an entity.
 
template<>
void focus_camera_on_3d_scene_for_asset_preview (rtti::context &ctx, const asset_preview_result &result)
 
template<>
void focus_camera_on_3d_scene_for_asset_preview (rtti::context &ctx, const asset_preview_result &result)
 
template<>
void focus_camera_on_3d_scene_for_asset_preview (rtti::context &ctx, const asset_preview_result &result)
 

Detailed Description

Provides default initialization and creation functions for various entities and assets.

Definition at line 25 of file defaults.h.

Member Enumeration Documentation

◆ scene_preset

Quality presets for new scene creation (low = less expensive, high = more expensive).

Enumerator
low 
medium 
high 
showcase 

Definition at line 214 of file defaults.h.

Member Function Documentation

◆ calc_bounds_global()

auto unravel::defaults::calc_bounds_global ( entt::handle entity,
int depth = -1 ) -> math::bbox
static

Calculates the bounding box of an entity.

Parameters
entityThe entity to calculate the bounds for.
Returns
The bounding box of the entity.

Definition at line 1427 of file defaults.cpp.

◆ calc_bounds_sphere_global()

auto unravel::defaults::calc_bounds_sphere_global ( entt::handle entity,
bool use_bbox_diagonal = true ) -> math::bsphere
static

Calculates the bounding sphere of an entity.

Parameters
entityThe entity to calculate the bounds for.
Returns
The bounding sphere of the entity.

Definition at line 1444 of file defaults.cpp.

◆ create_audio_source_entity()

auto unravel::defaults::create_audio_source_entity ( rtti::context & ctx,
scene & scn,
const std::string & name ) -> entt::handle
static

Creates a audio source entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the audio source entity.
Returns
A handle to the created entity.

Definition at line 1036 of file defaults.cpp.

◆ create_camera_entity()

auto unravel::defaults::create_camera_entity ( rtti::context & ctx,
scene & scn,
const std::string & name ) -> entt::handle
static

Creates a camera entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the camera entity.
Returns
A handle to the created entity.

Definition at line 999 of file defaults.cpp.

◆ create_default_3d_scene()

void unravel::defaults::create_default_3d_scene ( rtti::context & ctx,
scene & scn )
static

Creates a default 3D scene.

Parameters
ctxThe context for creation.
scnThe scene to create.

Definition at line 1084 of file defaults.cpp.

◆ create_default_3d_scene_for_asset_preview() [1/4]

template<>
auto unravel::defaults::create_default_3d_scene_for_asset_preview ( rtti::context & ctx,
scene & scn,
const asset_handle< material > & asset,
const usize32_t & size,
bool focus_camera ) -> asset_preview_result

Definition at line 1301 of file defaults.cpp.

◆ create_default_3d_scene_for_asset_preview() [2/4]

template<>
auto unravel::defaults::create_default_3d_scene_for_asset_preview ( rtti::context & ctx,
scene & scn,
const asset_handle< mesh > & asset,
const usize32_t & size,
bool focus_camera ) -> asset_preview_result

Definition at line 1366 of file defaults.cpp.

◆ create_default_3d_scene_for_asset_preview() [3/4]

template<>
auto unravel::defaults::create_default_3d_scene_for_asset_preview ( rtti::context & ctx,
scene & scn,
const asset_handle< prefab > & asset,
const usize32_t & size,
bool focus_camera ) -> asset_preview_result

Definition at line 1329 of file defaults.cpp.

◆ create_default_3d_scene_for_asset_preview() [4/4]

template<typename T >
static auto unravel::defaults::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

◆ create_default_3d_scene_for_editing()

void unravel::defaults::create_default_3d_scene_for_editing ( rtti::context & ctx,
scene & scn )
static

Creates a default 3D scene for editing.

Parameters
ctxThe context for creation.
scnThe scene to create.

Definition at line 1205 of file defaults.cpp.

◆ create_embedded_mesh_entity()

auto unravel::defaults::create_embedded_mesh_entity ( rtti::context & ctx,
scene & scn,
const std::string & name ) -> entt::handle
static

Creates an embedded mesh entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the entity.
Returns
A handle to the created entity.

Definition at line 808 of file defaults.cpp.

◆ create_light_entity()

auto unravel::defaults::create_light_entity ( rtti::context & ctx,
scene & scn,
light_type type,
const std::string & name ) -> entt::handle
static

Creates a light entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
typeThe type of light to create.
nameThe name of the light entity.
Returns
A handle to the created entity.

Definition at line 921 of file defaults.cpp.

◆ create_mesh_entity_at() [1/2]

auto unravel::defaults::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
static

Creates a mesh entity at a specified position.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
keyThe key of the mesh.
camThe camera to use for positioning.
posThe 2D position to place the mesh.
align_to_surfaceWhen true, aligns the object to the hit surface normal (otherwise stays upright).
Returns
A handle to the created entity.

Definition at line 897 of file defaults.cpp.

◆ create_mesh_entity_at() [2/2]

auto unravel::defaults::create_mesh_entity_at ( rtti::context & ctx,
scene & scn,
const std::string & key,
math::vec3 pos = {0.0f, 0.0f, 0.0f} ) -> entt::handle
static

Creates a mesh entity at a specified position.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
keyThe key of the mesh.
posThe 3D position to place the mesh.
Returns
A handle to the created entity.

Definition at line 855 of file defaults.cpp.

◆ create_particle_emitter_entity()

auto unravel::defaults::create_particle_emitter_entity ( rtti::context & ctx,
scene & scn,
const std::string & name ) -> entt::handle
static

Creates a particle emitter entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the particle emitter entity.
Returns
A handle to the created entity.

Definition at line 1029 of file defaults.cpp.

◆ create_prefab_at() [1/3]

auto unravel::defaults::create_prefab_at ( rtti::context & ctx,
scene & scn,
const std::string & key ) -> entt::handle
static

Creates a prefab entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
keyThe key of the prefab.
Returns
A handle to the created entity.

Definition at line 820 of file defaults.cpp.

◆ create_prefab_at() [2/3]

auto unravel::defaults::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
static

Creates a prefab entity at a specified position.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
keyThe key of the prefab.
camThe camera to use for positioning.
posThe 2D position to place the prefab.
align_to_surfaceWhen true, aligns the object to the hit surface normal (otherwise stays upright).
Returns
A handle to the created entity.

Definition at line 842 of file defaults.cpp.

◆ create_prefab_at() [3/3]

auto unravel::defaults::create_prefab_at ( rtti::context & ctx,
scene & scn,
const std::string & key,
math::vec3 pos ) -> entt::handle
static

Creates a prefab entity at a specified position.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
keyThe key of the prefab.
posThe 3D position to place the prefab.
Returns
A handle to the created entity.

Definition at line 829 of file defaults.cpp.

◆ create_reflection_probe_entity()

auto unravel::defaults::create_reflection_probe_entity ( rtti::context & ctx,
scene & scn,
probe_type type,
const std::string & name ) -> entt::handle
static

Creates a reflection probe entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
typeThe type of reflection probe to create.
nameThe name of the reflection probe entity.
Returns
A handle to the created entity.

Definition at line 947 of file defaults.cpp.

◆ create_scene_from_preset()

void unravel::defaults::create_scene_from_preset ( rtti::context & ctx,
scene & scn,
scene_preset preset )
static

Creates a 3D scene from a quality preset.

Parameters
ctxThe context for creation.
scnThe scene to create.
presetThe quality preset (low/medium/high).

Definition at line 1089 of file defaults.cpp.

◆ create_terrain()

auto unravel::defaults::create_terrain ( rtti::context & ctx,
scene & scn,
math::vec3 pos = {0.0f, 0.0f, 0.0f} ) -> entt::handle
static

Creates a test heightfield terrain entity (embedded procedural mesh).

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
posWorld position of the terrain origin.
Returns
A handle to the created entity.

Definition at line 910 of file defaults.cpp.

◆ create_text_entity()

auto unravel::defaults::create_text_entity ( rtti::context & ctx,
scene & scn,
const std::string & name ) -> entt::handle
static

Creates a text entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the text entity.
Returns
A handle to the created entity.

Definition at line 1019 of file defaults.cpp.

◆ create_ui_document_entity()

auto unravel::defaults::create_ui_document_entity ( rtti::context & ctx,
scene & scn,
const std::string & name ) -> entt::handle
static

Creates a UI document entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the UI document entity.
Returns
A handle to the created entity.

Definition at line 1012 of file defaults.cpp.

◆ create_volume_entity()

auto unravel::defaults::create_volume_entity ( rtti::context & ctx,
scene & scn,
const std::string & name,
volume_mode mode = volume_mode::local ) -> entt::handle
static

Creates a post process volume entity.

Parameters
ctxThe context for creation.
scnThe scene to create the entity in.
nameThe name of the post process volume entity.
Returns
A handle to the created entity.

Definition at line 968 of file defaults.cpp.

◆ deinit()

auto unravel::defaults::deinit ( rtti::context & ctx) -> bool
static

Deinitializes default settings and assets.

Parameters
ctxThe context for deinitialization.
Returns
True if deinitialization was successful, false otherwise.

Definition at line 603 of file defaults.cpp.

◆ focus_camera_on_3d_scene_for_asset_preview() [1/4]

template<>
void unravel::defaults::focus_camera_on_3d_scene_for_asset_preview ( rtti::context & ctx,
const asset_preview_result & result )
static

Definition at line 1268 of file defaults.cpp.

◆ focus_camera_on_3d_scene_for_asset_preview() [2/4]

template<>
void unravel::defaults::focus_camera_on_3d_scene_for_asset_preview ( rtti::context & ctx,
const asset_preview_result & result )
static

Definition at line 1275 of file defaults.cpp.

◆ focus_camera_on_3d_scene_for_asset_preview() [3/4]

template<>
void unravel::defaults::focus_camera_on_3d_scene_for_asset_preview ( rtti::context & ctx,
const asset_preview_result & result )
static

Definition at line 1288 of file defaults.cpp.

◆ focus_camera_on_3d_scene_for_asset_preview() [4/4]

template<typename T >
static void unravel::defaults::focus_camera_on_3d_scene_for_asset_preview ( rtti::context & ctx,
const asset_preview_result & result )
static

◆ focus_camera_on_bounds() [1/2]

void unravel::defaults::focus_camera_on_bounds ( entt::handle camera,
const math::bbox & bounds,
float duration = 0.0f )
static

Focuses a camera on bounds with a timed transition.

Parameters
cameraThe camera to focus.
boundsThe bounding box to focus on.
durationThe duration of the transition in seconds.
ease_funcThe easing function to apply (default is smooth_start_stop).

Definition at line 802 of file defaults.cpp.

◆ focus_camera_on_bounds() [2/2]

void unravel::defaults::focus_camera_on_bounds ( entt::handle camera,
const math::bsphere & bounds,
float duration = 0.0f )
static

Focuses a camera on bounds with a timed transition.

Parameters
cameraThe camera to focus.
boundsThe bounding sphere to focus on.
durationThe duration of the transition in seconds.
ease_funcThe easing function to apply (default is smooth_start_stop).

Definition at line 797 of file defaults.cpp.

◆ focus_camera_on_entities()

void unravel::defaults::focus_camera_on_entities ( entt::handle camera,
hpp::span< const entt::handle > entities,
float duration = 0.0f )
static

Focuses a camera on a specified entity with a timed transition.

Parameters
cameraThe camera to focus.
entitiesThe entities to focus on.
durationThe duration of the transition in seconds.

Definition at line 1399 of file defaults.cpp.

◆ init()

auto unravel::defaults::init ( rtti::context & ctx) -> bool
static

Initializes default settings and assets.

Parameters
ctxThe context for initialization.
Returns
True if initialization was successful, false otherwise.

Definition at line 596 of file defaults.cpp.

◆ init_assets()

auto unravel::defaults::init_assets ( rtti::context & ctx) -> bool
static

Initializes default assets.

Parameters
ctxThe context for initialization.
Returns
True if initialization was successful, false otherwise.

Definition at line 633 of file defaults.cpp.

◆ parse_scene_preset()

auto unravel::defaults::parse_scene_preset ( hpp::string_view value,
scene_preset & out ) -> bool
static

Parse a preset name (low|medium|high|showcase; aliases: standard/default -> medium). Empty string resolves to medium.

Definition at line 1043 of file defaults.cpp.

◆ scene_preset_to_string()

auto unravel::defaults::scene_preset_to_string ( scene_preset preset) -> const char*
static

Stable string for logging / MCP / UI ("low", "medium", "high", "showcase").

Definition at line 1068 of file defaults.cpp.


The documentation for this struct was generated from the following files: