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
impl MeshBuilder
Sourcepub fn new(vertex_positions: Vec<Vec3>, handedness: Handedness) -> Self
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.
Sourcepub fn with_vertex_normals(self, normals: Vec<Vec3>) -> Self
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.
Sourcepub fn with_vertex_tangents(self, tangents: Vec<Vec3>) -> Self
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.
Sourcepub fn with_vertex_uv0(self, uvs: Vec<Vec2>) -> Self
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.
Sourcepub fn with_vertex_uv1(self, uvs: Vec<Vec2>) -> Self
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.
Sourcepub fn with_vertex_colors(self, colors: Vec<[u8; 4]>) -> Self
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.
Sourcepub fn with_vertex_joint_indices(self, joint_indices: Vec<[u16; 4]>) -> Self
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.
Sourcepub fn with_vertex_joint_weights(self, joint_weights: Vec<Vec4>) -> Self
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.
Sourcepub fn with_indices(self, indices: Vec<u32>) -> Self
pub fn with_indices(self, indices: Vec<u32>) -> Self
Sourcepub fn with_flip_winding_order(self) -> Self
pub fn with_flip_winding_order(self) -> Self
Flip the winding order
See Mesh::flip_winding_order
for more information.
Sourcepub fn with_double_sided(self) -> Self
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.
Sourcepub unsafe fn without_validation(self) -> Self
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.
Sourcepub fn build(self) -> Result<Mesh, MeshValidationError>
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.