parry3d/transformation/to_trimesh/
heightfield_to_trimesh.rs1use crate::math::Real;
2use crate::shape::HeightField;
3use alloc::vec::Vec;
4use na::Point3;
5
6impl HeightField {
7 pub fn to_trimesh(&self) -> (Vec<Point3<Real>>, Vec<[u32; 3]>) {
9 let mut vertices = Vec::new();
10 let mut indices = Vec::new();
11
12 for (i, tri) in self.triangles().enumerate() {
13 vertices.push(tri.a);
14 vertices.push(tri.b);
15 vertices.push(tri.c);
16
17 let i = i as u32;
18 indices.push([i * 3, i * 3 + 1, i * 3 + 2])
19 }
20
21 (vertices, indices)
22 }
23}