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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
extern crate xml;
extern crate vecmath;
#[macro_use]
extern crate log;
pub use obj::*;
pub use vecmath::Matrix4;
pub mod document;
mod utils;
mod obj;
#[derive(Debug, Clone)]
pub struct Skeleton {
pub joints: Vec<Joint>,
pub bind_poses: Vec<Matrix4<f32>>,
}
#[derive(Debug, Clone)]
pub struct Joint {
pub name: String,
pub parent_index: JointIndex,
pub inverse_bind_pose: Matrix4<f32>,
}
impl Joint {
pub fn is_root(&self) -> bool {
self.parent_index == ROOT_JOINT_PARENT_INDEX
}
}
#[derive(Debug)]
pub struct Animation {
pub target: String,
pub sample_times: Vec<f32>,
pub sample_poses: Vec<Matrix4<f32>>,
}
#[derive(Debug)]
pub struct BindDataSet {
pub bind_data: Vec<BindData>,
}
#[derive(Debug)]
pub struct BindData {
pub object_name: String,
pub skeleton_name: String,
pub joint_names: Vec<String>,
pub vertex_weights: Vec<VertexWeight>,
pub weights: Vec<f32>,
pub inverse_bind_poses: Vec<Matrix4<f32>>,
}
#[derive(Debug, Copy, Clone)]
pub struct VertexWeight {
pub vertex: VertexIndex,
pub joint: JointIndex,
pub weight: WeightIndex,
}
pub type WeightIndex = usize;
pub type JointIndex = u8;
pub const ROOT_JOINT_PARENT_INDEX: JointIndex = 255u8;