assimp/math/
color3.rs
1#[cfg(feature = "cgmath")]
2use cgmath::Vector3;
3use ffi::AiColor3D;
4
5define_type! {
6 #[derive(Clone, Copy, Debug, PartialEq)]
8 struct Color3D(AiColor3D)
9}
10
11impl Color3D {
12 pub fn new(r: f32, g: f32, b: f32) -> Color3D {
13 Color3D(AiColor3D { r: r, g: g, b: b })
14 }
15}
16
17impl From<[f32; 3]> for Color3D {
18 fn from(v: [f32; 3]) -> Color3D {
19 Color3D::new(v[0], v[1], v[2])
20 }
21}
22
23impl From<Color3D> for [f32; 3] {
24 fn from(c: Color3D) -> [f32; 3] {
25 [c.r, c.g, c.b]
26 }
27}
28
29#[cfg(feature = "cgmath")]
30impl From<Vector3<f32>> for Color3D {
31 fn from(v: Vector3<f32>) -> Color3D {
32 Color3D::new(v[0], v[1], v[2])
33 }
34}
35
36#[cfg(feature = "cgmath")]
37impl From<Color3D> for Vector3<f32> {
38 fn from(c: Color3D) -> Vector3<f32> {
39 Vector3::new(c.r, c.g, c.b)
40 }
41}