OBD:Oni2AS

From OniGalore
Revision as of 19:23, 23 January 2020 by Geyser (talk | contribs) (documenting)
Jump to navigation Jump to search

ANIM file format

All of the .anim files in Oni2 are uncompressed, and store translation, rotation and scaling values as regular IEEE floats. The meaning of each float (whether it is a translation, a rotation or a scaling, what its axis is, and which bone it corresponds to) is described in the .skel file (skeleton) of the mesh: the transforms are parsed in the same order as they appear in the .skel file. The link between the skeleton and the animation is established at the level of the "entity", and is not detailed here.

For rotations, most commonly the full triplet of Euler angles is stored, and for translations the full position vector. For a few UI elements the pose is limited to a rotation around 1 axis (indicated in the .skel file), and therefore a single float is enough to describe the pose. Sometimes a rotation axis is present in the .skel but locked at a fixed value - in that case the keyable values are reduced to the remaining rotation axes. Scaling triplets are present, e.g., for the "Buco" robots.

There is no time compression. The complete pose (i.e., all the keyable translations/rotations/scalings listed in the .skel) is stored for each consecutive frame in the animation (i.e., if the transformation for a bone does not change at all for a certain time range, or during the whole animation, it is stored for each frame anyway). The frame rate is 30 fps.

Apart from the floats (translations and rotations for each pose/frame), each .anim file has a header, which announces, among other things, the number of transforms per frame and the number of frames. The header can be of the following three types:

Offset Type Raw Hex Value Description
0x00 4CC 41 4E 49 31 "ANI1" animation type "ANI1" (example file: kno_atk_comb_bak_bakkckCH.anim)
0x04 bitset 00 00 00 80 0, 0, 0, 128 flags; the following bits occur in the original files (values in hex):
0x01 00 00 00 - unknown
0x00 00 00 80 - has detailed (per-frame) root motion data
0x08 int32 21 00 00 00 33 number of frames
0x0C int32 78 00 00 00 120 number of transforms per frame (must be consistent with the number of keyable values in the .skel file). In this example the skeleton is kno.skel, which has 39 bones; all bones have an XYZ rotation triplet (Euler angles), and the root bone also has an XYZ translation triplet; hence there will be 120 values in total (plus the detailed root motion).
0x10 float BD 97 4D BD -0.0502 total root motion along X (matches the cumulated X values of the detailed root motion track, if any)
0x14 float 00 00 00 00 0.0 total root motion along Y (matches the cumulated Y values of the detailed root motion track, if any)
0x18 float 63 A7 03 BF -0.514 total root motion along Z (matches the cumulated Z values of the detailed root motion track, if any)

Offset Type Raw Hex Value Description
0x00 4CC 61 6E 69 00 "ani"+null animation type "ani" (example file: kno_atk_BLH1_lft_punch.anim)
0x04 bitset 01 00 00 00 1, 0, 0, 0 flag(s); the following bits occur in the original files (values in hex):
0x01 00 00 00 - unknown
0x08 int32 51 00 00 00 81 number of frames
0x0C int32 A2 00 00 00 162 number of transforms per frame (must be consistent with the number of keyable values in the .skel file). In this example the skeleton is the (missing) xkno.skel, which has 53 bones; all bones have an XYZ rotation triplet (Euler angles), and the root bone also has an XYZ translation triplet; hence there will be 162 values in total.
0x10 float 7D 18 7D BD -0.0618 total root motion along X (matches the keyed motion of the root bone)
0x14 float 00 00 00 00 0.0 total root motion along Y (matches the keyed motion of the root bone)
0x18 float 00 00 00 00 0.0 total root motion along Z (matches the keyed motion of the root bone)
0x1C byte 01 1 flag(s); the following bits occur in the original files (values in hex):
0x01 00 00 00 - unknown

Offset Type Raw Hex Value Description
0x00 4CC 00 00 00 00 null chars "short" animation type (example file: kno_BR2H1_HighPunchBackRight.anim)
0x04 int32 51 00 00 00 81 number of frames
0x08 int32 A2 00 00 00 162 number of transforms per frame (must be consistent with the number of keyable values in the .skel file). In this example the skeleton is the (missing) xkno.skel, which has 53 bones; all bones have an XYZ rotation triplet (Euler angles), and the root bone also has an XYZ translation triplet; hence there will be 162 values in total.
0x0C float AA 9D 00 3E 0.126 unknown
0x10 byte 01 1 flag(s); the following bits occur in the original files (values in hex):
0x01 00 00 00 - unknown

Immediately after the header begin the keyed values (floats), grouped by frame: first all the keyed values for frame 0, then for frame 1, etc.

For each frame, the keyed values correspond to the ones listed in the .skel and occur in the same order. The typical order is:

X translation of "root"; Y translation of "root"; Z translation of "root"
X rotation of "root"; Y rotation of "root"; Z rotation of "root"
X rotation of 1st child of "root", typically "spine_01"; Y rotation of "spine_01"; Z rotation of "spine_01"
... XYZ rotation for all the children of "spine_01", in hierarchical order (same as in the .skel)
X rotation of 2nd child of "root", typically "pelvis"; Y rotation of "pelvis"; Z rotation of "pelvis"
... XYZ rotation for all the children of "pelvis", in hierarchical order (same as in the .skel)
Detailed XYZ root motion (if any; can only occur in ANI1 type animation). Stored as single-frame increments.

Rotations are stored as XZY Euler angles (first rotation is around bone's Y, then around the new Z, and finally around the latest X). Angle values are in radians.