Struct bevy::render::mesh::Mesh [−]
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>
)
&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>
&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>
&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>ⓘ
Trait Implementations
impl Clone for Mesh
pub fn clone(&self) -> Mesh
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
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]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Asset for T where
T: TypeUuid + AssetDynamic + TypeUuidDynamic,
T: TypeUuid + AssetDynamic + TypeUuidDynamic,
impl<T> AssetDynamic for T where
T: Send + Sync + 'static + TypeUuidDynamic,
T: Send + Sync + 'static + TypeUuidDynamic,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Any + Clone,
T: Any + Clone,
impl<T> Component for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> Downcast<T> for T
impl<T> DowncastSync for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> TypeData for T where
T: 'static + Send + Sync + Clone,
T: 'static + Send + Sync + Clone,
pub fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>
impl<T> TypeUuidDynamic for T where
T: TypeUuid,
T: TypeUuid,
impl<T> Upcast<T> for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,