mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 10:28:27 +00:00
Define triangles by referring to meshes
This commit is contained in:
parent
7051d681ca
commit
aff4f5898b
@ -58,6 +58,10 @@ impl<'r, T> OperationResult<'r, T> {
|
||||
results: self.results.push_right(vertex),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn results(self) -> T {
|
||||
self.results
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
|
@ -3,33 +3,32 @@ use crate::geometry::Operations;
|
||||
pub fn model() -> anyhow::Result<Operations> {
|
||||
let mut mesh = Operations::default();
|
||||
|
||||
mesh.vertex([-0.5, -0.5, -0.5]) // 0
|
||||
.vertex([0.5, -0.5, -0.5]) // 1
|
||||
.vertex([-0.5, 0.5, -0.5]) // 2
|
||||
.vertex([0.5, 0.5, -0.5]) // 3
|
||||
.vertex([-0.5, -0.5, 0.5]) // 4
|
||||
.vertex([0.5, -0.5, 0.5]) // 5
|
||||
.vertex([-0.5, 0.5, 0.5]) // 6
|
||||
.vertex([0.5, 0.5, 0.5]); // 7
|
||||
let (a, b, c, d, e, f, g, h) = mesh
|
||||
.vertex([-0.5, -0.5, -0.5])
|
||||
.vertex([0.5, -0.5, -0.5])
|
||||
.vertex([-0.5, 0.5, -0.5])
|
||||
.vertex([0.5, 0.5, -0.5])
|
||||
.vertex([-0.5, -0.5, 0.5])
|
||||
.vertex([0.5, -0.5, 0.5])
|
||||
.vertex([-0.5, 0.5, 0.5])
|
||||
.vertex([0.5, 0.5, 0.5])
|
||||
.results();
|
||||
|
||||
[
|
||||
[0, 4, 6], // left
|
||||
[0, 6, 2],
|
||||
[1, 3, 7], // right
|
||||
[1, 7, 5],
|
||||
[0, 1, 5], // front
|
||||
[0, 5, 4],
|
||||
[2, 7, 3], // back
|
||||
[2, 6, 7],
|
||||
[0, 2, 1], // bottom
|
||||
[1, 2, 3],
|
||||
[4, 5, 7], // top
|
||||
[4, 7, 6],
|
||||
[a, e, g], // left
|
||||
[a, g, c],
|
||||
[b, d, h], // right
|
||||
[b, h, f],
|
||||
[a, b, f], // front
|
||||
[a, f, e],
|
||||
[c, h, d], // back
|
||||
[c, g, h],
|
||||
[a, c, b], // bottom
|
||||
[b, c, d],
|
||||
[e, f, h], // top
|
||||
[e, h, g],
|
||||
]
|
||||
.map(|triangle| {
|
||||
let triangle = triangle.map(|index| mesh.vertices[index]);
|
||||
mesh.triangle(triangle)
|
||||
});
|
||||
.map(|triangle| mesh.triangle(triangle));
|
||||
|
||||
Ok(mesh)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user