1use math_utils as math;
4use math_utils::geometry;
5
6use crate::vertex;
7
8pub mod gltf;
9
10pub fn aabb_to_vertex (aabb : geometry::Aabb3 <f32>)
11 -> vertex::Vert3dOrientationScaleColor
12{
13 let position = aabb.center().0.into_array();
14 let orientation = math::Matrix3::identity().into_col_arrays();
15 let scale = (0.5 * aabb.dimensions()).into_array();
16 let color = [1.0, 1.0, 1.0, 1.0];
17 vertex::Vert3dOrientationScaleColor { position, orientation, scale, color }
18}
19
20pub fn capsule_to_vertex (capsule : geometry::Capsule3 <f32>)
21 -> vertex::Vert3dOrientationScaleColor
22{
23 let position = capsule.center.0.into_array();
24 let orientation = math::Matrix3::identity().into_col_arrays();
25 let scale = [
26 *capsule.radius,
27 *capsule.radius,
28 *capsule.radius + *capsule.half_height
29 ];
30 let color = [1.0, 1.0, 1.0, 1.0];
31 vertex::Vert3dOrientationScaleColor { position, orientation, scale, color }
32}
33
34pub fn cylinder_to_vertex (cylinder : geometry::Cylinder3 <f32>)
35 -> vertex::Vert3dOrientationScaleColor
36{
37 let position = cylinder.center.0.into_array();
38 let orientation = math::Matrix3::identity().into_col_arrays();
39 let scale = [
40 *cylinder.radius,
41 *cylinder.radius,
42 *cylinder.radius + *cylinder.half_height
43 ];
44 let color = [1.0, 1.0, 1.0, 1.0];
45 vertex::Vert3dOrientationScaleColor { position, orientation, scale, color }
46}
47
48pub fn sphere_to_vertex (sphere : geometry::Sphere3 <f32>)
49 -> vertex::Vert3dOrientationScaleColor
50{
51 let position = sphere.center.0.into_array();
52 let orientation = math::Matrix3::identity().into_col_arrays();
53 let scale = [*sphere.radius, *sphere.radius, *sphere.radius];
54 let color = [1.0, 1.0, 1.0, 1.0];
55 vertex::Vert3dOrientationScaleColor { position, orientation, scale, color }
56}