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
use cgmath::{Matrix3, Vector3};
#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Orientation {
pub forward: Vector3<f32>,
pub right: Vector3<f32>,
pub up: Vector3<f32>,
}
impl From<Matrix3<f32>> for Orientation {
fn from(mat: Matrix3<f32>) -> Self {
Orientation {
forward: -mat.z,
right: mat.x,
up: mat.y,
}
}
}
impl Default for Orientation {
fn default() -> Self {
Self {
forward: -Vector3::unit_z(),
right: Vector3::unit_x(),
up: Vector3::unit_y(),
}
}
}