autd3_geometry_viewer/
settings.rs1use crate::{Vector3, SCALE, ZPARITY};
15
16#[derive(Clone)]
17pub struct Settings {
18 pub ambient: f32,
19 pub specular: f32,
20 pub light_pos_x: f32,
21 pub light_pos_y: f32,
22 pub light_pos_z: f32,
23 pub light_power: f32,
24 pub camera_pos_x: f32,
25 pub camera_pos_y: f32,
26 pub camera_pos_z: f32,
27 pub camera_rot_x: f32,
28 pub camera_rot_y: f32,
29 pub camera_rot_z: f32,
30 pub camera_fov: f32,
31 pub camera_near_clip: f32,
32 pub camera_far_clip: f32,
33 pub camera_move_speed: f32,
34 pub background: [f32; 4],
35 pub shows: Vec<bool>,
36}
37
38impl Settings {
39 pub fn new(num_dev: usize) -> Self {
40 let camera_pos_x = 86.6252 * SCALE;
41 let camera_pos_y = -250. * SCALE;
42 let camera_pos_z = 200. * SCALE * ZPARITY;
43 Self {
44 ambient: 60.,
45 specular: 80.,
46 light_pos_x: camera_pos_x,
47 light_pos_y: camera_pos_y,
48 light_pos_z: camera_pos_z,
49 light_power: 5.,
50 camera_pos_x,
51 camera_pos_y,
52 camera_pos_z,
53 camera_rot_x: 70. * ZPARITY,
54 camera_rot_y: 0.,
55 camera_rot_z: 0.,
56 camera_fov: 45.,
57 camera_near_clip: 0.1 * SCALE,
58 camera_far_clip: 1000. * SCALE,
59 camera_move_speed: 10. * SCALE,
60 background: [0.3, 0.3, 0.3, 1.],
61 shows: vec![true; num_dev],
62 }
63 }
64
65 pub(crate) const fn camera_pos(&self) -> Vector3 {
66 Vector3::new(self.camera_pos_x, self.camera_pos_y, self.camera_pos_z)
67 }
68
69 pub(crate) const fn camera_rot(&self) -> Vector3 {
70 Vector3::new(self.camera_rot_x, self.camera_rot_y, self.camera_rot_z)
71 }
72}
73
74impl Default for Settings {
75 fn default() -> Self {
76 Self::new(0)
77 }
78}