AVFX files are organized as a nested series of blocks, with each block following the format:
Name: 4 bytesSize: 4 bytesContents: [Size] bytes
The contents of a block can further contain other blocks. It is also worth noting that the name of a block is reversed from its actual meaning. For example, the "top-level" block for an AVFX file is "XFVA"(AVFX reversed). Names which are fewer than 4 character are also padded out to 4 bytes. Blocks are also padded out to be 4-aligned, so even if
Sizeis 3, there will be an extra
00 before the next block starts.
Note: the names of the blocks are reversed for readability. Also, the notation
TmLn, for example, simply means several sequential
TmLn blocks, one directly after the other. There is no "list" structure in AVFX files.
The structure is also abridged for brevity, the full list of parameters can be found at the link below.
AVFX:Ver: the AVFX version used?...parameters....ScCn: number of schedulers in this file (always 1)TlCn: number of timelinesEmCn: number of emittersPrCn: number of particlesEfCn: number of effectorsBdCn: number of bindersTxCn: number of texturesMdCn: number of modelsSchd: a scheduler blockTmLn: a list of timeline blocksEmit: a list of emitter blocksPtcl: a list of particle blocksEfct: a list of effector blocksBind: a list of binder blocksTex: a list of texture blocksModl: a list of model blocks
Schd:ItCn: item countTrCn: trigger count, always 12Item: a list of itemsTrgr: a list of triggers, always 12 Trgr blocks
Trgr blocks are organized is somewhat unintuitive. Both of them have an identical structure:
Item or Trgr:bEna: enabledStTm: start timeTlNo: timeline index
However, each subsequent
Item/Trgr will have the data of the previous appended to it. For example:
Item:bEnaStTmTlNoItem:bEna : from item #0StTm : from item #0TlNo : from item #0bEnaStTmTlNoItem:bEna : from item #0StTm : from item #0TlNo : from item #0bEna : from item #1StTm : from item #1TlNo : from item #1bEnaStTmTlNo
For this reason, the easiest way to read a list of
Item is to take the last one, and split it into 3-block chunks.
TmLn:...parameters...TICn: number of itemsCpCn: number of clipsItem: list of item blocksClip: list of clip blocks
Timeline items have this structure, and are similar to scheduler items in that each item contains the data of the previous ones as well.
Timeline clips are different in that the data they contain is not organized into blocks, but is rather one continuous 164-byte:
4-byte string, reversed4 4-byte ints4 4-byte floats4 32-byte strings
Emit:SdNm: the path to a sound file (.sdm)...parameters....PrCn: number of particlesEmCn: number of emitters...animation curves...ItEm: list of emitter itemsItPr: list of particles itemsData: depends on the emitter type
The Data block contains information relevant to the emitter's type (specified in the
EVT parameter). Depending on the type, the
Data block may not exist at all (structures).
ItPr blocks share the same basic structure, but follow the same pattern as items and triggers within schedulers, where previous items' data is appended to each subsequent one. However, in an emitter, all of the
ItEm data is included in the
ItPr data. As an example:
ItEm:[ItEm data #0]ItEm:[ItEm data #0][ItEm data #1]ItEm:[ItEm data #0][ItEm data #1][ItEm data #2]ItPr:[ItEm data #0][ItEm data #1][ItEm data #2][ItPr data #0]ItPr:[ItEm data #0][ItEm data #1][ItEm data #2][ItPr data #0][ItPr data #1]
Ptcl:...parameters...UvSN: number of UV Sets...more parameters......animation curves...Smpl: Simple animations (optional)UVSet: a list of UVSet blocksData: depends on particle typeTC1: texture color 1TC2: texture color 2 (optional)TC3: (optional)TC4: (optional)TN: texture normalTR: texture reflectionTD: texture distortionTP: texture palette
Like with emitters, the contents of the
Data block depends on the particle type (parameter
PrVT ). Some particle types do not contain a
Data block (structures).
Smpl block contains 2 unique parameters:
Cols is 16 bytes, where each 4 bytes represent an rgba color (each byte is one channel).
Frms is 8 bytes, where each 2 bytes is an integer.
As with emitters and particles, the
Data block (structures) depends on the type of effector, and may not exist.
Bind:...parameters...PrpS: Start binder propertiesPrp1: binder properties 1Prp2: binder properties 2PrpG: Goal binder propertiesData
Texture blocks are simply paths to
atex files within the game's internal file structure.
The embedded models have 4 possible blocks within them:
VIdx . All 4 of the blocks can be in the same model, however
VEmt are always paired, as are
This is a list of 2-byte integers, where each 3 integers represents a triangle in the model. The integers themselves are the indexes of vertices within
VDrw is a list of vertices, where each vertex is 36 bytes long with the following format:
4 2-byte floats: position4 1-byte ints: normal4 1-byte ints: tangent4 1-byte ints: color4 2-byte floats: uv14 2-byte floats: uv2
This is a list of 28-byte vertices, with the following format:
3 4-byte floats: position3 4-byte floats: normal4 1-byte ints: color
This is a list of 2-byte integers, where each integer corresponds to a vertex in
VEmt (so the length of elements in
VNum always equals the number in
Curves have the following structure:
The name of a curve varies, but some examples are
SclA , etc. They are used to animate motion over time.
Keys is a single block which contains the information on the shape of the curve. Every 16 bytes in
Keys corresponds to a single keyframe, with the following format:
2-byte integer: time2-byte integer: type4-byte float: X4-byte float: Y4-byte float: Z