Pose mixer and the character file the battle loads

Why the rebuild’s jump shows the wrong arms. Read from PDUWP.exe 1.3.25854.2 and the character files; proof tool converter/charpose.py (structs for the joint and animation chunk records, the chain below in Python; synthetic test converter/tests/test_charpose.py).

Result. The engine does nothing to the arm joints after the evaluator. The rebuild plays the right slots through the right maths on the wrong file: the protagonist was converted from <name>.alr, and the battle never loads that file. It loads <name><variant>.alr, which has another skeleton and other animation data in most slots.

1. Which file a character loads (H: code, charaset values, file contents)

protagonist plain file (what the rebuild converted) variant files (what the game loads)
animation slots 129 130 (slot 129: 1 frame, 28 joints)
joints, model 0 / model 1 101 / 23 115 / 23
leading placeholder joints 6, root = joint 6 20, root = joint 20: every body joint index is 14 higher (hips 8 → 22, right hand 38 → 52, head 57 → 71)
animated joints per slot 27 27 (the same named joints)
slots whose keys differ by ≥ 2° on a same-named joint 110 of 129; equal: 1, 12, 17, 18, 20, 56–60, 62, 71, 79, 103, 105, 106, 108, 111, 128

Slot lengths that differ (slot: plain → variant, frames): 3: 24 → 23, 4: 79 → 100, 6: 31 → 32, 8: 50 → 51, 10: 20 → 28, 11: 36 → 28, 13: 36 → 37, 15: 14 → 19, 16: 25 → 19, 19: 25 → 26, 22: 48 → 49, 24: 40 → 42, 27: 25 → 26, 29: 35 → 36, 34: 15 → 13, 35: 11 → 12, 36: 11 → 12, 42: 30 → 31, 43: 31 → 32, 44: 30 → 32, 47: 13 → 14, 50: 40 → 56, 51: 35 → 40, 52: 21 → 22, 53: 55 → 60, 54: 40 → 35, 55: 21 → 22, 78: 15 → 60, 95: 45 → 44. Two other playable models checked the same way: 14 and 19 slots of another length, 129 against 130 slots.

Corrections to earlier sections (they describe the plain file): “Skeleton (0x3)” (101 + 23 joints, placeholders 0–5), “Character animations (0x5)” (129 slots, root joint 6), “The evade” and “Movement animations” where a number comes from a slot length (the protagonist’s “up” is 13 frames: 13 / (vy / g) = 1.32 frames per tick, not 15 and 1.52; “down” and the evade landing are 12 frames, so the landing state lasts 11 ticks, not 10). The slot numbers, tables, rules and rates in those sections stand.

2. From the evaluator to the skinning matrices (H in code unless marked)

The character object keeps one pose mixer at +0x940 (init 0x140196d20; the bosses use the same class). Layout:

off content
+0x00, +0x38, +0x70, +0xA8 four layers of 0x38 bytes
layer +0x00 flags: 1 active, 2 loop, 4 weight frozen
layer +0x08 / +0x10 animation slot data / the model’s skeleton chunk
layer +0x18 frame (float)
layer +0x20 / +0x28 evaluator output (16 bytes per keyed channel, in chunk order) / key cursors
layer +0x30 / +0x34 weight step per mixer run / weight
+0xE0, +0xE8 model data, skeleton chunk
+0xF0, +0xF8 hook context, per-joint hook
+0x100, +0x110 matrix array (64 bytes each; entry 0 is the base, joint j is entry j + 1), joint count + 1

Joint record (0x40 bytes, skeleton chunk + 0x10; charpose.py Joint): +0x00 position, +0x0C rotation (radians, x y z), +0x18 scale, +0x24 u16 flags, +0x26 u16 index, +0x2A s16 parent, +0x2C u32 name id (six characters packed base 40), +0x3C s32 hook kind (written at run time). Flag 0x100 marks a named joint, 0x1 the root; 0x200 swaps in a global matrix (no joint of the playable model has it). The other bits (0x2, 0x10, 0x20, 0x400) are not read by the mixer.

