pub struct MeshData {
pub vertices: Vec<[f64; 3]>,
pub faces: Vec<[usize; 3]>,
pub normals: Vec<[f64; 3]>,
pub uvs: Vec<[f64; 2]>,
pub material_ids: Vec<usize>,
}Expand description
Container for mesh geometry and per-vertex attributes.
Fields§
§vertices: Vec<[f64; 3]>Vertex positions as [f64; 3] triples.
faces: Vec<[usize; 3]>Triangle face indices: each entry is [v0, v1, v2].
normals: Vec<[f64; 3]>Per-vertex normals (may be empty).
uvs: Vec<[f64; 2]>Per-vertex UV coordinates (may be empty).
material_ids: Vec<usize>Per-face material ID (may be empty).
Implementations§
Source§impl MeshData
impl MeshData
Sourcepub fn add_vertex(&mut self, pos: [f64; 3]) -> usize
pub fn add_vertex(&mut self, pos: [f64; 3]) -> usize
Add a vertex and return its index.
Sourcepub fn add_face_with_material(
&mut self,
v0: usize,
v1: usize,
v2: usize,
mat: usize,
)
pub fn add_face_with_material( &mut self, v0: usize, v1: usize, v2: usize, mat: usize, )
Add a triangular face with material ID.
Sourcepub fn compute_flat_normals(&mut self)
pub fn compute_flat_normals(&mut self)
Compute per-face normals and store as per-vertex normals (flat shading).
Sourcepub fn compute_smooth_normals(&mut self)
pub fn compute_smooth_normals(&mut self)
Compute smooth per-vertex normals by averaging face normals.
Sourcepub fn bounding_box(&self) -> ([f64; 3], [f64; 3])
pub fn bounding_box(&self) -> ([f64; 3], [f64; 3])
Return the axis-aligned bounding box of all vertices as (min, max).
Sourcepub fn num_triangles(&self) -> usize
pub fn num_triangles(&self) -> usize
Number of triangles in the mesh.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MeshData
impl RefUnwindSafe for MeshData
impl Send for MeshData
impl Sync for MeshData
impl Unpin for MeshData
impl UnsafeUnpin for MeshData
impl UnwindSafe for MeshData
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.