Skip to main content

Mesh

Struct Mesh 

Source
pub struct Mesh { /* private fields */ }
Expand description

A triangle mesh Geometry.

Implementations§

Source§

impl Mesh

Source

pub fn new(context: &Context, cpu_mesh: &CpuMesh) -> Self

Creates a new triangle mesh from the given CpuMesh. All data in the CpuMesh is transfered to the GPU, so make sure to remove all unnecessary data from the CpuMesh before calling this method.

Source

pub fn transformation(&self) -> Mat4

Returns the local to world transformation applied to this mesh.

Source

pub fn set_transformation(&mut self, transformation: Mat4)

Set the local to world transformation applied to this mesh. If any animation method is set using Self::set_animation, the transformation from that method is applied before this transformation.

Source

pub fn set_animation( &mut self, animation: impl Fn(f32) -> Mat4 + Send + Sync + 'static, )

Specifies a function which takes a time parameter as input and returns a transformation that should be applied to this mesh at the given time. To actually animate this mesh, call Geometry::animate at each frame which in turn evaluates the animation function defined by this method. This transformation is applied first, then the local to world transformation defined by Self::set_transformation.

Source

pub fn vertex_count(&self) -> u32

Returns the number of vertices in this mesh.

Source

pub fn indices_mut(&mut self) -> &mut TriangleBuffer

Used for editing the triangle definition in the TriangleBuffer for this mesh. Note: Changing this will possibly ruin the mesh.

Source

pub fn set_positions(&mut self, positions: &[Vec3]) -> Result<(), RendererError>

Update the vertex positions of the mesh. Returns an error if the number of positions does not match the number of vertices in the mesh.

Source

pub fn set_positions_partially( &mut self, offset: u32, positions: &[Vec3], ) -> Result<(), RendererError>

Partially update the vertex positions of the mesh. Returns an error if the number of positions plus the offset is larger than the number of vertices in the mesh.

Source

pub fn positions_mut(&mut self) -> &mut VertexBuffer<Vec3>

👎Deprecated:

use set_positions and set_positions_partially instead

Used for editing the vertex positions. Note: Changing this will possibly ruin the mesh.

Source

pub fn set_normals(&mut self, normals: &[Vec3]) -> Result<(), RendererError>

Update the vertex normals of the mesh. Returns an error if the number of normals does not match the number of vertices in the mesh.

Source

pub fn set_normals_partially( &mut self, offset: u32, normals: &[Vec3], ) -> Result<(), RendererError>

Partially update the vertex normals of the mesh. Returns an error if the number of normals plus the offset is larger than the number of vertices in the mesh or if the normal buffer is missing.

Source

pub fn normals_mut(&mut self) -> &mut Option<VertexBuffer<Vec3>>

👎Deprecated:

use set_normals and set_normals_partially instead

Used for editing the vertex normals. Note: Changing this will possibly ruin the mesh.

Source

pub fn set_uvs(&mut self, uvs: &[Vec2]) -> Result<(), RendererError>

Update the vertex UVs of the mesh. Returns an error if the number of UVs does not match the number of vertices in the mesh.

Source

pub fn set_uvs_partially( &mut self, offset: u32, uvs: &[Vec2], ) -> Result<(), RendererError>

Partially update the vertex UVs of the mesh. Returns an error if the number of UVs plus the offset is larger than the number of vertices in the mesh or if the UV buffer is missing.

Source

pub fn uvs_mut(&mut self) -> &mut Option<VertexBuffer<Vec2>>

👎Deprecated:

use set_uvs and set_uvs_partially instead

Used for editing the vertex uvs. Note: Changing this will possibly ruin the mesh.

Source

pub fn set_tangents(&mut self, tangents: &[Vec4]) -> Result<(), RendererError>

Update the vertex tangents of the mesh. Returns an error if the number of tangents does not match the number of vertices in the mesh.

Source

pub fn set_tangents_partially( &mut self, offset: u32, tangents: &[Vec4], ) -> Result<(), RendererError>

Partially update the vertex tangents of the mesh. Returns an error if the number of tangents plus the offset is larger than the number of vertices in the mesh or if the tangent buffer is missing.

Source

pub fn tangents_mut(&mut self) -> &mut Option<VertexBuffer<Vec4>>

👎Deprecated:

use set_tangents and set_tangents_partially instead

Used for editing the vertex tangents. Note: Changing this will possibly ruin the mesh.

Source

pub fn set_colors(&mut self, colors: &[Vec4]) -> Result<(), RendererError>

Update the vertex colors of the mesh. Returns an error if the number of colors does not match the number of vertices in the mesh.

Source

pub fn set_colors_partially( &mut self, offset: u32, colors: &[Vec4], ) -> Result<(), RendererError>

Partially update the vertex colors of the mesh. Returns an error if the number of colors plus the offset is larger than the number of vertices in the mesh or if the colors buffer is missing.

Source

pub fn colors_mut(&mut self) -> &mut Option<VertexBuffer<Vec4>>

👎Deprecated:

use set_colors and set_colors_partially instead

Used for editing the vertex colors. Note: Changing this will possibly ruin the mesh.

Trait Implementations§

Source§

impl Geometry for Mesh

Source§

fn aabb(&self) -> AxisAlignedBoundingBox

Returns the AxisAlignedBoundingBox for this geometry in the global coordinate system.
Source§

fn animate(&mut self, time: f32)

For updating the animation of this geometry if it is animated, if not, this method does nothing. The time parameter should be some continious time, for example the time since start.
Source§

fn draw( &self, viewer: &dyn Viewer, program: &Program, render_states: RenderStates, )

Draw this geometry.
Source§

fn vertex_shader_source(&self) -> String

Returns the vertex shader source for this geometry given that the fragment shader needs the given vertex attributes.
Source§

fn id(&self) -> GeometryId

Returns a unique ID for each variation of the shader source returned from Geometry::vertex_shader_source. Read more
Source§

fn render_with_material( &self, material: &dyn Material, viewer: &dyn Viewer, lights: &[&dyn Light], )

Render the geometry with the given Material. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the material does not require lights to be rendered.
Source§

fn render_with_effect( &self, material: &dyn Effect, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Render the geometry with the given Effect. Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method. Use an empty array for the lights argument, if the material does not require lights to be rendered.
Source§

impl<'a> IntoIterator for &'a Mesh

Source§

type Item = &'a dyn Geometry

The type of the elements being iterated over.
Source§

type IntoIter = Once<&'a dyn Geometry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl Freeze for Mesh

§

impl !RefUnwindSafe for Mesh

§

impl Send for Mesh

§

impl Sync for Mesh

§

impl Unpin for Mesh

§

impl UnsafeUnpin for Mesh

§

impl !UnwindSafe for Mesh

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.