The steps, in order:

  1. Play (0x140297d80, from the player’s play routine 0x140257310). Blend ≤ 0: all four layers are cleared and layer 0 starts at weight 1. Blend t > 0: a layer already holding the slot is dropped; every other active layer gets step −1/t; the new slot takes a free layer (the first active one if none is free) with weight 0 and step +1/t.
  2. Tick (0x140257510): only the current layer’s frame advances (by the play’s rate). Fading layers keep the frame they had: a cross-fade is from a frozen pose. A layer that is not looped stops at length − 0.01.
  3. Evaluate each active layer (0x140296ce0, “Key evaluation”).
  4. Mix (0x140298020), per mixer run: each layer’s weight += its step; at ≤ 0 the layer is switched off, at ≥ 1 it stays 1; the weights are divided by their sum. Then per joint, over the active layers: translation and scale are weighted sums; the rotation starts at identity and is slerped toward each layer’s quaternion by w / (sum of the weights so far), shortest way (0x14028ed60 negates on a negative dot product; linear when 1 − dot ≤ a small constant). A layer without a chunk for the joint, or without that channel, contributes the joint’s bind value (the bind rotation through the same quaternion builder).
  5. Matrix: quaternion → rotation matrix (the standard form, row vectors), then world = parent · T · R · S with the parent’s matrix taken from the array (parents come first; parent −1 is the base matrix).
  6. Hooks, only for joints with flag 0x100 and only when the character installed its hook (0x14025dc20, set up by 0x14025d380): hook kind 0 and 1 are the neck and head look twists (0x14025dc40, 0x14025dde0: yaw and pitch toward a target, clamped, turned at 0x1C7 angle units per tick; active only while the character’s look flag at +0x210 is set); kind 2, the root, copies the base matrix’s x and z into the root’s matrix (the root’s own ground-plane motion is not drawn: the animation plays in place); every other named joint: nothing. The setup also stores matrix pointers for both hands, the body, the alpha and camera joints and the attach slots (readers only).
  7. The matrices go to the skin palettes as they are.

No step touches the shoulders, arms or hands: no IK, no aim twist, no upper/lower body mask, no additive layer, no joint remap. Quaternion order and sign conventions are the ones pdconv already uses (q = qz · qy · qx, i.e. R = Rz · Ry · Rx). Not followed: the two look twists’ target and clamps in detail (M), the three-point routine 0x14025dab0 (one caller, 0x1402609af), flag 0x200’s global matrix.

3. The arms in the evade jump, game chain against the rebuild’s data

Both columns are the chain of section 2 (charpose.py pose), which for one layer is what pdconv exports; the only difference is the file. Model units (12 per metre); hand height is relative to the head joint, “side” is the hand’s distance from the head sideways.

slot, frame plain file (rebuild): left / right hand height, side variant file (game): height, side
34 “up”, start −6.4 / −5.4, 3.6 / 3.5 −6.4 / −5.3, 3.4 / 3.6
34, middle (7 of 15 / 6 of 13) −1.6 / −1.5, 4.4 / 5.0 −5.0 / −5.2, 2.9 / 3.0
34, end (14 / 12) +4.1 / +4.1, 5.0 / 5.1 0.0 / +1.0, 1.5 / 1.1
35 “down”, start +4.2 / +3.9, 4.9 / 5.3 +0.5 / +1.5, 1.3 / 1.0
35, middle (5 / 4) +0.6 / +0.5, 6.6 / 6.8 +0.8 / +1.1, 1.9 / 0.8
35, end (10 / 11) +0.7 / +1.0, 6.8 / 7.1 +1.6 / +2.4, 1.9 / 2.1

Joint rotations differ the same way, e.g. the left upper arm’s keys (x, y, z degrees) at the end of “up”: plain −22, −39, 33; variant 29, 60, −55; the left forearm in the middle of “down”: plain 0, 55, 0 (one axis in every frame); variant 85, 63, 86.

In words: in the game’s file the hands stay low for the first half of the rise, come up to the head by the top and stay on the head, elbows out, through the fall. In the plain file the arms swing up from the middle of the rise to well above the head and then spread wide at head height. That is the playtester’s “arms up on every jump”.

Footage (H for Xbox): the jumparms strip of the Xbox reference (tutorial jump, 21 frames) shows arms down in ticks 0–6, hands going to the head from tick 8 and held there to the landing, then a crouch. This is the variant file’s 34 / 35 / 36, not the plain file’s. PC footage of a jump was not looked at in this run; the PC executable and files are what was read. A long fall holds the end of “down” (hands on the head, as above).

Implementation notes for the rebuild

  1. Convert <name><variant>.alr for every character (variant 0 for the animations; all four when the colour variants are wanted). Never the plain file. The data command and main.gd’s character ids change with it.
  2. Re-derive everything that was read off the plain file: joint indices in code (root 6 → 20, hips 8 → 22, right hand 38 → 52; effect attach joints, root_bone_of checks), slot lengths baked into timings (rise rate, the evade landing’s ticks, cast profiles that count a slot’s frames), the renders described in “Movement animations”, and the tests that pin 129 slots or 101 joints. Rerun check_anim_keys.py on the variant file.
  3. No change to the playback maths. Keep the slot choice and rates. Do not add a fall-height rule, an arm mask or a pose fix.
  4. Blend like the mixer when the rebuild’s blends are next touched: at most four layers; a new play with blend t fades every older layer by 1/t per tick and itself in by 1/t; older layers are frozen at their frame; weights normalised; rotations slerped the short way; a joint a layer does not key uses its bind value. A cut clears all layers.
  5. Hooks: draw the root joint at the body’s x and z (already so: the root track is dropped). The neck and head look twists are a separate, small decode (section 2, step 6) before they are built.
  6. After the conversion compare a standing evade with the Xbox strip frame for frame; the ledger row can go to DECODED when the hands match.