Struct blender_mesh::BlenderMesh[][src]

pub struct BlenderMesh {
    pub vertex_positions: Vec<f32>,
    pub vertex_position_indices: Vec<u16>,
    pub num_vertices_in_each_face: Vec<u8>,
    pub vertex_normals: Vec<f32>,
    pub vertex_normal_indices: Option<Vec<u16>>,
    pub armature_name: Option<String>,
    pub vertex_group_indices: Option<Vec<u8>>,
    pub vertex_group_weights: Option<Vec<f32>>,
    pub num_groups_for_each_vertex: Option<Vec<u8>>,
}

All of the data about a Blender mesh

Fields

[v1x, v1y, v1z, v2x, v2y, v2z, ...]

The indices within vertex positions that make up each triangle in our mesh. Three vertex position indices correspond to one triangle [0, 1, 2, 0, 2, 3, ...]

TODO: enum.. if they're all equal we replace the MyEnum::PerVertex(u8) with MyEnum::Equal(4)

TODO: When we move to single index triangulate and add new vertices give those vertices the same group indices / weights TODO: A function that trims this down to n weights and indices per vertex. Similar to our triangulate function TODO: Make sure that when we combine vertex indices we expand our group weights

TODO: enum.. if they're all equal we replace the MyEnum::PerVertex(u8) with MyEnum::Equal(4)

Methods

impl BlenderMesh
[src]

impl BlenderMesh
[src]

We export our models 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. Reduces amount of data required to represent the model on disk.

OpenGL only supports one index buffer, we convert our vertex data from having three indices to having one. This usually requires some duplication of vertex data. We duplicate the minimum amount of vertex data necessary.

FIXME: Wrote a test and threw code at the wall until it passed. Need to refactor this extensively! Any work on this before refactoring will not be worth the time Split this up into smaller functions that it calls, and clean up those functions.

impl BlenderMesh
[src]

When exporting a mesh from Blender, faces will usually have 4 vertices (quad) but some faces might have 3 (triangle).

We read self.num_vertices_in_each_face to check how many vertices each face has.

If a face has 4 vertices we convert it into two triangles, each with 3 vertices.

Panics

Panics if a face has more than 4 vertices. In the future we might support 5+ vertices, but I haven't run into that yet. Not even sure if Blender can have faces with 5 vertices..

impl BlenderMesh
[src]

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

impl BlenderMesh
[src]

Different vertices might have different numbers of bones that influence them. A vertex near the shoulder might be influenced by the neck and upper arm and sternum, while a vertex in a toe might only be influenced by a toe bone.

When passing data to the GPU, each vertex needs the same number of bone attributes, so we must add/remove bones from each vertex to get them equal.

Say we're setting 3 groups per vertex:

  • If a vertex has one vertex group (bone) we will create two fake bones with 0.0 weight.
  • If a vertex has 5 bones we'll remove the one with the smallest weighting (influence).

Trait Implementations

impl Debug for BlenderMesh
[src]

Formats the value using the given formatter. Read more

impl PartialEq for BlenderMesh
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

impl Send for BlenderMesh

impl Sync for BlenderMesh