Builder

Struct Builder 

Source
pub struct Builder<Attrib = (), Basis = Model> {
    pub mesh: Mesh<Attrib, Basis>,
}
Expand description

A builder type for creating meshes.

Fields§

§mesh: Mesh<Attrib, Basis>

Implementations§

Source§

impl<A> Builder<A>

Source

pub fn push_face(&mut self, a: usize, b: usize, c: usize)

Appends a face with the given vertex indices.

Invalid indices (referring to vertices not yet added) are permitted, as long as all indices are valid when the build method is called.

Source

pub fn push_faces<Fs>(&mut self, faces: Fs)
where Fs: IntoIterator<Item = [usize; 3]>,

Appends all the faces yielded by the given iterator.

The faces may include invalid vertex indices (referring to vertices not yet added) are permitted, as long as all indices are valid when the build method is called.

Source

pub fn push_vert(&mut self, pos: Point3, attrib: A)

Appends a vertex with the given position and attribute.

Source

pub fn push_verts<Vs>(&mut self, verts: Vs)
where Vs: IntoIterator<Item = (Point3, A)>,

Appends all the vertices yielded by the given iterator.

Source

pub fn build(self) -> Mesh<A>

Returns the finished mesh containing all the added faces and vertices.

§Panics

If any of the vertex indices in facesverts.len().

Source§

impl<A> Builder<A>

Source

pub fn transform(self, tf: &Mat4x4<RealToReal<3, Model, Model>>) -> Self

Applies the given transform to the position of each vertex.

This is an eager operation, that is, only vertices currently added to the builder are transformed.

Source

pub fn warp(self, f: impl FnMut(Vertex3<A>) -> Vertex3<A>) -> Self

Applies an arbitrary mapping to each vertex.

This method can be used for various nonlinear transformations such as twisting or dilation. This is an eager operation, that is, only vertices currently added to the builder are transformed.

Source

pub fn with_vertex_normals(self) -> Builder<Normal3>

Computes a vertex normal for each vertex as an area-weighted average of normals of the faces adjacent to it.

The algorithm is as follows:

  1. Initialize the normal of each vertex to 0
  2. For each face:
    1. Take the cross product of two of the face’s edge vectors
    2. Add the result to the normal of each of the face’s vertices.
  3. Normalize each vertex normal to unit length.

This is an eager operation, that is, only vertices currently added to the builder are transformed. The attribute type of the result is Normal3; the vertex type it accepts is changed accordingly.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Builder<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 Builder<A, S>

Source§

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

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

impl<A> Default for Builder<A>

Source§

fn default() -> Self

Returns an empty builder.

Auto Trait Implementations§

§

impl<Attrib, Basis> Freeze for Builder<Attrib, Basis>

§

impl<Attrib, Basis> RefUnwindSafe for Builder<Attrib, Basis>
where Attrib: RefUnwindSafe, Basis: RefUnwindSafe,

§

impl<Attrib, Basis> Send for Builder<Attrib, Basis>
where Attrib: Send, Basis: Send,

§

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

§

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

§

impl<Attrib, Basis> UnwindSafe for Builder<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.