59auto intersect_ray_triangle(
const math::vec3& origin,
60 const math::vec3& dir,
66 constexpr float epsilon = 1e-7f;
67 const math::vec3 edge1 = v1 - v0;
68 const math::vec3 edge2 = v2 - v0;
69 const math::vec3 pvec = math::cross(dir, edge2);
70 const float det = math::dot(edge1, pvec);
71 if(det > -epsilon && det < epsilon)
75 const float inv_det = 1.0f / det;
76 const math::vec3 tvec = origin - v0;
77 const float u = math::dot(tvec, pvec) * inv_det;
82 const math::vec3 qvec = math::cross(tvec, edge1);
83 const float v = math::dot(dir, qvec) * inv_det;
88 const float t = math::dot(edge2, qvec) * inv_det;
99void raycast_mesh_submesh(mesh& msh,
100 const mesh::submesh& submesh,
102 const math::vec3& ray_origin,
103 const math::vec3& ray_dir,
104 float& closest_world_t,
105 scene_ray_hit& out_hit)
107 const auto* vertex_data = msh.get_system_vb();
108 const auto* index_data = msh.get_system_ib();
109 if(vertex_data ==
nullptr || index_data ==
nullptr)
113 const auto& vertex_format = msh.get_vertex_format();
114 if(!vertex_format.has(gfx::attribute::Position))
118 const auto face_count = msh.get_face_count();
119 if(submesh.face_start < 0 || submesh.face_count == 0)
123 const auto face_begin =
static_cast<uint32_t
>(submesh.face_start);
124 if(face_begin >= face_count)
128 const auto face_end = std::min(face_begin + submesh.face_count, face_count);
132 const math::vec3 local_origin = inv_combined.
transform_coord(ray_origin);
133 const math::vec3 local_dir = inv_combined.
transform_coord(ray_origin + ray_dir) - local_origin;
135 for(uint32_t f = face_begin;
f < face_end; ++
f)
137 const uint32_t i0 = index_data[
f * 3 + 0];
138 const uint32_t i1 = index_data[
f * 3 + 1];
139 const uint32_t i2 = index_data[
f * 3 + 2];
141 std::array<float, 4> p0{};
142 std::array<float, 4> p1{};
143 std::array<float, 4> p2{};
144 gfx::vertex_unpack(p0.data(), gfx::attribute::Position, vertex_format, vertex_data, i0);
145 gfx::vertex_unpack(p1.data(), gfx::attribute::Position, vertex_format, vertex_data, i1);
146 gfx::vertex_unpack(p2.data(), gfx::attribute::Position, vertex_format, vertex_data, i2);
148 const math::vec3 v0{p0[0], p0[1], p0[2]};
149 const math::vec3 v1{p1[0], p1[1], p1[2]};
150 const math::vec3 v2{p2[0], p2[1], p2[2]};
152 float local_t = 0.0f;
153 if(!intersect_ray_triangle(local_origin, local_dir, v0, v1, v2, local_t))
159 const math::vec3 world_hit = combined.
transform_coord(local_origin + local_dir * local_t);
160 const float world_t = math::dot(world_hit - ray_origin, ray_dir);
161 if(world_t <= 0.0f || world_t >= closest_world_t)
166 closest_world_t = world_t;
168 out_hit.position = world_hit;
169 const math::vec3 local_normal = math::normalize(math::cross(v1 - v0, v2 - v0));
176auto raycast_scene_closest_surface(
scene& scn,
const camera& cam,
const math::vec2& screen_pos) -> scene_ray_hit
178 scene_ray_hit result;
180 math::vec3 ray_origin;
182 if(!cam.viewport_to_ray(screen_pos, ray_origin, ray_dir))
186 ray_dir = math::normalize(ray_dir);
188 float closest_world_t = std::numeric_limits<float>::max();
190 scn.registry->view<transform_component, model_component, active_component>().each(
191 [&](
auto e,
auto&& transform_comp,
auto&& model_comp,
auto&&) ->
void
193 if(!model_comp.is_enabled())
197 const auto& mdl = model_comp.get_model();
202 auto lod = mdl.get_lod(0);
207 const auto mesh_ptr = lod.get();
213 const auto& world_transform = transform_comp.get_transform_global();
219 if(!world_bounds.
intersect(ray_origin, ray_dir, box_t,
false))
223 if(box_t > closest_world_t)
228 const auto& submeshes = mesh_ptr->get_submeshes();
229 const auto node_transforms = mesh_ptr->get_submesh_node_transforms();
230 for(
size_t s = 0;
s < submeshes.size(); ++
s)
232 const auto* submesh = submeshes[
s];
233 if(submesh ==
nullptr)
238 if(s < node_transforms.size())
240 combined = world_transform * node_transforms[
s];
242 raycast_mesh_submesh(*mesh_ptr, *submesh, combined, ray_origin, ray_dir, closest_world_t, result);
253 math::vec3
normal{0.0f, 1.0f, 0.0f};
259auto compute_drop_placement(
scene& scn,
const camera& cam,
const math::vec2& screen_pos) -> drop_placement
261 const auto surface = raycast_scene_closest_surface(scn, cam, screen_pos);
267 math::vec3 projected_pos{0.0f, 0.0f, 0.0f};
268 cam.viewport_to_world(screen_pos,
272 return {projected_pos, math::vec3{0.0f, 1.0f, 0.0f},
false};
276auto shortest_arc_rotation(
const math::vec3& from,
const math::vec3& to) -> math::quat
278 const math::vec3
f = math::normalize(from);
279 const math::vec3
t = math::normalize(to);
280 const float d = math::dot(f, t);
281 if(d >= 1.0f - 1e-6f)
283 return math::quat(1.0f, 0.0f, 0.0f, 0.0f);
285 if(d <= -1.0f + 1e-6f)
288 math::vec3
axis = math::cross(math::vec3{1.0f, 0.0f, 0.0f},
f);
289 if(math::dot(axis, axis) < 1e-6f)
291 axis = math::cross(math::vec3{0.0f, 0.0f, 1.0f},
f);
293 return math::angleAxis(math::pi<float>(), math::normalize(axis));
295 const math::vec3
axis = math::normalize(math::cross(f, t));
296 return math::angleAxis(std::acos(d), axis);
305 auto& tc =
entity.get<transform_component>();
306 const auto world_xform = tc.get_transform_global();
309 if(
auto* mc =
entity.try_get<model_component>())
311 const auto&
b = mc->get_local_bounds(0);
314 for(
const auto& corner :
b.get_corners())
321 if(
auto* txt =
entity.try_get<text_component>())
323 const auto b = txt->get_render_bounds();
324 for(
const auto& corner :
b.get_corners())
330 if(
auto* pc =
entity.try_get<particle_emitter_component>())
333 const auto b = pc->get_updated_world_bounds(world_xform);
334 for(
const auto& corner :
b.get_corners())
342 for(
auto child : tc.get_children())
344 accumulate_obb_local(local_bounds, child, inv_root, depth > 0 ? depth - 1 : -1);
351auto calc_obb_world_corners(entt::handle
entity, std::array<math::vec3, 8>& out_corners,
int depth = -1) ->
bool
357 auto& tc =
entity.get<transform_component>();
358 const auto root_world = tc.get_transform_global();
362 accumulate_obb_local(
local,
entity, inv_root, depth);
363 if(!
local.is_populated())
368 const auto local_corners =
local.get_corners();
369 for(
size_t i = 0;
i < local_corners.size(); ++
i)
371 out_corners[
i] = root_world.transform_coord(local_corners[i]);
379void rest_entity_on_contact(entt::handle
object,
const math::vec3&
contact,
const math::vec3& up_dir)
381 if(!
object || !
object.all_of<transform_component>())
385 std::array<math::vec3, 8> corners{};
386 if(!calc_obb_world_corners(
object, corners))
390 float min_proj = std::numeric_limits<float>::max();
391 for(
const auto& corner : corners)
393 min_proj = std::min(min_proj, math::dot(corner -
contact, up_dir));
395 auto& tc =
object.get<transform_component>();
396 tc.set_position_global(tc.get_position_global() - up_dir * min_proj);
401void finalize_surface_placement(entt::handle
object,
const drop_placement& placement,
bool align_to_normal)
403 if(!
object || !
object.all_of<transform_component>())
407 math::vec3 up_dir{0.0f, 1.0f, 0.0f};
408 if(align_to_normal && placement.on_surface)
410 auto& tc =
object.get<transform_component>();
411 const math::quat
align = shortest_arc_rotation(up_dir, placement.normal);
412 tc.set_rotation_global(
align * tc.get_rotation_global());
413 up_dir = placement.normal;
415 rest_entity_on_contact(
object, placement.contact, up_dir);
419void run_camera_focus_transition(entt::handle camera,
420 const math::vec3& target_center,
425 if(!camera.all_of<transform_component, camera_component>())
430 auto& trans_comp = camera.get<transform_component>();
431 auto& camera_comp = camera.get<camera_component>();
432 const auto& cam = camera_comp.get_camera();
434 float aspect = cam.get_aspect_ratio();
435 float fov = cam.get_fov();
436 float horizontal_fov = math::degrees(2.0f * math::atan(math::tan(math::radians(fov) / 2.0f) * aspect));
437 float mfov = math::min(fov, horizontal_fov);
438 float target_distance = radius / (math::sin(math::radians(mfov) / 2.0f));
440 math::vec3 start_position = trans_comp.get_position_global();
441 float start_ortho_size = camera_comp.get_ortho_size();
444 math::vec3 initial_target_position{};
448 math::vec3 forward = math::normalize(trans_comp.get_z_axis_global());
449 if(math::length(forward) < 0.001f)
451 forward = math::vec3{0.0f, 0.0f, -1.0f};
453 initial_target_position = target_center - target_distance * forward;
458 math::vec3 dir = math::normalize(target_center - start_position);
459 if(math::length(dir) < 0.001f)
461 dir = math::vec3{0.0f, 0.0f, -1.0f};
463 initial_target_position = target_center - target_distance * dir;
467 float distance_to_target = math::length(start_position - initial_target_position);
468 float proximity_threshold = target_distance * 0.15f;
471 float adjusted_target_distance = target_distance;
472 if(distance_to_target < proximity_threshold)
475 adjusted_target_distance = target_distance * 3.0f;
479 math::vec3 target_position{};
482 math::vec3 forward = math::normalize(trans_comp.get_z_axis_global());
483 if(math::length(forward) < 0.001f)
485 forward = math::vec3{0.0f, 0.0f, -1.0f};
487 target_position = target_center - adjusted_target_distance * forward;
491 math::vec3 dir = math::normalize(target_center - start_position);
492 if(math::length(dir) < 0.001f)
494 dir = math::vec3{0.0f, 0.0f, -1.0f};
496 target_position = target_center - adjusted_target_distance * dir;
501 trans_comp.set_position_global(target_position);
504 trans_comp.look_at(target_center);
506 camera_comp.set_ortho_size(radius);
507 camera_comp.update(trans_comp.get_transform_global());
513 auto seq_duration = std::chrono::duration_cast<seq::duration_t>(std::chrono::duration<float>(duration));
515 struct camera_transition_state
517 math::vec3 current_position;
518 float current_ortho_size;
521 auto state = std::make_shared<camera_transition_state>();
522 state->current_position = start_position;
523 state->current_ortho_size = start_ortho_size;
525 auto position_action =
seq::change_to(state->current_position, target_position, seq_duration, state, ease);
526 auto ortho_action =
seq::change_to(state->current_ortho_size, radius, seq_duration, state, ease);
528 auto combined_action =
seq::together(position_action, ortho_action);
529 combined_action.on_step.connect([camera, state, keep_rotation, target_center]()
533 auto& tc = camera.get<transform_component>();
534 auto& cc = camera.get<camera_component>();
535 tc.set_position_global(state->current_position);
538 tc.look_at(target_center);
540 cc.set_ortho_size(state->current_ortho_size);
541 cc.update(tc.get_transform_global());
546 auto action_id =
seq::start(combined_action,
"camera_focus");
551void calc_bounds_global_impl(
math::bbox& bounds, entt::handle
entity,
int depth)
553 auto& tc =
entity.get<transform_component>();
554 const auto world_xform = tc.get_transform_global();
557 if(
auto* mc =
entity.try_get<model_component>())
559 mc->update_world_bounds(world_xform);
560 auto b = mc->get_world_bounds();
561 for(
const auto& corner :
b.get_corners())
567 if(
auto* tc =
entity.try_get<text_component>())
569 auto b = tc->get_render_bounds();
570 for(
const auto& corner :
b.get_corners())
572 bounds.
add_point(world_xform.transform_coord(corner));
576 if(
auto* pc =
entity.try_get<particle_emitter_component>())
578 auto b = pc->get_updated_world_bounds(world_xform);
579 for(
const auto& corner :
b.get_corners())
588 for(
auto child : tc.get_children())
590 calc_bounds_global_impl(bounds, child, depth > 0 ? depth - 1 : -1);
598 APPLOG_TRACE(
"{}::{}", hpp::type_name_str<defaults>(), __func__);
600 return init_assets(ctx);
605 APPLOG_TRACE(
"{}::{}", hpp::type_name_str<defaults>(), __func__);
637 const auto id =
"engine:/embedded/cube";
638 auto instance = std::make_shared<mesh>();
640 manager.get_asset_from_instance(
id, instance);
643 const auto id =
"engine:/embedded/cube_rounded";
644 auto instance = std::make_shared<mesh>();
646 manager.get_asset_from_instance(
id, instance);
649 const auto id =
"engine:/embedded/sphere";
650 auto instance = std::make_shared<mesh>();
652 manager.get_asset_from_instance(
id, instance);
655 const auto id =
"engine:/embedded/plane";
656 auto instance = std::make_shared<mesh>();
658 manager.get_asset_from_instance(
id, instance);
661 const auto id =
"engine:/embedded/cylinder";
662 auto instance = std::make_shared<mesh>();
664 manager.get_asset_from_instance(
id, instance);
667 const auto id =
"engine:/embedded/capsule_2m";
668 auto instance = std::make_shared<mesh>();
670 manager.get_asset_from_instance(
id, instance);
673 const auto id =
"engine:/embedded/capsule_1m";
674 auto instance = std::make_shared<mesh>();
676 manager.get_asset_from_instance(
id, instance);
679 const auto id =
"engine:/embedded/cone";
680 auto instance = std::make_shared<mesh>();
682 manager.get_asset_from_instance(
id, instance);
685 const auto id =
"engine:/embedded/torus";
686 auto instance = std::make_shared<mesh>();
688 manager.get_asset_from_instance(
id, instance);
691 const auto id =
"engine:/embedded/terrain_test";
692 constexpr uint32_t sx = 64;
693 constexpr uint32_t sz = 64;
694 constexpr float k_pi = 3.14159265f;
695 std::vector<float> heights(
static_cast<size_t>(sx + 1) *
static_cast<size_t>(sz + 1));
696 for(uint32_t
z = 0;
z <= sz; ++
z)
698 const float tz =
static_cast<float>(
z) /
static_cast<float>(sz);
699 for(uint32_t
x = 0;
x <= sx; ++
x)
701 const float tx =
static_cast<float>(
x) /
static_cast<float>(sx);
702 const float nx = tx * 2.0f - 1.0f;
703 const float nz = tz * 2.0f - 1.0f;
704 heights[
static_cast<size_t>(
z) *
static_cast<size_t>(sx + 1) +
static_cast<size_t>(
x)] =
705 std::sin(nx * k_pi * 2.0f) * std::cos(nz * k_pi * 2.0f) * 0.5f + 0.5f;
708 auto instance = std::make_shared<mesh>();
718 manager.get_asset_from_instance(
id, instance);
721 const auto id =
"engine:/embedded/teapot";
722 auto instance = std::make_shared<mesh>();
724 manager.get_asset_from_instance(
id, instance);
727 const auto id =
"engine:/embedded/icosahedron";
728 auto instance = std::make_shared<mesh>();
730 manager.get_asset_from_instance(
id, instance);
733 const auto id =
"engine:/embedded/dodecahedron";
734 auto instance = std::make_shared<mesh>();
736 manager.get_asset_from_instance(
id, instance);
739 for(
int i = 0; i < 20; ++i)
741 const auto id = std::string(
"engine:/embedded/icosphere") + std::to_string(i);
742 auto instance = std::make_shared<mesh>();
744 manager.get_asset_from_instance(
id, instance);
774 const auto id =
"engine:/embedded/standard";
775 auto instance = std::make_shared<pbr_material>();
776 auto asset = manager.get_asset_from_instance<
material>(
id, instance);
782 const auto id =
"engine:/embedded/fallback";
783 auto instance = std::make_shared<pbr_material>();
786 instance->set_roughness(1.0f);
787 auto asset = manager.get_asset_from_instance<
material>(
id, instance);
805 const float radius = math::length(bounds.
get_dimensions()) / 2.0f;
806 run_camera_focus_transition(
camera,
center, radius,
true, duration);
812 auto asset = am.get_asset<
mesh>(
id);
813 auto mesh_asset = asset.get();
817 return create_mesh_entity_at(ctx, scn,
id,
position);
825 auto object = scn.instantiate(asset);
834 auto object = scn.instantiate(asset);
844 const std::string& key,
847 bool align_to_surface) -> entt::handle
849 const auto placement = compute_drop_placement(scn, cam, pos);
850 auto object = create_prefab_at(ctx, scn, key, placement.contact);
851 finalize_surface_placement(
object, placement, align_to_surface);
865 auto mesh_ptr = asset.get();
868 const auto& material_uids = mesh_ptr->get_default_material_uids();
869 for(
size_t i = 0; i < material_uids.size(); ++i)
871 auto mat_asset = am.get_asset<
material>(material_uids[i]);
874 mdl.set_material(mat_asset,
static_cast<uint32_t
>(i));
879 std::string
name = fs::path(key).stem().string();
880 auto object = scn.create_entity(
name);
884 model_comp.set_model(mdl);
889 if(model_comp.is_skinned())
899 const std::string& key,
902 bool align_to_surface) -> entt::handle
904 const auto placement = compute_drop_placement(scn, cam, pos);
905 auto object = create_mesh_entity_at(ctx, scn, key, placement.contact);
906 finalize_surface_placement(
object, placement, align_to_surface);
912 static constexpr const char* terrain_mesh_id =
"engine:/embedded/terrain_test";
913 auto object = create_mesh_entity_at(ctx, scn, terrain_mesh_id, pos);
926 auto object = scn.create_entity(
name +
" Light");
933 transf_comp.rotate_by_euler_local({50.0f, -30.0f + 180.0f, 0.0f});
952 auto object = scn.create_entity(
"Reflection Probe" +
name);
970 auto object = scn.create_entity(
name);
972 volume_comp.
mode = mode;
987 auto object = scn.create_entity(
name);
989 volume_comp.
mode = mode;
1001 auto object = scn.create_entity(
name);
1014 auto object = scn.create_entity(
name);
1021 auto object = scn.create_entity(
name);
1031 auto object = scn.create_entity(
name);
1038 auto object = scn.create_entity(
name);
1045 if(value.empty() || value ==
"medium" || value ==
"standard" || value ==
"default")
1047 out = scene_preset::medium;
1052 out = scene_preset::low;
1057 out = scene_preset::high;
1060 if(value ==
"showcase")
1062 out = scene_preset::showcase;
1072 case scene_preset::low:
1074 case scene_preset::medium:
1076 case scene_preset::high:
1078 case scene_preset::showcase:
1098 auto light = light_comp.get_light();
1125 light_comp.set_light(
light);
1131 auto probe = reflection_comp.
get_probe();
1133 probe.sphere_data.range = 1000.0f;
1149 comp->enabled =
false;
1151 comp->enabled =
false;
1153 comp->enabled =
false;
1155 comp->enabled =
false;
1157 comp->enabled =
false;
1159 comp->enabled =
false;
1165 comp->settings.fidelityfx.max_rays = 4;
1169 comp->enabled =
false;
1175 comp->enabled =
true;
1177 comp->enabled =
true;
1180 comp->enabled =
true;
1185 comp->enabled =
true;
1189 comp->enabled =
true;
1194 comp->enabled =
true;
1196 comp->enabled =
true;
1198 comp->enabled =
true;
1200 comp->enabled =
true;
1218 auto probe = reflection_comp.
get_probe();
1220 probe.sphere_data.range = 1000.0f;
1229 auto camera = create_camera_entity(ctx, scn,
"Main Camera");
1230 auto post_process_volume = create_default_volume_entity_for_preview(ctx, scn,
"Volume Global",
volume_mode::global);
1235 transf_comp.set_rotation_euler_local({20.0f, 180.0f, 0.0f});
1236 auto& camera_comp = camera.get<camera_component>();
1237 camera_comp.set_viewport_size(
size);
1244 auto& transf_comp =
object.get<transform_component>();
1245 transf_comp.set_rotation_euler_local({110.0f, -10.0f, -35.0f});
1247 auto& light_comp =
object.get_or_emplace<light_component>();
1248 auto light = light_comp.get_light();
1249 light.casts_shadows =
false;
1250 light_comp.set_light(light);
1252 auto& skylight =
object.get_or_emplace<skylight_component>();
1256 auto object = create_reflection_probe_entity(ctx, scn,
probe_type::sphere,
" Global");
1257 auto& reflection_comp =
object.get_or_emplace<reflection_probe_component>();
1258 auto probe = reflection_comp.get_probe();
1260 probe.sphere_data.range = 1000.0f;
1261 reflection_comp.set_probe(probe);
1278 if(bounds.radius < 1.0f)
1280 float scale = 1.0f / bounds.radius;
1291 if(bounds.radius < 1.0f)
1293 float scale = 1.0f / bounds.radius;
1309 auto camera = create_default_3d_scene_for_preview(ctx, scn,
size);
1312 auto object = create_embedded_mesh_entity(ctx, scn,
"Sphere");
1314 auto model = model_comp.get_model();
1316 model_comp.set_model(
model);
1317 model_comp.set_casts_shadow(
false);
1321 focus_camera_on_bounds(
camera, calc_bounds_sphere_global(
object,
false), 0.0f);
1337 auto camera = create_default_3d_scene_for_preview(ctx, scn,
size);
1340 auto object = scn.instantiate(asset,
false);
1344 if(
auto model_comp =
object.try_get<model_component>())
1346 model_comp->set_casts_shadow(
false);
1349 auto bounds = calc_bounds_sphere_global(
object);
1350 if(bounds.radius < 1.0f)
1352 float scale = 1.0f / bounds.radius;
1358 focus_camera_on_bounds(
camera, calc_bounds_sphere_global(
object), 0.0f);
1374 auto camera = create_default_3d_scene_for_preview(ctx, scn,
size);
1376 auto object = create_mesh_entity_at(ctx, scn, asset.id());
1378 if(
auto model_comp =
object.try_get<model_component>())
1380 model_comp->set_casts_shadow(
false);
1383 auto bounds = calc_bounds_sphere_global(
object);
1384 if(bounds.radius < 1.0f)
1386 float scale = 1.0f / bounds.radius;
1392 focus_camera_on_bounds(
camera, calc_bounds_sphere_global(
object), 0.0f);
1400 hpp::span<const entt::handle> entities,
1408 for(
const auto&
entity : entities)
1431 calc_bounds_global_impl(bounds,
entity, depth);
1436 const math::vec3 one{1, 1, 1};
1451 math::vec3 diag =
box.get_dimensions();
1452 float max_abs = math::max(math::abs(diag.x), math::max(math::abs(diag.y), math::abs(diag.z)));
1453 float radius = 0.5f * (use_bbox_diagonal ? math::length(diag) : max_abs);
const btCollisionObject * object
Provides storage for common representation of spherical bounding volume, and wraps up common function...
Manages assets, including loading, unloading, and storage.
auto get_asset(const std::string &key, load_flags flags=load_flags::standard, load_mode mode=load_mode::immediate) -> asset_handle< T >
Gets an asset by its key.
Class that contains core data for audio listeners. There can only be one instance of it per scene.
Class that contains core data for audio sources.
Class that contains core camera data, used for rendering and other purposes.
Class representing a camera. Contains functionality for manipulating and updating a camera....
static auto get() -> default_textures &
Class that contains core light data, used for rendering and other purposes.
void set_light(const light &l)
Sets the light object.
Base class for materials used in rendering.
static auto default_normal_map() -> asset_handle< gfx::texture > &
Gets the default normal map.
static auto default_color_map() -> asset_handle< gfx::texture > &
Gets the default color map.
Main class representing a 3D mesh with support for different LODs, submeshes, and skinning.
auto get_bounds() const -> const math::bbox &
Gets the local bounding box for this mesh.
Class that contains core data for meshes.
void set_casts_shadow(bool cast_shadow)
Sets whether the model casts shadows.
Structure describing a LOD group (set of meshes), LOD transitions, and their materials.
static auto fallback_material() -> asset_handle< material > &
Gets the fallback material.
void set_material(asset_handle< material > material, uint32_t index)
Sets the material for the specified index.
static auto default_material() -> asset_handle< material > &
Gets the default material.
void set_lod(asset_handle< mesh > mesh, uint32_t lod)
Sets the LOD (Level of Detail) mesh for the specified level.
Component that wraps the soa particle system emitter.
Class that contains core reflection probe data, used for rendering and other purposes.
auto get_probe() const -> const reflection_probe &
Gets the reflection probe object.
void set_probe(const reflection_probe &probe)
Sets the reflection probe object.
Class that contains sky light data.
@ none
No clouds rendered.
@ flat
Flat projected clouds (cheap, single-sample scattering)
@ volumetric
Volumetric raymarched clouds (full scattering, half-res with temporal)
Temporal anti-aliasing (HDR, before tonemap). Mutually exclusive with FXAA when enabled.
void set_text(const std::string &text)
Sets the text content to be rendered.
Spatial volume that applies post-processing effects when the camera is inside. Effect settings come f...
volume_mode mode
Volume mode: local uses bounds, global affects camera everywhere.
defaults::scene_preset preset
#define APPLOG_TRACE(...)
void vertex_unpack(float _output[4], attribute _attr, const vertex_layout &_decl, const void *_data, uint32_t _index)
auto inverse(transform_t< T, Q > const &t) noexcept -> transform_t< T, Q >
float smooth_stop(float progress)
Modelled after quarter-cycle of sine wave (different phase)
void stop_all(const std::string &scope)
Stops all actions within the specified scope.
auto start(seq_action action, const seq_scope_policy &scope_policy, hpp::source_location location) -> seq_id_t
Starts a new action.
auto together(const std::vector< seq_action > &actions, const sentinel_t &sentinel) -> seq_action
Creates a simultaneous action that executes a list of actions together.
auto change_to(T &object, const std::decay_t< T > &end, const duration_t &duration, const sentinel_t &sentinel, const ease_t &ease_func=ease::linear) -> seq_action
Creates an action to change an object to a specified value over a specified duration.
auto replace(const std::string &str, const std::string &search, const std::string &replace) -> std::string
auto to_lower(const std::string &str) -> std::string
probe_type
Enum class representing the type of reflection probe.
@ sphere
Sphere type reflection probe.
@ box
Box type reflection probe.
light_type
Enum representing the type of light.
@ environment
Environment reflection method.
@ static_only
Static-only reflection method.
std::vector< float > scale
Thread-safe handle to an asset.
static auto get_layout() -> const vertex_layout &
Storage for box vector values and wraps up common functionality.
bbox & add_point(const vec3 &point)
Grows the bounding box based on the point passed.
bool intersect(const bbox &bounds) const
Tests to see if this AABB is intersected by another AABB.
bbox & mul(const transform &t)
Transforms an axis aligned bounding box by the specified matrix.
bool is_populated() const
Checks if the bounding box is populated.
vec3 get_dimensions() const
Returns a vector containing the dimensions of the bounding box.
vec3 get_extents() const
Returns a vector containing the extents of the bounding box (the half-dimensions)
vec3 get_center() const
Returns a vector containing the exact center point of the box.
static auto from_point_normal(const vec3 &point, const vec3 &normal) -> plane
Creates a plane from a point and a normal.
Creates a default 3D scene for asset preview.
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 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.
scene_preset
Quality presets for new scene creation (low = less expensive, high = more expensive).
static auto init(rtti::context &ctx) -> bool
Initializes default settings and assets.
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).
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 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.
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 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.
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.
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.
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.
static auto deinit(rtti::context &ctx) -> bool
Deinitializes default settings and assets.
static auto default_light() -> asset_handle< font > &
static auto default_heavy() -> asset_handle< font > &
static auto default_extra_light() -> asset_handle< font > &
static auto default_regular() -> asset_handle< font > &
static auto default_bold() -> asset_handle< font > &
static auto default_semi_bold() -> asset_handle< font > &
static auto default_thin() -> asset_handle< font > &
static auto default_black() -> asset_handle< font > &
static auto default_medium() -> asset_handle< font > &
sm_resolution resolution
Resolution of the shadow map.
sm_impl type
Implementation type for shadow mapping.
Struct representing a light.
struct unravel::light::shadowmap_params shadow_params
struct unravel::light::contact_shadow_params contact_shadow
light_type type
The type of the light.
math::color color
The color of the light.
Represents a generic prefab with a buffer for serialized data.
Structure representing a reflection probe.
probe_type type
Type of the reflection probe.
reflect_method method
Reflection method.
Represents a scene in the ACE framework, managing entities and their relationships.
Component that provides a tag (name or label) for an entity.
Component that holds a reference to a UI document for RmlUi rendering.