Hierarchies are skeletons. Without them your body would be some lopsided floppy abomination. Yummy!
Hierarchy Format
Limb Format
The format of a limb in a hierarchy is as follows: XXXX YYYY ZZZZ CC SS OO OOOOOO
Where:
XXXX - X Location of limb relative to limb's parent.
YYYY - Y Location of limb relative to limb's parent.
ZZZZ - Z Location of limb relative to limb's parent.
CC - Child of limb (FF if no child)
SS - Sibling of limb (FF if no sibling) (limbs can have multiple siblings by using siblings of siblings) (rotation/location of each sibling is relative to the parent of all siblings)
OO OOOOOO - Four bytes for the Display List to use for the limb, where the first byte is the bank and the latter three are the offset of the Display List. For Link's hierarchy, this repeats a second time for Link's corresponding high poly Display List.
Limb Table
Immediately following the list of limbs that use the limb format described above, there is a table of values that point to the offset of each of the above limbs in order. There are four bytes per pointer: one for the bank and the latter three for the offset of the limb relative to the start of the file.
Following this table is a four-byte pointer to the start of the table. The location of this pointer within the file is the start of the hierarchy table. This is the offset that is referenced by .zactor files. For example, the four bytes are located at 0x7FB8 in object_md.zobj, and they are 06 00 7F 78, so the start of the hierarchy table is 0x7F78 and the hierarchy offset is 0x7FB8.
The byte immediately following this pointer is the number of limbs within the hierarchy. This is 0x10 in object_md.zobj, for example.
There are then three 00 bytes.
The final byte is the number of limbs that have a Display List. If this is not correct, graphical errors will occur, such as the geometry being connected to other actors on the map. This is 0x0F in object_md.zobj, for example.
Pointers within .zactor files.
Hierarchy pointers are hard-coded into .zactor files via assembly. There is usually an
LUI instruction that loads the first two bytes of the hierarchy offset into a register. A few instructions later, there is usually an
ADDIU instruction that loads the last to bytes of the hierarchy offset into the same register. If the offset is 0x8000 or more, 0x1 must be added to the second byte of the first half in the LUI instruction.
For example, if you open object_md.zobj in Hylian Toolbox, the hierarchy offset is 0x7FB8. Make that be six bytes. 0x007FB8. Now add the bank (always 06 for .zobj files). 06007FB8. Separate these into two groups of two bytes. 0600 7FB8. Is 7FB8 greater than or equal to 0x8000? No. If it were, however, 0600 would be 0601.
If you edited object_md.zobj and the new hierarchy was located at 0x21F78, you would first make it be six bytes (021F78) and then add the bank to get 06021F78. You separate these to get 0602 1F78. Because 0x21F78 is greater than or equal to 0x8000, however, you must add 0x1 to the second byte of 0602 to get 0603.