1use crate::internal::math::identity4;
2use crate::resource::ids::{MaterialId, MeshId};
3
4#[derive(Debug, Clone, Copy)]
5pub struct CameraDescriptor {
6 pub view: [[f32; 4]; 4],
7 pub projection: [[f32; 4]; 4],
8}
9
10impl Default for CameraDescriptor {
11 fn default() -> Self {
12 Self {
13 view: identity4(),
14 projection: identity4(),
15 }
16 }
17}
18
19#[derive(Debug, Clone, Copy)]
20pub struct MeshInstanceDescriptor {
21 pub mesh: MeshId,
22 pub material: MaterialId,
23 pub transform: [[f32; 4]; 4],
24 pub instance_count: u32,
25}
26
27impl MeshInstanceDescriptor {
28 pub fn new(mesh: MeshId, material: MaterialId) -> Self {
29 Self {
30 mesh,
31 material,
32 transform: identity4(),
33 instance_count: 1,
34 }
35 }
36
37 pub fn with_transform(mut self, transform: [[f32; 4]; 4]) -> Self {
38 self.transform = transform;
39 self
40 }
41
42 pub fn with_instance_count(mut self, instance_count: u32) -> Self {
43 self.instance_count = instance_count.max(1);
44 self
45 }
46}
47
48#[derive(Debug, Clone)]
49pub struct SceneDescriptor {
50 pub camera: CameraDescriptor,
51 pub instances: Vec<MeshInstanceDescriptor>,
52}
53
54impl SceneDescriptor {
55 pub fn new(instances: Vec<MeshInstanceDescriptor>) -> Self {
56 Self {
57 camera: CameraDescriptor::default(),
58 instances,
59 }
60 }
61
62 pub fn with_camera(mut self, camera: CameraDescriptor) -> Self {
63 self.camera = camera;
64 self
65 }
66}