Expand description

Linear representations of polygonal meshes.

This module provides types and traits that describe polygonal meshes as buffers of vertex data and buffers of indices into that vertex data. These buffers are called the vertex buffer and index buffer, respectively, and are typically used for indexed drawing. The MeshBuffer type unifies vertex and index buffers and maintains their consistency.

Note that only composite vertex buffers are supported, in which each element of a vertex buffer completely describes all attributes of a vertex. Plexus does not support component buffers, in which each attribute of a vertex is stored in a dedicated buffer.

Plexus refers to independent vertex and index buffers as raw buffers. For example, a Vec of index data is a raw buffer and can be modified without regard to consistency with any particular vertex buffer. The FromRawBuffers trait provides a way to construct mesh data structures from such raw buffers.

Index buffers may contain either flat or structured data. See the index module for more about these buffers and how they are defined.


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: MeshBuffer3<u32, Point3<f32>> = UvSphere::new(16, 16)
let indices = buffer.as_index_slice();
let positions = buffer.as_vertex_slice();

Converting a MeshGraph to a structured MeshBuffer:

use decorum::R64;
use nalgebra::Point3;
use plexus::buffer::MeshBufferN;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;

type E3 = Point3<R64>;

let graph: MeshGraph<E3> = Cube::new().polygons::<Position<E3>>().collect();
let buffer: MeshBufferN<usize, E3> = graph.to_mesh_by_vertex().unwrap();


Polygonal mesh composed of vertex and index buffers.


Errors concerning raw buffers and MeshBuffers.


Conversion from raw buffers.

Conversion from raw buffers that do not encode their arity.

Type Definitions

Quadrilateral MeshBuffer.

MeshBuffer that supports polygons with arbitrary arity.