pub struct BlenderMesh { /* private fields */ }
Expand description
All of the data about a mesh
TODO: Rename crate to MeshIr
Implementations§
Source§impl BlenderMesh
impl BlenderMesh
Sourcepub fn combine_vertex_indices(
&mut self,
config: &CreateSingleIndexConfig,
) -> SingleIndexedVertexAttributes
pub fn combine_vertex_indices( &mut self, config: &CreateSingleIndexConfig, ) -> SingleIndexedVertexAttributes
We store our exported Blender mesh with indices for positions, normals and uvs because
-
Easier because we we can unit test that here vs. a blender python script that’s much trickier to test.
-
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
impl BlenderMesh
pub fn interleave_vertex_data(&self) -> Vec<u8> ⓘ
Source§impl BlenderMesh
impl BlenderMesh
Sourcepub fn y_up(&mut self)
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
impl BlenderMesh
Sourcepub fn pbr_cube_without_textures() -> Self
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
impl BlenderMesh
Sourcepub fn armature_name(&self) -> Option<&String>
pub fn armature_name(&self) -> Option<&String>
The name of this mesh’s parent armature
Sourcepub fn set_armature_name(&mut self, armature_name: Option<String>)
pub fn set_armature_name(&mut self, armature_name: Option<String>)
Set the name of this mesh’s parent armature
Sourcepub fn materials(&self) -> &HashMap<String, PrincipledBSDF>
pub fn materials(&self) -> &HashMap<String, PrincipledBSDF>
A map of material name to the material’s data
Sourcepub fn materials_mut(&mut self) -> &mut HashMap<String, PrincipledBSDF>
pub fn materials_mut(&mut self) -> &mut HashMap<String, PrincipledBSDF>
A mutable map of material name to the material’s data
Sourcepub fn custom_properties(&self) -> &HashMap<String, CustomProperty>
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()
Sourcepub fn bounding_box(&self) -> BoundingBox
pub fn bounding_box(&self) -> BoundingBox
The smallest box that contains the entire mesh
Sourcepub fn set_bounding_box(&mut self, bounding_box: BoundingBox)
pub fn set_bounding_box(&mut self, bounding_box: BoundingBox)
Set the mesh’s bounding box.
Trait Implementations§
Source§impl Clone for BlenderMesh
impl Clone for BlenderMesh
Source§fn clone(&self) -> BlenderMesh
fn clone(&self) -> BlenderMesh
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BlenderMesh
impl Debug for BlenderMesh
Source§impl Default for BlenderMesh
impl Default for BlenderMesh
Source§fn default() -> BlenderMesh
fn default() -> BlenderMesh
Source§impl<'de> Deserialize<'de> for BlenderMesh
impl<'de> Deserialize<'de> for BlenderMesh
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 BlenderMesh
impl PartialEq for BlenderMesh
Source§impl Serialize for BlenderMesh
impl Serialize for BlenderMesh
impl StructuralPartialEq for BlenderMesh
Auto Trait Implementations§
impl Freeze for BlenderMesh
impl RefUnwindSafe for BlenderMesh
impl Send for BlenderMesh
impl Sync for BlenderMesh
impl Unpin for BlenderMesh
impl UnwindSafe for BlenderMesh
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.