pub struct TriMesh {
    pub name: String,
    pub material_name: Option<String>,
    pub positions: Positions,
    pub indices: Indices,
    pub normals: Option<Vec<Vec3>>,
    pub tangents: Option<Vec<Vec4>>,
    pub uvs: Option<Vec<Vec2>>,
    pub colors: Option<Vec<Color>>,
}
Expand description

A CPU-side version of a triangle mesh.

Fields

name: String

Name.

material_name: Option<String>

Name of the associated material, use this to match with PbrMaterial::name.

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

The normals of the vertices.

tangents: Option<Vec<Vec4>>

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

The uv coordinates of the vertices.

colors: Option<Vec<Color>>

The colors of the vertices. The colors are assumed to be in linear space.

Implementations

Returns the material for this mesh in the given list of materials. Returns None if no suitable material can be found.

Returns the number of vertices in this mesh.

Returns the number of triangles in this mesh.

Transforms the mesh by the given transformation.

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

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

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

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

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

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

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[.

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

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

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

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

Computes the axis aligned bounding box of the mesh.

Returns an error if the mesh is not valid.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more