Mesh

Struct Mesh 

Source
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>

Source

pub fn new<F, V>(faces: F, verts: V) -> Self
where F: IntoIterator<Item = Tri<usize>>, V: IntoIterator<Item = Vertex3<A, B>>,

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 facesverts.len().

Source

pub fn faces(&self) -> impl Iterator<Item = Tri<&Vertex3<A, B>>>

Returns an iterator over the faces of self, mapping the vertex indices to references to the corresponding vertices.

Source

pub fn merge(self, _: Self) -> Self

Returns a mesh with the faces and vertices of both self and other.

Source§

impl<A> Mesh<A>

Source

pub fn builder() -> Builder<A>

Returns a new mesh builder.

Source

pub fn into_builder(self) -> Builder<A>

Consumes self and returns a mesh builder with the faces and vertices of self.

Trait Implementations§

Source§

impl<Attrib: Clone, Basis: Clone> Clone for Mesh<Attrib, Basis>

Source§

fn clone(&self) -> Mesh<Attrib, Basis>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug, S: Debug + Default> Debug for Mesh<A, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A, S> Default for Mesh<A, S>

Source§

fn default() -> Self

Returns an empty mesh.

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>
where Attrib: Send, Basis: Send,

§

impl<Attrib, Basis> Sync for Mesh<Attrib, Basis>
where Attrib: Sync, Basis: Sync,

§

impl<Attrib, Basis> Unpin for Mesh<Attrib, Basis>
where Attrib: Unpin, Basis: Unpin,

§

impl<Attrib, Basis> UnwindSafe for Mesh<Attrib, Basis>
where Attrib: UnwindSafe, Basis: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.