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>
impl<'vertices, R: Renderable> Vertices<'vertices, R>
ip Vertices
sourcepub fn new(
indices: &'vertices BufferAccessor<'vertices, R>,
position: &'vertices BufferAccessor<'vertices, R>,
) -> Self
pub fn new( indices: &'vertices BufferAccessor<'vertices, R>, position: &'vertices BufferAccessor<'vertices, R>, ) -> Self
Create a new Vertices object with no additional attributes
sourcepub fn add_attr(
&mut self,
attr: VertexAttr,
accessor: &'vertices BufferAccessor<'vertices, R>,
)
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
sourcepub fn borrow_indices<'a>(&'a self) -> &'a BufferAccessor<'vertices, R>
pub fn borrow_indices<'a>(&'a self) -> &'a BufferAccessor<'vertices, R>
Borrow the indices BufferAccessor
sourcepub fn borrow_position<'a>(&'a self) -> &'a BufferAccessor<'vertices, R>
pub fn borrow_position<'a>(&'a self) -> &'a BufferAccessor<'vertices, R>
Borrow the position BufferAccessor
sourcepub fn borrow_attr<'a>(
&'a self,
attr: VertexAttr,
) -> Option<&'a BufferAccessor<'vertices, R>>
pub fn borrow_attr<'a>( &'a self, attr: VertexAttr, ) -> Option<&'a BufferAccessor<'vertices, R>>
Borrow an attribute BufferAccessor if the Vertices has one
sourcepub fn iter_attrs(
&self,
) -> Iter<'_, (VertexAttr, &BufferAccessor<'vertices, R>)>
pub fn iter_attrs( &self, ) -> Iter<'_, (VertexAttr, &BufferAccessor<'vertices, R>)>
Iterate through attributes
sourcepub fn create_client(&self, renderer: &mut R)
pub fn create_client(&self, renderer: &mut R)
Create the render buffer required by the BufferAccessor
sourcepub fn borrow_client(&self) -> Ref<'_, R::Vertices>
pub fn borrow_client(&self) -> Ref<'_, R::Vertices>
Borrow the client