Struct three_d::core::CPUMesh[][src]

pub struct CPUMesh {
    pub name: String,
    pub material_name: Option<String>,
    pub positions: Vec<f32>,
    pub indices: Option<Indices>,
    pub normals: Option<Vec<f32>>,
    pub uvs: Option<Vec<f32>>,
    pub colors: Option<Vec<u8>>,
}
Expand description

A CPU-side version of a triangle mesh. Can be constructed manually or loaded via io or via the utility functions for generating simple triangle meshes.

Fields

name: String

Name.

material_name: Option<String>

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

positions: Vec<f32>

The positions of the vertices. Three contiguous floats defines a 3D position (x, y, z), therefore the length must be divisable by 3. If there is no indices associated with this mesh, three contiguous positions defines a triangle, in that case, the length must also be divisable by 9.

indices: Option<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<f32>>

The normals of the vertices. Three contiguous floats defines a normal (x, y, z), therefore the length must be divisable by 3.

uvs: Option<Vec<f32>>

The uv coordinates of the vertices. Two contiguous floats defines a coordinate (u, v), therefore the length must be divisable by 2.

colors: Option<Vec<u8>>

The colors of the vertices. Four contiguous bytes defines a color (r, g, b, a), therefore the length must be divisable by 4. The colors are assumed to be in linear space.

Implementations

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 axis aligned bounding box of the mesh.

Returns an error if the mesh is not valid.

Trait Implementations

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

Performs the conversion.

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

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. 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