pub struct CpuMesh {
    pub positions: Positions,
    pub indices: Indices,
    pub normals: Option<Vec<Vector3<f32>>>,
    pub tangents: Option<Vec<Vector4<f32>>>,
    pub uvs: Option<Vec<Vector2<f32>>>,
    pub colors: Option<Vec<Srgba>>,
}
Expand description

A CPU-side version of a triangle mesh.

Fields§

§positions: Positions

The positions of the vertices. If there is no indices associated with this mesh, three contiguous positions defines a triangle, in that case, the length must be divisable by 3.

§indices: Indices

The indices into the positions, normals, uvs and colors arrays which defines the three vertices of a triangle. Three contiguous indices defines a triangle, therefore the length must be divisable by 3.

§normals: Option<Vec<Vector3<f32>>>

The normals of the vertices.

§tangents: Option<Vec<Vector4<f32>>>

The tangents of the vertices, orthogonal direction to the normal. The fourth value specifies the handedness (either -1.0 or 1.0).

§uvs: Option<Vec<Vector2<f32>>>

The uv coordinates of the vertices.

§colors: Option<Vec<Srgba>>

The colors of the vertices.

Implementations§

source§

impl TriMesh

source

pub fn vertex_count(&self) -> usize

Returns the number of vertices in this mesh.

source

pub fn triangle_count(&self) -> usize

Returns the number of triangles in this mesh.

source

pub fn transform(&mut self, transform: &Matrix4<f32>) -> Result<(), Error>

Transforms the mesh by the given transformation.

source

pub fn square() -> TriMesh

Returns a square mesh spanning the xy-plane with positions in the range [-1..1] in the x and y axes.

source

pub fn circle(angle_subdivisions: u32) -> TriMesh

Returns a circle mesh spanning the xy-plane with radius 1 and center in (0, 0, 0).

source

pub fn sphere(angle_subdivisions: u32) -> TriMesh

Returns a sphere mesh with radius 1 and center in (0, 0, 0).

source

pub fn cube() -> TriMesh

Returns an axis aligned unconnected cube mesh with positions in the range [-1..1] in all axes.

source

pub fn cylinder(angle_subdivisions: u32) -> TriMesh

Returns a cylinder mesh around the x-axis in the range [0..1] and with radius 1.

source

pub fn cone(angle_subdivisions: u32) -> TriMesh

Returns a cone mesh around the x-axis in the range [0..1] and with radius 1 at -1.0.

source

pub fn arrow( tail_length: f32, tail_radius: f32, angle_subdivisions: u32 ) -> TriMesh

Returns an arrow mesh around the x-axis in the range [0..1] and with radius 1. The tail length and radius should be in the range ]0..1[.

source

pub fn compute_normals(&mut self)

Computes the per vertex normals and updates the normals of the mesh. It will override the current normals if they already exist.

source

pub fn compute_tangents(&mut self)

Computes the per vertex tangents and updates the tangents of the mesh. It will override the current tangents if they already exist.

source

pub fn for_each_vertex(&self, callback: impl FnMut(usize))

Iterates over all vertices in this mesh and calls the callback function with the index for each vertex.

source

pub fn for_each_triangle(&self, callback: impl FnMut(usize, usize, usize))

Iterates over all triangles in this mesh and calls the callback function with the three indices, one for each vertex in the triangle.

source

pub fn compute_aabb(&self) -> AxisAlignedBoundingBox

Computes the AxisAlignedBoundingBox for this triangle mesh.

source

pub fn validate(&self) -> Result<(), Error>

Returns an error if the mesh is not valid.

Trait Implementations§

source§

impl Clone for TriMesh

source§

fn clone(&self) -> TriMesh

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TriMesh

source§

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

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

impl Default for TriMesh

source§

fn default() -> TriMesh

Returns the “default value” for a type. Read more
source§

impl Deserialize for TriMesh

source§

fn deserialize( path: impl AsRef<Path>, raw_assets: &mut RawAssets ) -> Result<TriMesh, Error>

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,