pub struct Mesh<Attrib, Basis = Model> {
pub faces: Vec<Tri<usize>>,
pub verts: Vec<Vertex3<Attrib, Basis>>,
}Expand description
A triangle mesh.
An object made of flat polygonal faces that typically form a contiguous surface without holes or boundaries, so that every face shares each of its edges with another face. For instance, a cube can be represented by a mesh with 8 vertices and 12 faces. By using many faces, complex curved shapes can be approximated.
Fields§
§faces: Vec<Tri<usize>>The faces of the mesh, with each face a triplet of indices
to the verts vector. Several faces can share a vertex.
verts: Vec<Vertex3<Attrib, Basis>>The vertices of the mesh.
Implementations§
Source§impl<A, B> Mesh<A, B>
impl<A, B> Mesh<A, B>
Sourcepub fn new<F, V>(faces: F, verts: V) -> Self
pub fn new<F, V>(faces: F, verts: V) -> Self
Creates a new triangle mesh with the given faces and vertices.
Each face in faces is a triplet of indices, referring to
the vertices in verts that define that face.
§Examples
use retrofire_core::geom::{Mesh, tri, vertex};
use retrofire_core::math::pt3;
let verts = [
pt3(0.0, 0.0, 0.0),
pt3(1.0, 0.0, 0.0),
pt3(0.0, 1.0, 0.0),
pt3(0.0, 0.0, 1.0)
]
.map(|v| vertex(v, ()));
let faces = [
// Indices point to the verts array
tri(0, 1, 2),
tri(0, 1, 3),
tri(0, 2, 3),
tri(1, 2, 3)
];
// Create a mesh with a tetrahedral shape
let tetra: Mesh<()> = Mesh::new(faces, verts);§Panics
If any of the vertex indices in faces ≥ verts.len().
Trait Implementations§
Auto Trait Implementations§
impl<Attrib, Basis> Freeze for Mesh<Attrib, Basis>
impl<Attrib, Basis> RefUnwindSafe for Mesh<Attrib, Basis>where
Attrib: RefUnwindSafe,
Basis: RefUnwindSafe,
impl<Attrib, Basis> Send for Mesh<Attrib, Basis>
impl<Attrib, Basis> Sync for Mesh<Attrib, Basis>
impl<Attrib, Basis> Unpin for Mesh<Attrib, Basis>
impl<Attrib, Basis> UnwindSafe for Mesh<Attrib, Basis>where
Attrib: UnwindSafe,
Basis: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more