Module plexus::generate
[−]
[src]
Mesh generation from primitives like cubes and spheres.
This module provides unit primitives that can be used to form complex iterator expressions to generate meshes via a stream of topology and geometry. This data can be collected into simple buffers for rendering or a graph (half-edge) for further manipulation.
Iterator expressions begin with a unit primitive and manipulate its components like vertices, lines, and polygons. Generation and decomposition operations are exposed via traits.
Examples
Generating position and index buffers for a scaled sphere:
use plexus::generate::{IndexedPolygons, SpatialVertices, Triangulate, Vertices}; use plexus::generate::sphere::UVSphere; let sphere = UVSphere::<f32>::with_unit_radius(16, 16); let positions: Vec<_> = sphere .spatial_vertices() // Generate the unique set of positional vertices. .map(|(x, y, z)| (x * 10.0, y * 10.0, z * 10.0)) // Scale the positions by 10. .collect(); let indeces: Vec<_> = sphere .indexed_polygons() // Generate polygons indexing the unique set of vertices. .triangulate() // Decompose the polygons into triangles. .vertices() // Decompose the triangles into vertices (indeces). .collect();
Modules
cube | |
sphere |
Structs
HashIndexer | |
Line | |
Quad | |
Triangle |
Enums
Polygon |