1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use cgmath::{Euler, Matrix4, Rad, SquareMatrix, Vector3, Zero};
#[derive(Debug)]
pub struct ModelData {
pub position: Vector3<f32>,
pub rotation: Euler<Rad<f32>>,
pub scale: f32,
pub groups: Vec<ModelDataGroup>,
}
impl Default for ModelData {
fn default() -> ModelData {
Self {
position: Vector3::zero(),
rotation: Euler::new(Rad(0.0), Rad(0.0), Rad(0.0)),
scale: 1.0,
groups: Vec::new(),
}
}
}
impl ModelData {
pub(crate) fn matrix(&self) -> Matrix4<f32> {
Matrix4::from_translation(self.position)
* Matrix4::from(self.rotation)
* Matrix4::from_scale(self.scale)
}
}
#[derive(Debug, Clone)]
pub struct ModelDataGroup {
pub matrix: Matrix4<f32>,
}
impl Default for ModelDataGroup {
fn default() -> Self {
Self {
matrix: Matrix4::identity(),
}
}
}