pub struct GpuMesh {
pub vertices: Vec<[f32; 3]>,
pub normals: Vec<[f32; 3]>,
pub indices: Vec<[u32; 3]>,
pub tex_coords: Vec<[f32; 2]>,
}Expand description
Triangle mesh stored in GPU-friendly interleaved layout.
Each vertex holds a position, a normal, and a UV texture coordinate.
Triangles are stored as [i, j, k] index triples.
Fields§
§vertices: Vec<[f32; 3]>Vertex positions [x, y, z].
normals: Vec<[f32; 3]>Per-vertex normals [nx, ny, nz].
indices: Vec<[u32; 3]>Triangle index triples.
tex_coords: Vec<[f32; 2]>Per-vertex UV texture coordinates [u, v].
Implementations§
Source§impl GpuMesh
impl GpuMesh
Sourcepub fn add_vertex(&mut self, pos: [f32; 3], normal: [f32; 3], uv: [f32; 2])
pub fn add_vertex(&mut self, pos: [f32; 3], normal: [f32; 3], uv: [f32; 2])
Add a vertex with position, normal, and UV.
Sourcepub fn add_triangle(&mut self, i: u32, j: u32, k: u32)
pub fn add_triangle(&mut self, i: u32, j: u32, k: u32)
Add a triangle by vertex indices.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Number of vertices.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Number of triangles.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuMesh
impl RefUnwindSafe for GpuMesh
impl Send for GpuMesh
impl Sync for GpuMesh
impl Unpin for GpuMesh
impl UnsafeUnpin for GpuMesh
impl UnwindSafe for GpuMesh
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<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>
Converts
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>
Converts
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 more