pub struct SingleIndexedVertexAttributes { /* private fields */ }
Expand description
Most 3D model file formats export vertex data with multiple indices.
There might be indices for the positions, normals and uvs.
The SingleIndexVertexData
is vertex data that only has one index.
When we’ve run BlenderMesh.combine_vertex_indices
we’ll end up generating
SingleIndexVertexData
Implementations§
Source§impl SingleIndexedVertexAttributes
impl SingleIndexedVertexAttributes
Sourcepub fn face_weight_normals(&mut self) -> Result<(), WeightedNormalsError>
pub fn face_weight_normals(&mut self) -> Result<(), WeightedNormalsError>
Alter normals to be both surface weighted (connected triangle size) and angle weighted (angle of connected triangle corner)
@see http://www.bytehazard.com/articles/vertnorm.html
TODO: We could also implement this for multi-indexed - but we should wait until we refactor / replace the combine_indices function because, for example, if we weight normals before we calculate face tangents our face tangents will be incorrect. In general this entire crate needs to be heavily TDD“d and refactored into something clean..
TODO: When we combine normals we’ll end up with a lot of vertices that have the same data so we should dedupe the vertices / indices
Source§impl SingleIndexedVertexAttributes
impl SingleIndexedVertexAttributes
Sourcepub fn interleave<T: Copy>(
attribs: &[&VertexAttribute<T>],
) -> Result<Vec<T>, InterleaveError>
pub fn interleave<T: Copy>( attribs: &[&VertexAttribute<T>], ) -> Result<Vec<T>, InterleaveError>
Combine anu number of vertex attributes into a single buffer of vertex data.
Say you have positions: [0., 1., 2., 10., 11., 12.] with attribute size 3 uvs : [0., 1., 1., 1.]
This would get stitched together as [0., 1., 2., 0., 1., 10., 11., 12., 1., 1.]
More generally, say you have attributes P with size 3, U with size 2, N with size 3.
They’ll get interleaved as [ P0, P0, P0, U0, U0, N0, N0, P1, P1, P1, U1, U1, N1, N1, … ],
Source§impl SingleIndexedVertexAttributes
impl SingleIndexedVertexAttributes
Sourcepub fn indices(&self) -> &Vec<u16>
pub fn indices(&self) -> &Vec<u16>
For SingleIndexVertexData
every 3 indices corresponds to one triangle.
There can not be any other faces (quads, ngons) - only triangles.
Sourcepub fn vertices(&self) -> &Vec<Vertex>
pub fn vertices(&self) -> &Vec<Vertex>
All of the vertex data for the mesh.
You can index into this data using SingleIndexedVertexAttributes
Trait Implementations§
Source§impl Default for SingleIndexedVertexAttributes
impl Default for SingleIndexedVertexAttributes
Source§fn default() -> SingleIndexedVertexAttributes
fn default() -> SingleIndexedVertexAttributes
Source§impl<'de> Deserialize<'de> for SingleIndexedVertexAttributes
impl<'de> Deserialize<'de> for SingleIndexedVertexAttributes
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SingleIndexedVertexAttributes
impl PartialEq for SingleIndexedVertexAttributes
Source§fn eq(&self, other: &SingleIndexedVertexAttributes) -> bool
fn eq(&self, other: &SingleIndexedVertexAttributes) -> bool
self
and other
values to be equal, and is used by ==
.impl StructuralPartialEq for SingleIndexedVertexAttributes
Auto Trait Implementations§
impl Freeze for SingleIndexedVertexAttributes
impl RefUnwindSafe for SingleIndexedVertexAttributes
impl Send for SingleIndexedVertexAttributes
impl Sync for SingleIndexedVertexAttributes
impl Unpin for SingleIndexedVertexAttributes
impl UnwindSafe for SingleIndexedVertexAttributes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.