CSKR (File Format)

Revision as of 14:30, 26 January 2015 by >Aruki

The CSKR format contains skin bindings for rigged models. It attaches groups of vertices to bones. Note that any model being skinned needs to be exported at the same time as the skin; you can't skin a pre-existing model without modifying it. The reason is because the way the skin format works, the vertices with the same weights need to be grouped together in the model file.

This file format is almost completely documented
The only thing that isn't understood about this format is, why do some CSKR files contain all the vertex coordinates and normals? Also, what's the max number of bones that can be weighted to one vertex?

Format

CSKR is a very simple format. It begins with a 32-bit weight count, followed by a set of vertex groups. Each vertex group assigns a set of weights to a specified number of vertices; these vertices are specified simply through a count value, and are implied to begin after the end of the previous group. The total value of all the weights on all bones in a given vertex group should be 1.0.

Vertex Group

Type Count Description
long 1 Weight count (WC)
Weight WC Weights
long 1 Vertex count

Weight

Type Count Description
long 1 Bone ID
float 1 Weight

Footer

CSKR files contain a footer after all the weights are assigned. The structure is a little strange; it lists the vertex coordinate and vertex normal counts (which are often the same value). Usually each of these counts will be preceded by a value of 0xFFFFFFFF; however, if they're not, then the entire vertex coordinate/normal array from the model file will be inserted into the skin file. It's a byte-for-byte match with the data from the model. The purpose of this section is unknown.