Struct SingleIndexedVertexAttributes

Source
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

Source

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

Source

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

Source

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.

Source

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 Debug for SingleIndexedVertexAttributes

Source§

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

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

impl Default for SingleIndexedVertexAttributes

Source§

fn default() -> SingleIndexedVertexAttributes

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SingleIndexedVertexAttributes

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SingleIndexedVertexAttributes

Source§

fn eq(&self, other: &SingleIndexedVertexAttributes) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SingleIndexedVertexAttributes

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SingleIndexedVertexAttributes

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,