Crate polyhedron_ops
source ·Expand description
Conway-Hart Polyhedron Operations
This crate implements the Conway Polyhedron Operators and their extensions by George W. Hart and others.
The internal representation uses n-gon mesh buffers. These need preprocessing before they can be sent to a GPU but are almost fine to send to an offline renderer, as-is.
See the playground
example for code on how to do either.
Example
use polyhedron_ops::Polyhedron;
use std::path::Path;
// Conway notation: gapcD
let polyhedron = Polyhedron::dodecahedron()
.chamfer(None, true)
.propellor(None, true)
.ambo(None, true)
.gyro(None, None, true)
.finalize();
// Export as ./polyhedron-gapcD.obj
polyhedron.write_to_obj(&Path::new("."), false);
The above code starts from a dodecahedron and iteratively applies four operators.
The resulting shape is shown below.
Cargo Features
[dependencies]
polyhedron-ops = { version = "0.3", features = [ "bevy", "nsi", "obj" ] }
-
bevy
– A polyhedro can be converted into abevy
Mesh
. See thebevy
example.ignore Mesh::from(polyhedron)
-
nsi
– Add supports for sending data to renderers implementing the ɴsɪ API. The function is calledto_nsi()
. -
obj
– Add support for output to Wavefront OBJ via thewrite_to_obj()
function.
Modules
Re-exports commonly used types and traits.