Skinned mesh file format (.bsm2)

Simple binary file for animated skinned meshes. Contains vertex buffer, index buffer (triangle indices), geometry subsets (ranges in index buffer), material names, animations, and optional bone hierarchy info for physics meshes.

File structure

uint32 number of vertices
uint32 number of indices
uint32 number of geometry subsets
uint32 number of bones
uint32 number of material names
uint32 number of animations
for each vertex
float3 position
int1010102 normal // in normalized signed 1010102 format
int1010102 tangent // tangent in x,y,z, sign mult of bitangent in w
uint16 u, v // texture coord in normalized uint16 format
uint8 bones[4] // bone indices
uint8 weights[4] // bone weights in normalized uint8
for each index
uint16 index
for each geometry subset
uint32 first index
uint32 number of indices
uint32 material index
for each material name
string name
for each animation
string name
uint64 duration in ns
uint64 keys interval in ns
uint32 number of keys
for each animation key
for each bone
float3x4 bone transformation matrix
optional hierarchy info for physics meshes:
uint8 parent bone index[number of bones]
float4x4 inverse base pose matrix[number of bones]
string bone names[number of bones]

There string stored as:

uint32 string size
char characters[string size] // without 0 terminator

For regular animated meshes (without hierarchy info in file) all bone transformation matrices include inverse base pose transform and all parent bones transforms. For physics meshes (with hierarchy info) bone transformation matrices are local and don't include parent and inverse base pos transforms.

Tooling

.bsm2 files are created from .fbx files by fbx_bsm2 tool: fbx_bsm2 [-hierarchy] [-last_bones] path/to/file.fbx will output path/to/file.bsm2.

Options:

  • -hierarchy - include hierarchy info for physics.
  • -last_bones - output full bone chains. Without this conversion will include only bones, which influence mesh vertices. Sometimes bones at the ends of hierarchy chains doesn't influence mesh, but they may be useful for physics simulation.
Last updated on