logo
Expand description

Indexing and aggregation.

This module provides types and traits that describe index buffers and indexers that disambiguate vertex data to construct minimal index and vertex buffers. Plexus refers to independent vertex and index buffers as raw buffers. See the buffer module and MeshBuffer type for tools for working with these buffers.

Index Buffers

Index buffers describe the topology of a polygonal mesh as ordered groups of indices into a vertex buffer. Each group of indices represents a polygon. The vertex buffer contains data that describes each vertex, such as positions or surface normals. Plexus supports structured and flat index buffers via the Grouping and IndexBuffer traits. These traits are implemented for Vec.

Flat index buffers contain unstructured indices with an implicit grouping, such as Vec<usize>. Arity of these buffers is constant and is described by the Flat meta-grouping. Rendering pipelines typically expect this format.

Structured index buffers contain elements that explicitly group indices, such as Vec<Trigon<usize>>. These buffers can be formed from polygonal types in the primitive module.

Indexers

Indexers construct index and vertex buffers from iterators of polygonal types in the primitive module, such as NGon and UnboundedPolygon. The IndexVertices trait provides functions for collecting an iterator of $n$-gons into these buffers.

Mesh data structures also implement the FromIndexer and FromIterator traits so that iterators of $n$-gons can be collected into these types (using a HashIndexer by default). A specific Indexer can be configured using the CollectWithIndexer trait.

Examples

Indexing data for a cube to create raw buffers and a MeshBuffer:

use decorum::R64;
use nalgebra::Point3;
use plexus::buffer::MeshBuffer;
use plexus::index::{Flat3, HashIndexer};
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;

type E3 = Point3<R64>;

let (indices, positions) = Cube::new()
    .polygons::<Position<E3>>()
    .triangulate()
    .index_vertices::<Flat3, _>(HashIndexer::default());
let buffer = MeshBuffer::<Flat3, E3>::from_raw_buffers(indices, positions).unwrap();

Structs

Flat index buffer meta-grouping.

Hashing vertex indexer.

LRU caching vertex indexer.

Traits

Functions for collecting an iterator of $n$-gons into a mesh data structure.

Functions for collecting an iterator of $n$-gons into raw index and vertex buffers.

Index buffer.

Functions for collecting an iterator of $n$-gons into raw index and vertex buffers.

Vertex indexer.

Type Definitions

Alias for a flat and triangular index buffer.

Alias for a flat and quadrilateral index buffer.