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

pub struct Mesh { /* fields omitted */ }

Implementations

impl Mesh

Contains geometry in the form of a mesh.

Often meshes are automatically generated by bevy’s asset loaders or primitives, such as crate::shape::Cube or crate::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
}

pub const ATTRIBUTE_COLOR: &'static str

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

pub const ATTRIBUTE_NORMAL: &'static str

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

pub const ATTRIBUTE_TANGENT: &'static str

The direction of the vertex tangent. Used for normal mapping

pub const ATTRIBUTE_POSITION: &'static str

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

pub const ATTRIBUTE_UV_0: &'static str

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

pub fn new(primitive_topology: PrimitiveTopology) -> Mesh

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.

pub fn primitive_topology(&self) -> PrimitiveTopology

pub fn set_attribute(
    &mut self,
    name: impl Into<Cow<'static, str>>,
    values: impl Into<VertexAttributeValues>
)

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

pub fn attribute(
    &self,
    name: impl Into<Cow<'static, str>>
) -> Option<&VertexAttributeValues>

Retrieve the data currently set behind a vertex attribute.

pub fn attribute_mut(
    &mut self,
    name: impl Into<Cow<'static, str>>
) -> Option<&mut VertexAttributeValues>

pub fn set_indices(&mut self, indices: Option<Indices>)

Indices describe how triangles are constructed out of the vertex attributes. They are only useful for the crate::pipeline::PrimitiveTopology variants that use triangles

pub fn indices(&self) -> Option<&Indices>

pub fn indices_mut(&mut self) -> Option<&mut Indices>

pub fn get_index_buffer_bytes(&self) -> Option<Vec<u8, Global>>

pub fn get_vertex_buffer_layout(&self) -> VertexBufferLayout

pub fn count_vertices(&self) -> usize

pub fn get_vertex_buffer_data(&self) -> Vec<u8, Global>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator

Trait Implementations

impl Clone for Mesh

impl Debug for Mesh

impl From<Box> for Mesh

impl From<Capsule> for Mesh

impl From<Cube> for Mesh

impl From<Icosphere> for Mesh

impl From<Plane> for Mesh

impl From<Quad> for Mesh

impl From<Torus> for Mesh

impl TypeUuid for Mesh

Auto Trait Implementations

impl RefUnwindSafe for Mesh

impl Send for Mesh

impl Sync for Mesh

impl Unpin for Mesh

impl UnwindSafe for Mesh

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Asset for T where
    T: TypeUuid + AssetDynamic + TypeUuidDynamic

impl<T> AssetDynamic for T where
    T: Send + Sync + 'static + TypeUuidDynamic

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Any + Clone

impl<T> Component for T where
    T: 'static + Send + Sync

impl<T> Downcast for T where
    T: Any

impl<T> Downcast<T> for T

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> TypeData for T where
    T: 'static + Send + Sync + Clone

impl<T> TypeUuidDynamic for T where
    T: TypeUuid

impl<T> Upcast<T> for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,