[][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.


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 flat MeshBuffer:

use decorum::R64;
use nalgebra::Point3;
use plexus::buffer::MeshBuffer4;
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: MeshBuffer4<usize, E3> = graph.to_mesh_by_vertex().unwrap();



Linear representation of a mesh.





Type Definitions


Alias for a triangular MeshBuffer.


Alias for a quadrilateral MeshBuffer.


Alias for a MeshBuffer that supports arbitrary polygons.