Struct Mesh

Source
pub struct Mesh { /* private fields */ }
Expand description

Mesh, vertex data and vao/vbo

Implementations§

Source§

impl Mesh

Source

pub fn vertices(&self) -> &[Vector3]

Vertex positions (XYZ - 3 components per vertex) (shader-location = 0)

Source

pub fn vertices_mut(&mut self) -> &mut [Vector3]

Vertex positions (XYZ - 3 components per vertex) (shader-location = 0)

Source

pub fn texcoords(&self) -> &[Vector2]

Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)

Source

pub fn texcoords_mut(&mut self) -> &mut [Vector2]

Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)

Source

pub fn texcoords2(&self) -> &[Vector2]

Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)

Source

pub fn texcoords2_mut(&mut self) -> &mut [Vector2]

Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)

Source

pub fn normals(&self) -> &[Vector3]

Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)

Source

pub fn normals_mut(&mut self) -> &mut [Vector3]

Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)

Source

pub fn tangents(&self) -> &[Vector4]

Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)

Source

pub fn tangents_mut(&mut self) -> &mut [Vector4]

Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)

Source

pub fn colors(&self) -> &[Color]

Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)

Source

pub fn colors_mut(&mut self) -> &mut [Color]

Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)

Source

pub fn indices(&self) -> &[u16]

Vertex indices (in case vertex data comes indexed)

Source

pub fn indices_mut(&mut self) -> &mut [u16]

Vertex indices (in case vertex data comes indexed)

Source

pub fn upload(&mut self, dynamic: bool)

Upload mesh vertex data in GPU and provide VAO/VBO ids

Source

pub fn update_buffer(&self, index: u32, data: &[u8], offset: u32)

Update mesh vertex data in GPU for a specific buffer index

Source

pub fn export(&self, file_name: &str) -> bool

Export mesh data to file, returns true on success

Source

pub fn get_bounding_box(&self) -> BoundingBox

Compute mesh bounding box limits

Source

pub fn generate_tangents(&mut self)

Compute mesh tangents

Source

pub fn generate_polygon(sides: u32, radius: f32) -> Self

Generate polygonal mesh

Source

pub fn generate_plane(width: f32, length: f32, res_x: u32, res_z: u32) -> Self

Generate plane mesh (with subdivisions)

Source

pub fn generate_cube(width: f32, height: f32, length: f32) -> Self

Generate cuboid mesh

Source

pub fn generate_sphere(radius: f32, rings: u32, slices: u32) -> Self

Generate sphere mesh (standard sphere)

Source

pub fn generate_hemisphere(radius: f32, rings: u32, slices: u32) -> Self

Generate half-sphere mesh (no bottom cap)

Source

pub fn generate_cylinder(radius: f32, height: f32, slices: u32) -> Self

Generate cylinder mesh

Source

pub fn generate_cone(radius: f32, height: f32, slices: u32) -> Self

Generate cone/pyramid mesh

Source

pub fn generate_torus(radius: f32, size: f32, rad_seg: u32, sides: u32) -> Self

Generate torus mesh

Source

pub fn generate_knot(radius: f32, size: f32, rad_seg: u32, sides: u32) -> Self

Generate trefoil knot mesh

Source

pub fn generate_heightmap(heightmap: &Image, size: Vector3) -> Self

Generate heightmap mesh from image data

Source

pub fn generate_cubicmap(cubicmap: &Image, cube_size: Vector3) -> Self

Generate cubes-based map mesh from image data

Source

pub fn as_raw(&self) -> &Mesh

Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original

Source

pub fn as_raw_mut(&mut self) -> &mut Mesh

Get the ‘raw’ ffi type Take caution when cloning so it doesn’t outlive the original

Source

pub unsafe fn from_raw(raw: Mesh) -> Self

Convert a ‘raw’ ffi object to a safe wrapper

§Safety
  • The raw object must be correctly initialized
  • The raw object should be unique. Otherwise, make sure its clones don’t outlive the newly created object.

Trait Implementations§

Source§

impl Debug for Mesh

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Mesh

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.