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
use crate;
/// A way to store rendered objects without having to re-process them
/*
impl Mesh {
/// Create a new, empty mesh
///
/// This allocates, so hold on to meshes rather than creating and destroying them
pub fn new() -> Mesh {
Mesh {
vertices: Vec::new(),
triangles: Vec::new()
}
}
/// Clear the mesh, removing anything that has been drawn to it
pub fn clear(&mut self) {
self.vertices.clear();
self.triangles.clear();
}
/// Add vertices from an iterator, some transforms, and a background
pub fn add_positioned_vertices(&mut self, vertices: impl Iterator<Item = Vector>,
trans: Transform, tex_trans: Option<Transform>, bkg: Background) -> u32 {
let offset = self.vertices.len();
self.vertices.extend(vertices
.map(|v| Vertex::new(trans * v, tex_trans.map(|trans| trans * v), bkg)));
offset as u32
}
/// Add all the data from the other mesh into this mesh
pub fn extend(&mut self, other: &Mesh) {
self.vertices.extend(other.vertices.iter().cloned());
self.triangles.extend(other.triangles.iter().cloned());
}
}*/