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