Skip to main content

Module mesh

Module mesh 

Source
Expand description

Unity meshes: vertex channels in interleaved streams (decoded through checked vertex layouts), or a compressed mesh (bit-packed quantised floats); an index buffer of 16- or 32-bit indices; submeshes.

Vertex data layout (Unity 5 and later): the channels name a stream, an offset in it, a format and a dimension; a stream’s stride is the sum of its channels’ sizes, and the streams follow each other, each starting 16-byte aligned. The bytes are in the mesh, or streamed from a resource file (m_StreamData).

A compressed mesh’s floats are PackedBitVectors: n items of bits bits each, little-endian bit order, each start + item * (range / (2^bits - 1)) in f32; normals and tangents keep x and y, z is rebuilt from the unit length with a stored sign; its indices are packed integers (m_Triangles).

Structs§

Blend
Bone influences per vertex, as a mesh stores them: vertex v’s weights and bone slots are weights[starts[v]..starts[v + 1]] and bones[..], heaviest first.
Channel
One decoded channel: dim components per vertex.
MeshShapes
A mesh’s blend shapes as stored (m_Shapes): per channel its frames in increasing weight (Unity’s weights run 0 to 100), per frame sparse deltas of the mesh’s vertices, applied to the mesh as stored before any skin.
MeshSkin
A mesh’s skin as stored, in Unity’s frame: the blend channels (BlendWeight and BlendIndices: up to four influences a vertex, as Unity draws them at four or fewer), the full influences of a mesh that stores them (m_VariableBoneCountWeights, which Unity draws only at unlimited skin weights; the channels then hold its first four renormalised), and per bone the bind pose, the matrix taking the renderer’s local space to the bone’s at bind time.
ShapeChannel
One blend shape channel (m_Shapes.channels): a name, the CRC-32 of it that an animation curve names it by, and its frames (frames of them from first_frame in MeshShapes::frames).
ShapeFrame
One frame of a blend shape (m_Shapes.shapes, its fullWeights entry): the weight it is at, its entries (count from first in MeshShapes::vertices) and whether they carry normal and tangent deltas.
ShapeVertex
A blend shape entry (m_Shapes.vertices): the delta of vertex index of the mesh, in Unity’s frame.
SubMesh
A submesh: a run of the index buffer.
UnityMeshData
A mesh as stored, in Unity’s frame.

Constants§

CHANNELS
Unity’s shader channels, in the order of m_Channels.

Type Aliases§

PaddedSets
A skin’s influences as sets of four per vertex ([set][vertex]): the weights, the bone slots and the number of vertices cut to a limit (MeshSkin::padded).