Plexus is a Rust library for generating and manipulating 3D meshes.
Generation and Iterator Expressions
Meshes can be generated from primitives like cubes and spheres using iterator
expressions. Primitives emit topological structures like Triangle
s or
Quad
s, which contain arbitrary geometric data in their vertices. These can be
transformed and decomposed into other topologies and geometric data via
triangulation, tesselation, and conversion into rendering pipeline data.
use ConjointBuffer;
use ;
use *; // Common generator traits.
// Example module in the local crate that provides rendering.
use ;
// Construct a buffer of index and vertex data from a sphere primitive.
// `HashConjugate` is used to convert vertex geometry into a conjugate type
// that supports `Hash` via the `into_hash` function. That type is convertible
// to `Vertex` via the `From` trait in this example.
let buffer = with_unit_radius
.polygons_with_position
.map_vertices
.map_vertices
.;
draw;
Half-Edge Graph Meshes
Generators are flexible and easy to use, but only represent vertex geometry and
are difficult to query and manipulate once complete. A Mesh
, represented as a
half-edge graph,
supports arbitrary geometry for vertices, edges, and faces. The graph can also
be queried and manipulated in ways that generators and iterator expressions
cannot.
use Point3;
use r32;
use ;
use *;
use ;
// Construct a mesh from a sphere primitive. Note that the `(r32, r32, r32)`
// geometry is convertible to `Point3<f32>` via the `FromGeometry` trait in
// this example.
let mesh: = with_unit_radius
.polygons_with_position
.map_vertices
.
.into_geometry;
// Extrude a face in the mesh.
let face = mesh.face_mut.unwrap;
let face = face.extrude.unwrap;