Struct BlenderMesh

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

All of the data about a mesh

TODO: Rename crate to MeshIr

Implementations§

Source§

impl BlenderMesh

Source

pub fn combine_vertex_indices( &mut self, config: &CreateSingleIndexConfig, ) -> SingleIndexedVertexAttributes

We store our exported Blender mesh with indices for positions, normals and uvs because

  1. Easier because we we can unit test that here vs. a blender python script that’s much trickier to test.

  2. Smaller to store the fields indexed than to expand them.


Most rendering pipelines only supports one index buffer, so here we convert our vertex data from having three indices to having one.

This typically requires some duplication of vertex data - we duplicate the minimum amount of vertex data necessary.

TODO: Need to continue refactoring

TODO: Make this function set BlenderMesh.vertex_attributes = VertexData::SingleIndexVertexData

TODO: Don’t work on additionally functionality until we’ve broken up these tests and implementation into smaller, specific pieces.

TODO: There are unexpected (based on the method’s name) mutations in here such as triangulation. Lot’s to refactor in this crate.

Source§

impl BlenderMesh

Source§

impl BlenderMesh

Source

pub fn y_up(&mut self)

Blender meshes get exported with a Z up coordinate system. Here we flip our coordinate system to be y up

@see https://gamedev.stackexchange.com/a/7932

TODO: When we have bone data we’ll need to change them to port change-mat4-coordinate-system into here. https://github.com/chinedufn/change-mat4-coordinate-system/blob/master/change-mat4-coordinate-system.js

Source§

impl BlenderMesh

Source

pub fn pbr_cube_without_textures() -> Self

Create a default Blender cube with uniform PBR texture inputs.

A 2x2x2 cube centered about the origin.

Source§

impl BlenderMesh

Source

pub fn armature_name(&self) -> Option<&String>

The name of this mesh’s parent armature

Source

pub fn set_armature_name(&mut self, armature_name: Option<String>)

Set the name of this mesh’s parent armature

Source

pub fn materials(&self) -> &HashMap<String, PrincipledBSDF>

A map of material name to the material’s data

Source

pub fn materials_mut(&mut self) -> &mut HashMap<String, PrincipledBSDF>

A mutable map of material name to the material’s data

Source

pub fn custom_properties(&self) -> &HashMap<String, CustomProperty>

Custom properties for this mesh

i.e. in Blender this might be found with bpy.context.view_layer.objects.active.keys()

Source

pub fn bounding_box(&self) -> BoundingBox

The smallest box that contains the entire mesh

Source

pub fn set_bounding_box(&mut self, bounding_box: BoundingBox)

Set the mesh’s bounding box.

Source

pub fn name(&self) -> &String

The name of the mesh

Source

pub fn set_name(&mut self, name: String)

Set the name of the mesh

Trait Implementations§

Source§

impl Clone for BlenderMesh

Source§

fn clone(&self) -> BlenderMesh

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BlenderMesh

Source§

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

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

impl Default for BlenderMesh

Source§

fn default() -> BlenderMesh

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

impl<'de> Deserialize<'de> for BlenderMesh

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 BlenderMesh

Source§

fn eq(&self, other: &BlenderMesh) -> 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 BlenderMesh

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 BlenderMesh

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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>,