6#include <nlohmann/json.hpp>
8#include "ecs/entity_mapping.h"
9#include "ecs/environment.h"
10#include "resource/asset_type.h"
11#include "ecs/component/animation/animation.h"
12#include "ecs/component/animation/animator.h"
13#include "ecs/component/animation/bone_socket.h"
14#include "ecs/component/audio/audio_listener.h"
15#include "ecs/component/audio/audio_source.h"
16#include "ecs/component/core/hierarchy.h"
17#include "ecs/component/core/name.h"
18#include "ecs/component/core/transform.h"
19#include "ecs/component/physics/character_controller.h"
20#include "ecs/component/physics/collider.h"
21#include "ecs/component/physics/joint.h"
22#include "ecs/component/physics/ragdoll.h"
23#include "ecs/component/physics/rigidbody.h"
24#include "ecs/component/render/camera.h"
25#include "ecs/component/render/decal.h"
26#include "ecs/component/render/irradiance_volume.h"
27#include "ecs/component/render/light.h"
28#include "ecs/component/render/lod.h"
29#include "ecs/component/render/mesh.h"
30#include "ecs/component/render/ocean.h"
31#include "ecs/component/render/particle_emitter.h"
32#include "ecs/component/render/planar_reflector.h"
33#include "ecs/component/render/reflection_probe.h"
34#include "ecs/component/render/terrain.h"
35#include "ecs/component/ui/ui_button.h"
36#include "ecs/component/ui/ui_canvas.h"
37#include "ecs/component/ui/ui_choice.h"
38#include "ecs/component/ui/ui_element.h"
39#include "ecs/component/ui/ui_image.h"
40#include "ecs/component/core/net_local.h"
41#include "ecs/component/ui/ui_scroll.h"
42#include "ecs/component/ui/ui_slider.h"
43#include "ecs/component/ui/ui_toggle.h"
44#include "ecs/component/ui/ui_text.h"
45#include "system/script/script_component.h"
47namespace Vkm::Engine {
64#define VKM_SCENE_COMPONENTS(P, R, E) \
66 P(Transform, "Transform") \
69 P(Rigidbody, "Rigidbody") \
70 R(Collider, "Collider") \
71 P(CharacterController, "CharacterController") \
73 E(Ragdoll, "Ragdoll") \
77 R(ParticleEmitter, "ParticleEmitter") \
78 P(ParticleTrigger, "ParticleTrigger") \
79 R(AudioSource, "AudioSource") \
80 P(AudioListener, "AudioListener") \
81 P(IrradianceVolume, "IrradianceVolume") \
83 P(ReflectionProbe, "ReflectionProbe") \
84 P(PlanarReflector, "PlanarReflector") \
85 R(Terrain, "Terrain") \
86 P(Animation, "Animation") \
87 R(Animator, "Animator") \
88 P(BoneSocket, "BoneSocket") \
89 P(ScriptComponent, "Script") \
90 P(UICanvas, "UICanvas") \
91 P(UIElement, "UIElement") \
92 R(UIImage, "UIImage") \
94 P(UIButton, "UIButton") \
95 P(UIScroll, "UIScroll") \
96 E(UISlider, "UISlider") \
97 E(UIToggle, "UIToggle") \
98 E(UIChoice, "UIChoice") \
99 P(NetLocal, "NetLocal")
114 nlohmann::json save(
const Name&);
115 void load(
const nlohmann::json&,
Name&);
126 void load(
const nlohmann::json&,
Transform&);
128 nlohmann::json save(
const Camera&);
129 void load(
const nlohmann::json&,
Camera&);
131 nlohmann::json save(
const Light&);
132 void load(
const nlohmann::json&,
Light&);
140 void load(
const nlohmann::json&,
Rigidbody&);
163 nlohmann::json save(
const Joint&,
const EntityNamer&);
164 void load(
const nlohmann::json&,
Joint&,
const EntityResolver&);
172 nlohmann::json save(
const Ragdoll&,
const EntityNamer&);
173 void load(
const nlohmann::json&,
Ragdoll&,
const EntityResolver&);
193 void load(
const nlohmann::json&,
BoneSocket&);
222 nlohmann::json save(
const Ocean&);
223 void load(
const nlohmann::json&,
Ocean&);
233 nlohmann::json save(
const UICanvas&);
234 void load(
const nlohmann::json&,
UICanvas&);
237 void load(
const nlohmann::json&,
UIElement&);
242 nlohmann::json save(
const UIText&);
243 void load(
const nlohmann::json&,
UIText&);
245 nlohmann::json save(
const UIButton&);
246 void load(
const nlohmann::json&,
UIButton&);
248 nlohmann::json save(
const UIScroll&);
249 void load(
const nlohmann::json&,
UIScroll&);
251 nlohmann::json save(
const NetLocal&);
252 void load(
const nlohmann::json&,
NetLocal&);
254 nlohmann::json save(
const UISlider&,
const EntityNamer&);
255 void load(
const nlohmann::json&,
UISlider&,
const EntityResolver&);
257 nlohmann::json save(
const UIToggle&,
const EntityNamer&);
258 void load(
const nlohmann::json&,
UIToggle&,
const EntityResolver&);
260 nlohmann::json save(
const UIChoice&,
const EntityNamer&);
261 void load(
const nlohmann::json&,
UIChoice&,
const EntityResolver&);
285 void load(
const nlohmann::json&,
Animation&);
305 std::vector<MeshHandle> meshes;
306 std::vector<MaterialHandle> materials;
307 std::vector<SkeletonHandle> skeletons;
308 std::vector<TextureHandle> textures;
309 std::vector<AnimationClipHandle> clips;
310 std::vector<AudioClipHandle> sounds;
311 std::vector<TerrainHandle> terrains;
339 AssetType
type = AssetType::Count;
362 class UnresolvedScope {
364 UnresolvedScope() =
default;
367 UnresolvedScope(
const UnresolvedScope& other) =
delete;
368 UnresolvedScope& operator=(
const UnresolvedScope& other) =
delete;
370 UnresolvedScope(UnresolvedScope && other) =
delete;
371 UnresolvedScope& operator=(UnresolvedScope && other) =
delete;
Type-erased resource registry with typed handles and generational lifetimes.
Definition resource_manager.h:46
Central registry managing entities and an open set of component types.
Definition scene.h:29
Per-component (de)serialization to JSON.
Definition component_serializer.h:109
uint32_t loadParentIndex(const nlohmann::json &json)
Read a saved Hierarchy's parent reference as a saved slot.
void emitAssetRefs(const Collider &, AssetRefs &)
Record every asset the component references into refs.
std::vector< UnresolvedRef > takeUnresolvedRefs()
Take the references the loads since the last call could not resolve.
Component representing an animation that can be applied to an entity.
Definition animation.h:17
What drives a rig: the skeleton, the clip playing on it, and the playback position.
Definition animator.h:45
The ear: the pose every spatial source is heard relative to.
Definition audio_listener.h:16
A sound emitter: one clip, how loud, and where it is heard from.
Definition audio_source.h:26
Carried by a weapon, a hat or a muzzle flash to ride a bone of the rig it hangs off.
Definition bone_socket.h:23
Component representing a camera, containing projection and view parameters.
Definition camera.h:25
Turns a desired direction into velocity on a Rigidbody, and reports what the body stands on.
Definition character_controller.h:17
Collision geometry attached to an entity, evaluated in its Transform frame.
Definition collider.h:84
Every asset a set of components references, one list per kind.
Definition component_serializer.h:304
An asset name a load failed to resolve, and the field it was read from.
Definition component_serializer.h:336
AssetType type
Which kind the loader looked it up as.
Definition component_serializer.h:339
A projected decal - bullet holes, blood, scorch marks.
Definition decal.h:16
The scene's lighting environment: sky, night sky and fog.
Definition environment.h:137
Component representing parent-child relationships in an entity hierarchy.
Definition hierarchy.h:16
Baked global illumination: a grid of irradiance probes filling a box.
Definition irradiance_volume.h:21
Ties this entity's body to another, at a point on each.
Definition joint.h:31
Distance-selected geometry for an entity.
Definition lod.h:25
Component representing a light source in the scene.
Definition light.h:36
Component representing a renderable mesh (geometry + material) in the world.
Definition mesh.h:34
Component for giving entities a human-readable name.
Definition name.h:15
Keeps an entity, and everything below it, off the wire: each end runs its own.
Definition net_local.h:18
The scene's sea: wind-driven waves moving every surface whose material is waves.
Definition ocean.h:40
CPU-simulated particle emitter: fire, smoke, sparks, impacts, trails, heat haze.
Definition particle_emitter.h:74
Makes a child entity's ParticleEmitter a sub-emitter of its parent's.
Definition particle_emitter.h:165
The physics world's own parameters, read once per fixed step.
Definition physics_settings.h:14
A flat mirror: a rectangle on the entity's XZ plane, facing its +Y, that reflects the scene as it is ...
Definition planar_reflector.h:18
Turns a rig over to physics, and back.
Definition ragdoll.h:49
Local reflection + irradiance probe.
Definition reflection_probe.h:18
Dynamics state for a physics body: motion, material response and mass.
Definition rigidbody.h:32
ECS component attaching owned, polymorphic Behaviors to an entity.
Definition script_component.h:36
A terrain in the world: its asset, centred on the entity.
Definition terrain.h:15
Root of a screen-space UI layer.
Definition ui_canvas.h:18
One of a list of options, stepped through by two UIButtons: a setting's "< High >" row.
Definition ui_choice.h:21
The 2D rect of a UI node - the screen-space analogue of Transform.
Definition ui_element.h:44
A filled quad drawn over its element's resolved rect.
Definition ui_image.h:16
A value dragged along a UIButton's width: the button is the track.
Definition ui_slider.h:20
Text drawn within its element's rect, on as many lines as it breaks into.
Definition ui_text.h:24
A UIButton that is on or off, flipped by its click.
Definition ui_toggle.h:20