pub struct Mesh {
pub vertices: Vec<Vertex>,
pub indices: Vec<u32>,
}Expand description
A triangle mesh.
Fields§
§vertices: Vec<Vertex>Vertex data.
indices: Vec<u32>Triangle indices (3 per triangle).
Implementations§
Source§impl Mesh
impl Mesh
pub fn new() -> Self
Sourcepub fn add_vertex(&mut self, vertex: Vertex) -> u32
pub fn add_vertex(&mut self, vertex: Vertex) -> u32
Add a vertex and return its index.
Sourcepub fn add_triangle(&mut self, i0: u32, i1: u32, i2: u32)
pub fn add_triangle(&mut self, i0: u32, i1: u32, i2: u32)
Add a triangle by vertex indices.
Sourcepub fn add_quad(&mut self, i0: u32, i1: u32, i2: u32, i3: u32)
pub fn add_quad(&mut self, i0: u32, i1: u32, i2: u32, i3: u32)
Add a quad (two triangles) by vertex indices. Vertices are provided in order around the quad. Triangles are wound CCW for front-facing.
Sourcepub fn add_quad_ao(&mut self, i0: u32, i1: u32, i2: u32, i3: u32, ao: [u8; 4])
pub fn add_quad_ao(&mut self, i0: u32, i1: u32, i2: u32, i3: u32, ao: [u8; 4])
Add a quad with AO-aware triangulation to fix anisotropy. Uses the diagonal that minimizes interpolation artifacts.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Get the number of triangles.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Get the number of vertices.
Sourcepub fn positions_flat(&self) -> Vec<f32>
pub fn positions_flat(&self) -> Vec<f32>
Get positions as a flat array (for glTF export).
Sourcepub fn normals_flat(&self) -> Vec<f32>
pub fn normals_flat(&self) -> Vec<f32>
Get normals as a flat array (for glTF export).
Sourcepub fn colors_flat(&self) -> Vec<f32>
pub fn colors_flat(&self) -> Vec<f32>
Get colors as a flat array (for glTF export).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mesh
impl RefUnwindSafe for Mesh
impl Send for Mesh
impl Sync for Mesh
impl Unpin for Mesh
impl UnwindSafe for Mesh
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more