pub struct TriMesh<N: RealField + Copy> {
pub coords: Vec<Point<N>>,
pub normals: Option<Vec<Vector<N>>>,
pub uvs: Option<Vec<Point2<N>>>,
pub indices: IndexBuffer,
}
Expand description
Geometric description of a mesh.
Fields§
§coords: Vec<Point<N>>
Coordinates of the mesh vertices.
normals: Option<Vec<Vector<N>>>
Coordinates of the mesh normals.
uvs: Option<Vec<Point2<N>>>
Textures coordinates of the mesh.
indices: IndexBuffer
Index buffer of the mesh.
Implementations§
Source§impl<N: RealField + Copy> TriMesh<N>
impl<N: RealField + Copy> TriMesh<N>
Sourcepub fn new(
coords: Vec<Point<N>>,
normals: Option<Vec<Vector<N>>>,
uvs: Option<Vec<Point2<N>>>,
indices: Option<IndexBuffer>,
) -> TriMesh<N>
pub fn new( coords: Vec<Point<N>>, normals: Option<Vec<Vector<N>>>, uvs: Option<Vec<Point2<N>>>, indices: Option<IndexBuffer>, ) -> TriMesh<N>
Creates a new TriMesh
.
If no indices
is provided, trivial, sequential indices are generated.
Sourcepub fn has_normals(&self) -> bool
pub fn has_normals(&self) -> bool
Whether or not this triangle mesh has normals.
Sourcepub fn translate_by(&mut self, t: &Translation<N>)
pub fn translate_by(&mut self, t: &Translation<N>)
Translates each vertex of this mesh.
Sourcepub fn transform_by(&mut self, t: &Isometry<N>)
pub fn transform_by(&mut self, t: &Isometry<N>)
Transforms each vertex and rotates each normal of this mesh.
Sourcepub fn num_triangles(&self) -> usize
pub fn num_triangles(&self) -> usize
The number of triangles on this mesh.
Sourcepub fn flat_indices(&self) -> Vec<u32>
pub fn flat_indices(&self) -> Vec<u32>
Returns only the vertex ids from the index buffer.
Source§impl<N: RealField + Copy> TriMesh<N>
impl<N: RealField + Copy> TriMesh<N>
Sourcepub fn recompute_normals(&mut self)
pub fn recompute_normals(&mut self)
Recomputes the mesh normals using its vertex coordinates and adjascency informations infered from the index buffer.
Sourcepub fn flip_normals(&mut self)
pub fn flip_normals(&mut self)
Flips all the normals of this mesh.
Sourcepub fn flip_triangles(&mut self)
pub fn flip_triangles(&mut self)
Flips the orientation of every triangle of this mesh.
Source§impl<N: RealField + Copy> TriMesh<N>
impl<N: RealField + Copy> TriMesh<N>
Sourcepub fn scale_by_scalar(&mut self, s: N)
pub fn scale_by_scalar(&mut self, s: N)
Scales each vertex of this mesh.
Source§impl<N: RealField + Copy> TriMesh<N>
impl<N: RealField + Copy> TriMesh<N>
Sourcepub fn unify_index_buffer(&mut self)
pub fn unify_index_buffer(&mut self)
Force the mesh to use the same index for vertices, normals and uvs.
This might cause the duplication of some vertices, normals and uvs. Use this method to transform the mesh data to a OpenGL-compliant format.
Sourcepub fn replicate_vertices(&mut self)
pub fn replicate_vertices(&mut self)
Unifies the index buffer and ensure duplicate each vertex are duplicated such that no two vertex entry of the index buffer are equal.
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for TriMesh<N>
impl<N> RefUnwindSafe for TriMesh<N>where
N: RefUnwindSafe,
impl<N> Send for TriMesh<N>
impl<N> Sync for TriMesh<N>
impl<N> Unpin for TriMesh<N>where
N: Unpin,
impl<N> UnwindSafe for TriMesh<N>where
N: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.