Struct mod3d_base::Vertices

source ·
pub struct Vertices<'vertices, R: Renderable + ?Sized> { /* private fields */ }
Expand description

A set of vertices using one or more crate::BufferData through BufferAccessors.

A number of Vertices is used by an Object, its components and their meshes; one is used for each primitive within a mesh for its elements. The actual elements will be sets of triangles (as stripes or whatever) which use these vertices.

A Vertices object includes a lot of options for vertices, and different renderers (or different render stages) may require different subsets of these indices. As such, in OpenGL for example, a Vertices object may end up with more than one VAO. This data is part of the [VerticesClient] struct associated with the Vertices

When it comes to creating an instance of a mesh, that instance will have specific transformations and materials for each of its primitives; rendering the instance with a shader will require enabling the Vertices client for that shader, setting appropriate render options (uniforms in OpenGL)

Implementations§

source§

impl<'vertices, R: Renderable> Vertices<'vertices, R>

ip Vertices

source

pub fn new( indices: &'vertices BufferAccessor<'vertices, R>, position: &'vertices BufferAccessor<'vertices, R>, ) -> Self

Create a new Vertices object with no additional attributes

source

pub fn add_attr( &mut self, attr: VertexAttr, accessor: &'vertices BufferAccessor<'vertices, R>, )

Add a BufferAccessor for a particular VertexAttr

On creation the Vertices will have views for indices and positions; this provides a means to add views for things such as normal, tex coords, etc

source

pub fn borrow_indices<'a>(&'a self) -> &'a BufferAccessor<'vertices, R>

Borrow the indices BufferAccessor

source

pub fn borrow_position<'a>(&'a self) -> &'a BufferAccessor<'vertices, R>

Borrow the position BufferAccessor

source

pub fn borrow_attr<'a>( &'a self, attr: VertexAttr, ) -> Option<&'a BufferAccessor<'vertices, R>>

Borrow an attribute BufferAccessor if the Vertices has one

source

pub fn iter_attrs( &self, ) -> Iter<'_, (VertexAttr, &BufferAccessor<'vertices, R>)>

Iterate through attributes

source

pub fn create_client(&self, renderer: &mut R)

Create the render buffer required by the BufferAccessor

source

pub fn borrow_client(&self) -> Ref<'_, R::Vertices>

Borrow the client

Trait Implementations§

source§

impl<'vertices, R: Debug + Renderable + ?Sized> Debug for Vertices<'vertices, R>
where R::Vertices: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'vertices, R> Display for Vertices<'vertices, R>
where R: Renderable,

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'vertices, R> !Freeze for Vertices<'vertices, R>

§

impl<'vertices, R> !RefUnwindSafe for Vertices<'vertices, R>

§

impl<'vertices, R> !Send for Vertices<'vertices, R>

§

impl<'vertices, R> !Sync for Vertices<'vertices, R>

§

impl<'vertices, R> Unpin for Vertices<'vertices, R>
where <R as Renderable>::Vertices: Unpin,

§

impl<'vertices, R> !UnwindSafe for Vertices<'vertices, R>

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.