Difference between revisions of "ANIM (File Format)"

From Retro Modding Wiki
Jump to: navigation, search
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{research|1|Having trouble with bone rotations +/- 180 degrees in format 2}}
+
The '''ANIM''' format is used to represent discrete [[wikipedia:Key frame|animation keys]]
The '''ANIM format''' is used in conjunction with the [[CINF (File Format)|CINF]] and [[CSKR (File Format)|CSKR]]
+
bound to a skeletal rig.
to animate rigged [[CMDL (File Format)|CMDL meshes]].
+
  
There are two versions of the ANIM format in ''Metroid Prime'' (indicated by the file's first long value):
+
Keyed attributes include:
  
{| class="wikitable"
+
* [[wikipedia:Quaternion|Quaternion]] Rotations (WXYZ)
!Version
+
* Translations (XYZ)
!Description
+
* Scale (XYZ, since MP2)
|-
+
|0x0
+
|[[#Quaternion Array Format|Quaternion Array Format]]
+
|-
+
|0x2
+
|[[#Rotation Vector Bitstream Format|Rotation Vector Bitstream Format]]
+
|}
+
  
== Quaternion Array Format ==
+
ANIMs are used in a variety of ways by Retro's engine. A single ANIM resource is known as
 +
a ''primitive'' which may be blended and/or sequenced with other primitives to assemble
 +
complex character animations (defined by [[ANCS (File Format)|ANCS]] and [[CHAR (File Format)|CHAR]]).
  
The '''Quaternion Array Format''' (0x0) is a less common animation format in ''Metroid Prime''.
+
Each game has deviations in the format, but the principle of operation remains the same for all of them:
It's only used in a ''Ridley'' intro animation and the rotating ''pirate data'' artifact hologram
+
above the Impact Crater.
+
 
+
The format maps animation channels to bones and supplies rotations as an array of [[wikipedia:Quaternion|quaternion]] (WXYZ) keys.
+
Optionally, translations may be specified for a subset of bones as an array of float3 keys.
+
 
+
{| class="wikitable"
+
!Data Type
+
!Element Count
+
!Identifier
+
!Notes
+
|-
+
|[[#Header0|Header0]]
+
|1
+
|header
+
|
+
|-
+
|char
+
|header‑>bone_entry_count
+
|bone_entry_map
+
|The index-positions of this table correspond to the ''bone ids'' in the associated [[CINF (File Format)|CINF]]. The value is 0xff if the bone is not animated by this ANIM or an index relating the ''bone_translation_map'' and ''quaternion_key_array'' below
+
|-
+
|long
+
|1
+
|bone_channel_count
+
|Count of bone channels present in the ''bone_translation_map'' and ''quaternion_key_array'' below
+
|-
+
|char
+
|bone_channel_count
+
|bone_translation_map
+
|Each bone channel may be optionally augmented with translation vectors at the bottom of the file. The index-positions of this table correspond to the values in the ''bone_entry_map'' above. The value is 0xff if the bone is not translated by this ANIM or an index relating the ''quaternion_key_array'' below
+
|-
+
|long
+
|1
+
|quaternion_key_count
+
|Count of elements in ''quaternion_key_array'' below
+
|-
+
|float4
+
|quaternion_key_count
+
|quaternion_key_array
+
|The quaternion keys are interleaved like such (bone-major):
+
<pre>
+
|------------|------------|-----|------------|
+
| bone0/key0 | bone0/key1 | ... | bone0/keyN |
+
| bone1/key0 | bone1/key1 | ... | bone1/keyN |
+
| .......... | .......... | ... | .......... |
+
| boneN/key0 | boneN/key1 | ... | boneN/keyN |
+
|------------|------------|-----|------------|
+
</pre>
+
|-
+
|long
+
|1
+
|translation_key_count
+
|Count of elements in ''translation_key_array'' below
+
|-
+
|float3
+
|translation_key_count
+
|translation_key_array
+
|The translation keys are interleaved like such (bone-major):
+
<pre>
+
|------------|------------|-----|------------|
+
| bone0/key0 | bone0/key1 | ... | bone0/keyN |
+
| bone1/key0 | bone1/key1 | ... | bone1/keyN |
+
| .......... | .......... | ... | .......... |
+
| boneN/key0 | boneN/key1 | ... | boneN/keyN |
+
|------------|------------|-----|------------|
+
</pre>
+
Any bone channels that were marked 0xff in the ''bone_translation_map'' are skipped by this array
+
|-
+
|long
+
|1
+
|evnt_ref
+
|ID for this ANIM's [[EVNT (File Format)|EVNT]] resource, or 0xffffffff if no events triggered
+
|}
+
 
+
=== Header0 ===
+
 
+
{| class="wikitable"
+
!Offset
+
!Length
+
!Data Type
+
!Identifier
+
!Notes
+
|-
+
|0x0
+
|4
+
|float
+
|duration
+
|Time in seconds that the animation plays for
+
|-
+
|0x4
+
|4
+
|float
+
|key_interval
+
|Time in seconds between keys of each bone channel (reciprocal of frame-rate)
+
|-
+
|0x8
+
|4
+
|long
+
|bone_entry_count
+
|Count of bone-channels in animation
+
|-
+
|0xC
+
|4
+
|long
+
|key_count
+
|Count of keys for each bone channel (keys are set for every frame of the animation)
+
|}
+
 
+
== Rotation Vector Bitstream Format ==
+
 
+
The '''Rotation Vector Bitstream Format''' is the most widely used animation format in ''Metroid Prime''.
+
The format uses a compressed [[wikipedia:Bitstream|bitstream]] to store keys that have been
+
[[wikipedia:Delta encoding|delta encoded]] and [[wikipedia:Quantization (signal processing)|quantized]]
+
to make for a very compact, compressed animation. The data is processed sequentially to reconstruct the
+
decompressed bone channel data.
+
 
+
In addition to the bitstream quantization, the format includes a bitmap specifying which frames of the animation have
+
keys added. Consequently, the runtime constructs missing keys via interpolation (reducing animation size further).
+
 
+
=== Header2 ===
+
 
+
{| class="wikitable"
+
!Offset
+
!Length
+
!Data Type
+
!Identifier
+
!Notes
+
|-
+
|0x0
+
|4
+
|long
+
|scratch_size
+
|Amount of memory that the animation system needs to allocate to process animation
+
|-
+
|0x4
+
|4
+
|long
+
|evnt_ref
+
|ID for this ANIM's [[EVNT (File Format)|EVNT]] resource, or 0xffffffff if no events triggered
+
|-
+
|0x8
+
|4
+
|long
+
|unknown0
+
|Always 0x1
+
|-
+
|0xC
+
|4
+
|float
+
|duration
+
|Time in seconds that the animation plays for
+
|-
+
|0x10
+
|4
+
|float
+
|interval
+
|Time in seconds between keys of each bone channel (reciprocal of frame-rate)
+
|-
+
|0x14
+
|4
+
|long
+
|unknown1
+
|Always 0x3
+
|-
+
|0x18
+
|4
+
|long
+
|unknown2
+
|Always 0x0
+
|-
+
|0x1C
+
|4
+
|long
+
|rotation_divisor
+
|Rotation vectors are divided by this value before being applied
+
|-
+
|0x20
+
|4
+
|float
+
|translation_multiplier
+
|Translation vectors are multiplied by this value before being applied
+
|-
+
|0x24
+
|4
+
|long
+
|bone_channel_count
+
|Count of bone channels present in ANIM
+
|-
+
|0x28
+
|4
+
|long
+
|unknown3
+
|Always 0x1
+
|-
+
|0x2C
+
|4
+
|long
+
|key_bitmap_length
+
|Number of bits in ''key bitmap''
+
|}
+
  
 +
* [[ANIM (Metroid Prime)]] (used in Metroid Prime 1 and 2)
 +
* [[ANIM (Metroid Prime 3)]]
 +
* [[ANIM (Donkey Kong Country Returns)]]
 +
* [[ANIM (Tropical Freeze)]]
  
 
[[Category:File Formats]]
 
[[Category:File Formats]]

Latest revision as of 19:50, 5 May 2016

The ANIM format is used to represent discrete animation keys bound to a skeletal rig.

Keyed attributes include:

  • Quaternion Rotations (WXYZ)
  • Translations (XYZ)
  • Scale (XYZ, since MP2)

ANIMs are used in a variety of ways by Retro's engine. A single ANIM resource is known as a primitive which may be blended and/or sequenced with other primitives to assemble complex character animations (defined by ANCS and CHAR).

Each game has deviations in the format, but the principle of operation remains the same for all of them: