mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-02 05:15:54 +00:00
Generate 3MF file
This commit is contained in:
parent
47d6296680
commit
b675afdbaa
@ -1,4 +1,47 @@
|
|||||||
|
use std::fs::File;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
println!("Hello, world!");
|
let vertices = [
|
||||||
|
[-0.5, -0.5, -0.5], // 0
|
||||||
|
[0.5, -0.5, -0.5], // 1
|
||||||
|
[-0.5, 0.5, -0.5], // 2
|
||||||
|
[0.5, 0.5, -0.5], // 3
|
||||||
|
[-0.5, -0.5, 0.5], // 4
|
||||||
|
[0.5, -0.5, 0.5], // 5
|
||||||
|
[-0.5, 0.5, 0.5], // 6
|
||||||
|
[0.5, 0.5, 0.5], // 7
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.map(|[x, y, z]| threemf::model::Vertex { x, y, z })
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let triangles = [
|
||||||
|
[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],
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.map(|[v1, v2, v3]| threemf::model::Triangle { v1, v2, v3 })
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let mesh = threemf::Mesh {
|
||||||
|
vertices: threemf::model::Vertices { vertex: vertices },
|
||||||
|
triangles: threemf::model::Triangles {
|
||||||
|
triangle: triangles,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let output = File::create("output.3mf")?;
|
||||||
|
threemf::write(output, mesh)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user