pub struct Mesh {
pub vertices: Vec<Vertex>,
pub indices: Vec<usize>,
pub material: usize,
}Fields§
§vertices: Vec<Vertex>§indices: Vec<usize>These indices are relative to 0 for this mesh. When adding to a global index buffer, we offset them by previous meshes’ vertex counts.
material: usizeImplementations§
Source§impl Mesh
impl Mesh
Sourcepub fn new_surface(points: &Vec<Vec<Vec3>>, two_sided: bool) -> Self
pub fn new_surface(points: &Vec<Vec<Vec3>>, two_sided: bool) -> Self
Create a grid surface of triangles.
Useful for building a grid surface like terrain, or a surface plot.
grid’s outer vec is rows; inner vec is col-associated values within that
row. The grid is evenly-spaced.
todo: You should draw both sides.
Create a sided surface. Useful as terrain, or as a 2-sided plot.
Note that the grid is viewed here as x, z, with values in y direction, to be compatible
with the convention of Z-up used elsewhere.
Points are (x, y, z), with Z being the vertical component. Their indices correspond to how they’re tied together in a mesh.
Sourcepub fn new_sphere(radius: f32, subdivisions: u32) -> Self
pub fn new_sphere(radius: f32, subdivisions: u32) -> Self
Creates an isosphere, from subdividing an icosahedron. 2-3 subdivisions works well for most uses.
Sourcepub fn new_sphere_uv(radius: f32, num_lats: usize, num_lons: usize) -> Self
pub fn new_sphere_uv(radius: f32, num_lats: usize, num_lons: usize) -> Self
Create a UV sphere mesh. A higher number of latitudes and longitudes results in a a smoother sphere.
pub fn new_ring( len: f32, radius_inner: f32, radius_outer: f32, num_sides: usize, ) -> Self
Sourcepub fn new_box(len_x: f32, len_y: f32, len_z: f32) -> Self
pub fn new_box(len_x: f32, len_y: f32, len_z: f32) -> Self
Create a box (rectangular prism) mesh.
Sourcepub fn new_tetrahedron(side_len: f32) -> Self
pub fn new_tetrahedron(side_len: f32) -> Self
Create a tetrahedron mesh
Sourcepub fn new_cylinder(len: f32, radius: f32, num_sides: usize) -> Self
pub fn new_cylinder(len: f32, radius: f32, num_sides: usize) -> Self
Create a cylinder
pub fn new_pyramid(len: f32, radius: f32, num_sides: usize) -> Self
Sourcepub fn new_arrow(len: f32, radius: f32, num_sides: usize) -> Self
pub fn new_arrow(len: f32, radius: f32, num_sides: usize) -> Self
Create an arrow, oriented up.
Sourcepub fn from_obj(obj_data: &[u8]) -> Self
pub fn from_obj(obj_data: &[u8]) -> Self
Load a mesh from obj data. File type description Example
Sourcepub fn from_obj_file(filename: &str) -> Self
pub fn from_obj_file(filename: &str) -> Self
Load a mesh from a obj file. File type description Example
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
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().