logo

Struct bevy::render::mesh::Mesh[]

pub struct Mesh { /* fields omitted */ }

Implementations

Contains geometry in the form of a mesh.

Often meshes are automatically generated by bevy’s asset loaders or primitives, such as shape::Cube or shape::Box, but you can also construct one yourself.

Example of constructing a mesh:

fn create_triangle() -> Mesh {
    let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
    mesh.set_attribute(Mesh::ATTRIBUTE_POSITION, vec![[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]]);
    mesh.set_indices(Some(Indices::U32(vec![0,1,2])));
    mesh
}

Per vertex coloring. Use in conjunction with Mesh::set_attribute

The direction the vertex normal is facing in. Use in conjunction with Mesh::set_attribute

The direction of the vertex tangent. Used for normal mapping

Where the vertex is located in space. Use in conjunction with Mesh::set_attribute

Texture coordinates for the vertex. Use in conjunction with Mesh::set_attribute

Per vertex joint transform matrix weight. Use in conjunction with Mesh::set_attribute

Per vertex joint transform matrix index. Use in conjunction with Mesh::set_attribute

Construct a new mesh. You need to provide a PrimitiveTopology so that the renderer knows how to treat the vertex data. Most of the time this will be PrimitiveTopology::TriangleList.

Returns the topology of the mesh.

Sets the data for a vertex attribute (position, normal etc.). The name will often be one of the associated constants such as Mesh::ATTRIBUTE_POSITION.

Retrieves the data currently set to the vertex attribute with the specified name.

Retrieves the data currently set to the vertex attribute with the specified name mutably.

Sets the vertex indices of the mesh. They describe how triangles are constructed out of the vertex attributes and are therefore only useful for the PrimitiveTopology variants that use triangles.

Retrieves the vertex indices of the mesh.

Retrieves the vertex indices of the mesh mutably.

Computes and returns the index data of the mesh as bytes. This is used to transform the index data into a GPU friendly format.

Counts all vertices of the mesh.

Panics

Panics if the attributes have different vertex counts.

Computes and returns the vertex data of the mesh as bytes. Therefore the attributes are located in alphabetical order. This is used to transform the vertex data into a GPU friendly format.

Panics

Panics if the attributes have different vertex counts.

Duplicates the vertex attributes so that no vertices are shared.

This can dramatically increase the vertex count, so make sure this is what you want. Does nothing if no Indices are set.

Panics

If the mesh has any other topology than PrimitiveTopology::TriangleList.

Calculates the Mesh::ATTRIBUTE_NORMAL of a mesh.

Panics

Panics if Indices are set or Mesh::ATTRIBUTE_POSITION is not of type float3. Consider calling Mesh::duplicate_vertices or export your mesh with normal attributes.

Compute the Axis-Aligned Bounding Box of the mesh vertices in model space

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Clones the mesh.

Converts the extracted mesh a into GpuMesh.

The representation of the the asset in the “render world”.

The GPU-representation of the the asset.

Specifies all ECS data required by RenderAsset::prepare_asset. For convenience use the lifetimeless SystemParams. 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

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. 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 resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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