[][src]Module plexus::buffer

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

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

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.

The MeshBuffer3 and MeshBufferN type definitions avoid verbose type parameters and provide the most common index buffer configurations.

Examples

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();

Converting a MeshGraph to a flat MeshBuffer:

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();

Structs

MeshBuffer

Linear representation of a mesh.

Enums

BufferError

Traits

IntoFlatIndex
IntoStructuredIndex

Type Definitions

MeshBuffer3

Alias for a flat and triangular MeshBuffer. Prefer this alias.

MeshBuffer4

Alias for a flat and quadrilateral MeshBuffer.

MeshBufferN

Alias for a structured and polygonal MeshBuffer.