Linear representation of meshes.
This module provides a
MeshBuffer that represents a mesh as a linear
collection of vertex geometry and an ordered collection of indices into
that vertex geometry. These two buffers are called the vertex buffer and
index buffer, respectively.
MeshBuffer combines these buffers and
exposes them as slices. This layout is well-suited for graphics pipelines.
Vertex buffers describe the geometry of a
MeshBuffer. Only vertex
geometry is supported; there is no way to associate geometry with an edge
nor face, for example.
MeshBuffers use composite vertex buffers. Each element of the vertex
buffer completely describes the geometry of that vertex. For example, if
each vertex is described by a position and color attribute, then each
element in the vertex buffer contains both attributes within a single
structure. Component buffers, which store attributes in separate buffers,
are not supported.
Index buffers describe the topology of a
MeshBuffer. Both structured
and flat index buffers are supported. See the
index module for more
information about index buffer formats.
MeshBufferN type definitions avoid verbose type
parameters and provide the most common index buffer configurations.
Generating a flat
MeshBuffer from a $uv$-sphere:
use decorum::N32; use nalgebra::Point3; use plexus::buffer::MeshBuffer3; use plexus::prelude::*; use plexus::primitive::generate::Position; use plexus::primitive::sphere::UvSphere; let buffer = UvSphere::new(16, 16) .polygons::<Position<Point3<N32>>>() .triangulate() .collect::<MeshBuffer3<u32, Point3<f32>>>(); let indices = buffer.as_index_slice(); let positions = buffer.as_vertex_slice();
MeshGraph to a flat
use decorum::N64; use nalgebra::Point3; use plexus::graph::MeshGraph; use plexus::prelude::*; use plexus::primitive::cube::Cube; use plexus::primitive::generate::Position; use plexus::U4; let graph = Cube::new() .polygons::<Position<Point3<N64>>>() .collect::<MeshGraph<Point3<N64>>>(); let buffer = graph .to_mesh_buffer_by_vertex::<U4, usize, Point3<N64>>() .unwrap();
Linear representation of a mesh.
Alias for a flat and triangular
Alias for a flat and quadrilateral
Alias for a structured and polygonal