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>
impl<A> Builder<A>
Sourcepub fn push_face(&mut self, a: usize, b: usize, c: usize)
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.
Sourcepub fn push_faces<Fs>(&mut self, faces: Fs)
pub fn push_faces<Fs>(&mut self, faces: Fs)
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.
Sourcepub fn push_vert(&mut self, pos: Point3, attrib: A)
pub fn push_vert(&mut self, pos: Point3, attrib: A)
Appends a vertex with the given position and attribute.
Sourcepub fn push_verts<Vs>(&mut self, verts: Vs)where
Vs: IntoIterator<Item = (Point3, A)>,
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§impl<A> Builder<A>
impl<A> Builder<A>
Sourcepub fn transform(self, tf: &Mat4x4<RealToReal<3, Model, Model>>) -> Self
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.
Sourcepub fn warp(self, f: impl FnMut(Vertex3<A>) -> Vertex3<A>) -> Self
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.
Sourcepub fn with_vertex_normals(self) -> Builder<Normal3>
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:
- Initialize the normal of each vertex to 0
- For each face:
- Take the cross product of two of the face’s edge vectors
- Add the result to the normal of each of the face’s vertices.
- 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.