ANCS (File Format)

Revision as of 23:37, 11 April 2015 by imported>Antidote (extra '=')

The ANCS format defines characters for animation in Metroid Prime 1 and 2. Starting in Metroid Prime 3, it was replaced by the CHAR format. The extension stands for ANimation Character Set.


To do:
Notate Metroid Prime 2 differences.
This file format needs a lot of research
Most of the file structure is known, but we still don't know what any of it actually is! Also, the table at the end of the file is unknown.


Header

The ANCS format is split up into multiple nodes. Each node defines a character - a model, a skeleton, and a skin - and then sets a number of animation-related parameters on each one. At the end of the file, after every node, is a listing of ANIM and EVNT files.

There's a very short 8-byte header before the nodes begin.

Offset Size Description
0x0 2 Unknown; always 1
0x2 2 Unknown; always 1 (maybe actually one 32-bit magic?)
0x4 4 Node count
0x8 Nodes begin

Nodes

Type Count Description
u32 1 Node number; starts at 0, increases by 1 on each subsequent node
u16 1 Flags? This value can alter the structure of the file. Usually 6.
string 1 Node name (zero-terminated)
CMDL 1 Model
CSKR 1 Skin
CINF 1 Skeleton
u32 1 Animation count

This struct then repeats animation count times:

Type Count Description
u32 1 Animation number; starts with 0, increases by 1 on each subsequent animation
u8 1 Unknown; usually 0
string 1 Animation name (zero-terminated)

PAS Database

The next part of the file is the PAS Database, which creates animation states and sets parameters on them. The PAS Database header is structured:

Offset Size Description
0x0 4 "PAS4" magic fourCC
0x4 4 Anim state count
0x8 4 Default state (will be 0xFFFFFFFF on files with no anim states)

Anim State

Type Count Description
u32 1 Unknown
u32 1 Parm Info count (PC)
u32 1 Anim Info count (AC)
Parm Info PC Parm Info
Anim Info AC Anim Info
Parm Info
Type Count Description
u32 1 Parm Type; enum ranging from 0 to 4, see below for possible values
u32 1 Unknown
float 1 Unknown
ParmType 2 Parms

These are the possible types that can be specified by Parm Type:

Value Size Type
0 4 s32
1 4 u32
2 4 float
3 1 bool
4 4 enum
Anim Info

The Anim Info structure is a little unorthodox. It starts with an unknown 32-bit value, and then is followed by a set of values. There's one value present per Parm Info instance, and the type of each value corresponds to that Parm Info's Parm Type setting.

Particles

Note: if the flag value at the start of the node is 5 instead of 6, one of these values is missing. It's currently not known specifically which one it toggles, so be careful. However if the value is 10 the data is from Metroid Prime 2 and special attention must be paid in order to properly read the information.

Type Count Description Notes
u32 1 Particle count (PC)
PART PC Particle file IDs
u32 1 Swoosh particle count (SC)
SWHC SC Swoosh particle file IDs
u32 1 Unknown
u32 1 Electric particle count (EC)
ELSC EC Electric particle file IDs
u32 1 Unknown
u32 1 Unknown Only in Metroid Prime 2
u32 1 Unknown Only in Metroid Prime 2

Animations

This section begins with a 32-bit count value, then this struct repeats:

Type Count Description
string 1 Animation name
float 6 Unknown; possibly an AABB

Effects

This section is used for effect placement - binding particles to bones, which is used for things like Space Pirate eye fire. It starts with a 32-bit count value, then this struct repeats:

Type Count Description Notes
string 1 Effect name
u32 1 Unknown
string 1 Effect name 2 Metroid Prime 1 only
u32 1 Unknown Metroid Prime 2 only
char 4 "PART" fourCC
PART 1 Particle file ID
string 1 Bone name
float 1 Unknown
u32 1 Unknown
u32 1 Unknown

Footer

The end of the node structure contains this data:

Type Count Description Notes
CMDL 1 Unknown model
CSKR 1 Unknown skin
u32 1 Action ID Count (AC)
u32 AC ActionIDs
u32 1 Unknown Only in Metroid Prime 2
u8 1 Unknown bool? Only in Metroid prime 2

Metroid Prime 2 Unknown Struct

Immediately following the the footer is a second count/struct pair that only appears in Metroid Prime 2, it is currently unknown what purpose this serves. The count is a 32bit integer and is directly followed by an array of the following struct:

Type Description
u32 Action ID
CAABox Unknown