Character Battle Models

As they exist on the game CD, Chrono Cross character battle models consist of applicable textures followed by the model geometry itself. The model data begin with a header that points to various sections, and the sections have their own subheaders and subsections.

Below, the model format is detailed byte-by-byte. Keep in mind that all data in PSX games are represented in "Little Endian" Mode, meaning we humans must employ a byte-order reversal technique to understand it. For example, 06 00 00 00 means 0x06, and F8 4E 00 00 means 0x4EF8.

Also keep in mind that offset ranges are relative, meaning pointer tables report locations that are are a certain number of bytes from the beginning of the current header/subheader. This makes no difference in the overall file header when you're looking at the model data file as excised from the game CD, but it most certainly affects the correct interpretation of subheaders.

Overall Structure[edit]

A general overview of how a given battle model's various sections fit together:

MODEL HEADER
*Section 1
  Section 1 Header
   "Constructs"
    UV Map
    Vertex Pool
    VDDM (Vestigial Data that Doesn't Matter)
*Section 2 (Skeleton)
  Section 2 Header
  Skeletal Units
*Section 3 (Yet Uknown; affects model shading and placement on the battlefield)
*Section 4 (Animations)
*Section 5 (Uknown)

MODEL HEADER[edit]

#S #S #S #S S1 S1 S1 S1 - S2 S2 S2 S2 S3 S3 S3 S3
S4 S4 S4 S4 S5 S5 S5 S5 - S6 S6 S6 S6 EF EF EF EF
  Where...
  #S = Number of Sections in the model.
  S1 = Starting Offset of Section 1.
  S2 = Starting Offset of Section 2.
  S3 = Starting Offset of Section 3.
  S4 = Starting Offset of Section 4.
  S5 = Starting Offset of Section 5.
  S6 = Starting Offset of Section 6 (usually set to zero, making it de facto nonexistent).
  EF = End of File address.

Section 1[edit]

Section 1 is composed of a number of units we'll call "Constructs" for lack of a better term at the moment. Each "Construct" apparently ties together parts of the model's UV Map, Vertex Pool, the VDDM, and the skeleton defined in Section 2.

Section 1 Header

#C #C #C #C C1 C1 C1 C1 - C2 C2 C2 C2 ... 
?? ?? ?? ?? ?? ?? ?? ??
  Where...
  #C = Number of Constructs
  C1 = Starting Offset of the First Construct, relative to the beginning of Section 1.
  C2 = Starting Offset of the Second Construct, relative to the beginning of Section 1.
  ... = More starting offsets of additional Constructs, relative to the beginning of Section 1.
  ?? = There are four bytes of data that may be a checksum, followed by an additional four 
       bytes of unknown purpose.

Constructs
Each construct consists of a Header followed by 8-byte mode vertex assignments, 16-byte mode vertex assignments, and a UV Footer.

Construct Header:
  UM UM UM UM VP VP VP VP - VD VD VD VD 
  Where...
  UM = Offset into the UV Map, relative to the beginning of Section 1; 
       start grabbing texture pieces here.
  VP = Offset into the Vertex Pool, relative to the beginning of Section 1; 
       start grabbing vertices here.
  VD = Offset into unknown Vestigial Data (the VDDM) that can be zero'd out
       with absolutely no effect on the model.

8-byte mode vertex assignment header format: #A #A #A #A VO VO VO VO
8-byte mode vertex assignment format: NV NV JJ JJ
   Where...
   #A = Number of assignments that follow.
   VO = Offset into the Vertex Pool, relative to the VP offset given in the Construct Header.
   NV = Next NV Vertices are assigned to JJ JJ.
   JJ =Index of the joint to which the body of vertices is assigned.

16-byte mode vertex assignment header format: #A #A #A #A VO VO VO VO
16-byte mode vertex assigment format: NV NV 00 00 J1 J1 W1 W1 J2 J2 W2 W2
   Where...
   #A = Number of assignments that follow.
   VO = Offset into the Vertex Pool, relative to the VP offset given in the Construct Header.
   NV = Next NV Vertices are assigned to J1 J1 and J2 J2.
00 00 = Buffer bytes that are apparently always zero'd. If more than FF FF vertices are
        assigned, they might come into play, but this should be extremely rare.
   J1 = Index of the first joint to which the body of vertices is assigned.
   W1 = Weight of the association between NV and J1 for animation purposes.
   J2 = Index of the second joint to which the body of vertices is assigned.
   W2 = Weight of the association between NV and J2 for animation purposes.

UV Footer: This tells the game engine where to look in the UV Map for the triangles and quads 
assigned to each construct.
   #E #E #E #E TQ TQ ## ## UO UO UO UO...
   Where...
   #E = Number of 8-byte entries.
   TQ = First two bytes in the 8-byte entry. If it's set to 0x24, the next bytes refer to
        triangles; if set to 0x2C, the next bytes refer to quads.
   ## = Number of quads or triangles assigned to the Construct.
   UO = UV Map offset from which to start pulling the triangles or quads. 
        Relative to the UM offset given in the construct header.
  ... = More TQ, ##, and UO information for each additional entry.

UV Map
This part of Section 1 defines how the model texture is split into pieces and wrapped around the 3D structure. It lacks a header, but is split up into distinct Triangle and Quad sections that alternate according to the specifications of the preceding Constructs.

Triangle UV data and pointer setup: U1 V1 U2 V2 U3 V3 P1 P1 - P2 P2 P3 P3
  Quad UV data and pointer setup:     U1 V1 U2 V2 U3 V3 U4 V4 - P1 P1 P2 P2 P3 P3 P4 P4
   Where... 
   U? V? are pixel coordinates on the model texture; top-left corner is 0, 0.
   P? P? are pointer values that tell the game engine which polygon the texture piece is 
         applied to.

Rules for interpreting quad pointers...
Rule for Positive Pointers (as interpreted in hexadecimal)
*If you're reading one of the first two pointers, divide the byte pair value by 0x2, then by
  0x8. This value is the index for the vertex to which the UV point is mapped.
*If you're reading one of the last two pointers, divide the byte pair value by 0x8. This value 
  is the index for the vertex to which the UV point is mapped.
*Texture Page Rule...
**If the first two vertex pointers end in a "1" instead of a "0" nybble, then
  the texture piece is pulled from the RIGHT texture. 
**If the first two vertex pointers end in a "0" instead of a "1" nybble, then 
  the texture piece is pulled from the LEFT texture.


Rule for Negative Pointers (as interpreted in hexadecimal)
*If you're in one of the first two columns, divide the byte pair value by 0x10. Go backward 
 that number of positions into the pointer data.
*If you're in one of the last two columns, divide the byte pair value by 0x8. Go backward that
 number of positions into the pointer data.
*Texture Page Rule...
**If the first two vertex pointers end in a "1" instead of a "0" nybble, then
  the texture piece is pulled from the RIGHT texture. 
**If the first two vertex pointers end in a "0" instead of a "1" nybble, then 
  the texture piece is pulled from the LEFT texture.

Rules for interpreting triangle pointers...
 For triangles, switch pointers such that the first UV coordinate gets the second pointer; the 
 second UV coordinate gets the third pointer; the third UV coordinate gets the first pointer. 
 The pointers retain the division properties they had in their original positions.

Rule for Positive Pointers (hex)
*If you're reading the first pointer, divide the byte pair value by 0x8. This value is the 
 vertex index.
*If you're in one of the last two columns, divide the byte pair value by 0x2, then by 0x8. This 
 value is the vertex index.
*Texture Page Rule...
**If the last two vertex pointers end in a "1" instead of a "0" nybble, then
  the texture piece is pulled from the RIGHT texture. 
**If the last two vertex pointers end in a "0" instead of a "1" nybble, then 
  the texture piece is pulled from the LEFT texture.

Rule for Negative Pointers (hex)
*If you're reading the first pointer, divide the byte pair value by 0x8. Go backward that 
 number of positions into the pointer data, adding an invisible position to the three extant 
 positions.
*If you're in one of the last two columns, divide the byte pair value by 0x10. Go backward that 
 number of positions into the non-UV data, adding an invisible position to the three extant 
 positions.
*Texture Page Rule...
**If the last two vertex pointers end in a "1" instead of a "0" nybble, then
  the texture piece is pulled from the RIGHT texture. 
**If the last two vertex pointers end in a "0" instead of a "1" nybble, then 
  the texture piece is pulled from the LEFT texture.

Vertex Pool
This part of Section 1 defines the 3D structure of the model's arms, legs, etc. It lacks a header, but is split up into distinct 8-byte mode and 16-byte mode sections that alternate according to the specifications of the preceding Constructs. Note that the coordinate byte pairs should be read as signed 16 bit, fixed point 4.12 numbers.

  "8-byte mode" setup...
   ZZ ZZ YY YY XX XX 00 00 - ZZ ZZ YY YY XX XX 01 00
   ZZ ZZ YY YY XX XX 02 00 - ZZ ZZ YY YY XX XX 03 00
  "16-byte mode" setup...
   ZZ ZZ YY YY XX XX 00 00 - ZZ ZZ YY YY XX XX 00 00
   ZZ ZZ YY YY XX XX 01 00 - ZZ ZZ YY YY XX XX 01 00
    Where...
    ZZ: Magnitude of coordinate on the up & down axis on the screen plane
    YY: Magnitude of coordinate on depth axis; toward or away from you with respect to the 
        screen.
    XX: Magnitude of coordinate on right & left axis on the screen plane
 00 00: The vertex index; two bytes per vertex. They progress from 00 00 to 01 00, and so on.

    16-byte mode appears to come into play when a vertex is associated with more than one bone.
    * The first eight bytes represent the vertex's location relative to the first bone it is 
      associated with.
    * The second eight bytes represent the vertex's location relative to the second bone it is 
      associated with.

VDDM: Vestigial Data that Doesn't Matter
Section 1 ends with a curious string of bytes that is mathematically related to the number of vertices, but which does not have an apparent purpose. It can be safely zero'd out (bytes converted to all 00s) with absolutely no detectable effect on the model.

Format: Four-byte stride, the fourth byte always being 00.
 ?? ?? ?? 00 ?? ?? ?? 00 - ?? ?? ?? 00 ?? ?? ?? 00
 ?? ?? ?? 00 ?? ?? ?? 00 - ?? ?? ?? 00 ?? ?? ?? 00

Section 2[edit]

This is the model's "skeleton," so to speak. Bone lengths are not specified in the model structure, but rather can be inferred from the 3D coordinates given to each joint. Each "bone" consists of a parent joint and a "current joint" to which the 3D coordinates and the rotational data apply.

Section 2 Header

 NB NB NB NB 
 Where NB = Number of Bones


Bone Format

PJ PJ PJ PJ XR XR YR YR - ZR ZR XC XC YC YC ZC ZC 
BI BI BI BI
 Where... 
 PJ = Index of parent joint (0xFFFF, or -1 if this bone has no parent joint) 
 XR = X rotation (range: 0XF000 ~ 0xFFF, or -4096 to 4095, where 4096 = 360 degrees) 
 YR = Y rotation (range: 0XF000 ~ 0xFFF, or -4096 to 4095, where 4096 = 360 degrees) 
 ZR = Z rotation (range: 0XF000 ~ 0xFFF, or -4096 to 4095, where 4096 = 360 degrees) 
 XC = X coordinate in 3D space relative to parent joint 
 YC = Y coordinate in 3D space relative to parent joint 
 ZC = Z coordinate in 3D space relative to parent joint 
 BI = Current bone index (0xFFFF, or -1 if current joint and parent joint do not form a bone)

Section 3[edit]

Section 4[edit]

Section 5[edit]

SPECIAL THANKS: To Gemini for identifying the battle textures that led us to the models; to Luminaire85 for finding and interpreting the headers and subheaders, fine-tuning various theories, and coding the model viewer; to MDenham for figuring out how the pointers and Section 1-1 work; to Halkun, Cyberman and yaz0r for providing constant advice and guidance; and to jono for making sure this wiki entry makes sense.

From: Chrono Cross File Structure