Struct MeshBuilder

Source
pub struct MeshBuilder { /* private fields */ }
Expand description

Easy to use builder for a Mesh that deals with common operations for you.

Implementations§

Source§

impl MeshBuilder

Source

pub fn new(vertex_positions: Vec<Vec3>, handedness: Handedness) -> Self

Create a new MeshBuilder with a given set of positions.

All vertices must have positions.

Source

pub fn with_vertex_normals(self, normals: Vec<Vec3>) -> Self

Add vertex normals to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_vertex_tangents(self, tangents: Vec<Vec3>) -> Self

Add vertex tangents to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_vertex_uv0(self, uvs: Vec<Vec2>) -> Self

Add the first set of texture coordinates to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_vertex_uv1(self, uvs: Vec<Vec2>) -> Self

Add the second set of texture coordinates to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_vertex_colors(self, colors: Vec<[u8; 4]>) -> Self

Add vertex colors to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_vertex_joint_indices(self, joint_indices: Vec<[u16; 4]>) -> Self

Add vertex joint indices to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_vertex_joint_weights(self, joint_weights: Vec<Vec4>) -> Self

Add vertex joint weights to the given mesh.

§Panic

Will panic if the length is different from the position buffer length.

Source

pub fn with_indices(self, indices: Vec<u32>) -> Self

Add indices to the given mesh.

§Panic

Will panic if the length is zero.

Source

pub fn with_flip_winding_order(self) -> Self

Flip the winding order

See Mesh::flip_winding_order for more information.

Source

pub fn with_double_sided(self) -> Self

Mark this mesh as needing to be double sided. This will duplicate all faces with the opposite winding order. This acts as if backface culling was disabled.

Source

pub unsafe fn without_validation(self) -> Self

Doesn’t run validation on the mesh.

§Safety

This asserts the following are true about the mesh:

  • All vertex arrays are the same length.
  • There is a non-zero count of vertices.
  • The count of vertices is less than MAX_VERTEX_COUNT.
  • All indexes are in bounds for the given vertex arrays.
  • There is a non-zero count of indices.
  • There is a multiple-of-three count of indices.
Source

pub fn build(self) -> Result<Mesh, MeshValidationError>

Build a mesh, adding whatever components weren’t provided.

If normals weren’t provided, they will be calculated. If mesh is right handed, will be converted to left handed.

All others will be filled with defaults.

Trait Implementations§

Source§

impl Debug for MeshBuilder

Source§

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

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

impl Default for MeshBuilder

Source§

fn default() -> MeshBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, 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.