euv_core/game/engine3d/world/struct.rs
1use super::*;
2
3/// 3D world-space transform (translation, yaw/pitch/roll Euler rotation, and non-uniform scale).
4#[derive(Clone, Copy, Data, Debug, PartialEq)]
5pub struct Transform3D {
6 /// World-space translation `(x, y, z)`.
7 #[get(type(copy))]
8 pub(crate) position: Vec3,
9 /// Horizontal Y-axis yaw rotation in radians.
10 #[get(type(copy))]
11 pub(crate) yaw_rad: f32,
12 /// Vertical X-axis pitch rotation in radians.
13 #[get(type(copy))]
14 pub(crate) pitch_rad: f32,
15 /// Longitudinal Z-axis roll rotation in radians.
16 #[get(type(copy))]
17 pub(crate) roll_rad: f32,
18 /// Scale multiplier along `(x, y, z)`.
19 #[get(type(copy))]
20 pub(crate) scale: Vec3,
21}
22
23/// Fluent descriptor for spawning a `SceneObject3D` into `World3D`.
24#[derive(Clone, Data, Debug, PartialEq)]
25pub struct SpawnObjectDesc {
26 /// Human-readable object label.
27 pub(crate) name: String,
28 /// Registered mesh identifier from `World3D::register_mesh`.
29 #[get(type(copy))]
30 pub(crate) mesh_id: usize,
31 /// World-space TRS transform.
32 #[get(type(copy))]
33 pub(crate) transform: Transform3D,
34 /// Surface PBR material.
35 #[get(type(copy))]
36 pub(crate) material: PbrMaterial,
37 /// Whether this object casts ray-traced shadows and appears in BVH reflections.
38 #[get(type(copy))]
39 pub(crate) ray_trace_caster: bool,
40 /// Continuous spin speed in radians/sec.
41 #[get(type(copy))]
42 pub(crate) spin_speed: f32,
43}
44
45/// Fluent descriptor for importing a 3D `.obj` or `.gltf` model into `World3D`.
46#[derive(Clone, Data, Debug, PartialEq)]
47pub struct ImportModelDesc {
48 /// Source model interchange format.
49 #[get(type(copy))]
50 pub(crate) format: ModelFormat,
51 /// Raw `.obj` or `.gltf` text content.
52 pub(crate) source: String,
53 /// World-space placement transform.
54 #[get(type(copy))]
55 pub(crate) transform: Transform3D,
56 /// Fallback PBR material when source omits material definitions.
57 #[get(type(copy))]
58 pub(crate) fallback_material: PbrMaterial,
59 /// Optional continuous Y-spin speed in radians/sec.
60 #[get(type(copy))]
61 pub(crate) spin_speed: f32,
62}
63
64/// Instanced 3D scene object placed inside an open-world chunk.
65#[derive(Clone, Data, Debug, PartialEq)]
66pub struct SceneObject3D {
67 /// Human-readable object label.
68 pub(crate) name: String,
69 /// Index into `World3D::mesh_library` enabling GPU instancing batching.
70 #[get(type(copy))]
71 pub(crate) mesh_id: usize,
72 /// World-space TRS transform.
73 #[get(type(copy))]
74 pub(crate) transform: Transform3D,
75 /// Material override (or default mesh material).
76 #[get(type(copy))]
77 pub(crate) material: PbrMaterial,
78 /// Cached world-space AABB for O(1) frustum culling and chunk streaming.
79 #[get(type(copy))]
80 pub(crate) world_bounds: Aabb3D,
81 /// Spatial open-world chunk coordinate `(chunk_x, chunk_z)`.
82 #[get(type(copy))]
83 pub(crate) chunk_coord: (i32, i32),
84 /// Whether this object casts ray-traced shadows and appears in BVH reflections.
85 #[get(type(copy))]
86 pub(crate) ray_trace_caster: bool,
87 /// Continuous spin speed in radians/sec for animated hero models or props.
88 #[get(type(copy))]
89 pub(crate) spin_speed: f32,
90}
91
92/// Primary sun/moon directional light and atmospheric sky parameters.
93#[derive(Clone, Copy, Data, Debug, PartialEq)]
94pub struct DirectionalLight3D {
95 /// Normalized direction pointing toward the sun.
96 #[get(type(copy))]
97 pub(crate) direction: Vec3,
98 /// Linear HDR sun radiance color.
99 #[get(type(copy))]
100 pub(crate) color: Vec3,
101 /// Ambient sky zenith color.
102 #[get(type(copy))]
103 pub(crate) sky_zenith: Vec3,
104 /// Ambient sky horizon and volumetric fog color.
105 #[get(type(copy))]
106 pub(crate) sky_horizon: Vec3,
107 /// Time of day in `[0.0, 24.0]` hours.
108 #[get(type(copy))]
109 pub(crate) time_of_day: f32,
110}
111
112/// Complete open-world 3D scene graph with mesh instancing library, chunk streaming, and BVH acceleration.
113#[derive(Clone, Data, Debug)]
114pub struct World3D {
115 /// Shared LOD mesh asset library referenced by `SceneObject3D::mesh_id`.
116 pub(crate) mesh_library: Vec<MeshLodChain>,
117 /// All world objects partitioned into open-world chunks.
118 pub(crate) objects: Vec<SceneObject3D>,
119 /// Active 3D perspective camera.
120 #[get(type(copy))]
121 pub(crate) camera: Camera3D,
122 /// Active directional sun/sky lighting.
123 #[get(type(copy))]
124 pub(crate) sun: DirectionalLight3D,
125 /// Flat BVH built over world-space triangles for ray-traced shadows, reflections, and GI.
126 pub(crate) bvh: Bvh3D,
127 /// Dirty flag triggering automatic BVH rebuild on geometry or transform changes.
128 #[get(type(copy))]
129 pub(crate) bvh_dirty: bool,
130 /// Open-world chunk size in meters (`64.0m` per city block).
131 #[get(type(copy))]
132 pub(crate) chunk_size: f32,
133 /// Index of the drivable player vehicle object if spawned.
134 #[get(skip)]
135 pub(crate) player_vehicle_index: Option<usize>,
136 /// Total imported external 3D models (`.obj` / `.gltf`).
137 #[get(type(copy))]
138 pub(crate) imported_model_count: usize,
139 /// Active 3D camera mode index (`0=Chase`, `1=Hood`, `2=Orbit`, `3=Aerial`, `4=FreeFly`, `5=CinematicDolly`).
140 #[get(type(copy))]
141 pub(crate) camera_mode: u8,
142 /// Continuous orbit angle in radians used for `Orbit` and `CinematicDolly` modes.
143 #[get(type(copy))]
144 pub(crate) camera_orbit_rad: f32,
145}