Difference between revisions of "FF9/File/0x02"

From Final Fantasy Inside
< FF9
Jump to navigation Jump to search
my_wiki>Zidane
my_wiki>Zande
Line 1: Line 1:
Model begins with 4-byte header:
+
'''3D Model Header'''
  
 +
Global header for the 3D model, one per model.<br />
 +
Size: 20 bytes
  
1: 00    (1-st model byte)
 
  
2: 00
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 +
! style="background:rgb(204,204,204);" align="center" | Description
 +
|-
 +
| | 0x00
 +
| | WORD
 +
| | NULL (0x0000)
 +
|-
 +
| | 0x02
 +
| | BYTE
 +
| | Number of Bones
 +
|-
 +
| | 0x03
 +
| | BYTE
 +
| | Number of Groups
 +
|-
 +
| | 0x04
 +
| | WORD
 +
| | Total size of data, excl. all headers (3D Model/Bone/Object-Group Headers)
 +
|-
 +
| | 0x06
 +
| | WORD
 +
| | Unknown (possible an ID)
 +
|-
 +
| | 0x08
 +
| | WORD
 +
| | Unknown (possible an ID)
 +
|-
 +
| | 0x0A
 +
| | WORD
 +
| | Unknown (possible an ID)
 +
|-
 +
| | 0x0C
 +
| | DWORD
 +
| | Pointer to Bone Header(s)
 +
|-
 +
| | 0x10
 +
| | WORD
 +
| | Pointer to Group Header(s)
 +
|}
  
3: Bones count.
 
  
4: Objects count.
+
'''Bone Header'''
  
 +
Global header for bones, one header per bone.<br />
 +
Size: 4 bytes
  
Next there is 8 byte, unknown purpose
 
  
Next there is 4 bytes, value is always 0x14. I think, that it is count of bytes from 1-st byte to bones table.
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 +
! style="background:rgb(204,204,204);" align="center" | Description
 +
|-
 +
| | 0x00
 +
| | 24BIT
 +
| | Length
 +
|-
 +
| | 0x03
 +
| | BYTE
 +
| | Parent Bone
 +
|}
  
Next there is 4-byte pointer from 1-st model byte to object table.
 
  
 +
'''Group Header'''
  
 +
Global header for groups, one header per group.<br />
 +
Size: 40 bytes
  
'''Bones'''
 
  
Next there is model scelet, bones counting from 0. Every bone information is of 4-bytes:
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
 
+
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
3 bytes — bone length
+
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 
+
! style="background:rgb(204,204,204);" align="center" | Description
1 byte — parent bone
+
|-
 
+
| | 0x00
 
+
| | WORD
 
+
| | Size of the group's data (excluding the header).
'''Object table'''
+
|-
 
+
| | 0x02
Size of table is 40 * objects count.
+
| | WORD
 
+
| | Number of Quadrangle Polygons (Type-A)
{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
+
|-
! style="background:rgb(204,204,204);" align="center" | Data
+
| | 0x04
! style="background:rgb(204,204,204);" align="center" | Length (bytes)
+
| | WORD
 +
| | Number of Triangle Polygons (Type-A)
 +
|-
 +
| | 0x06
 +
| | WORD
 +
| | Number of Quadrangle Polygons (Type-B)
 +
|-
 +
| | 0x08
 +
| | WORD
 +
| | Number of Triangle Polygons (Type-B)
 +
|-
 +
| | 0x0A
 +
| | WORD
 +
| | Number of Quadrangle Polygons (Type-C)
 
|-
 
|-
| style="background:rgb(255,255,255);" | UNKNOWN
+
| | 0x0C
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Number of Triangle Polygons (Type-C)
 
|-
 
|-
| style="background:rgb(255,255,255);" | Quads count
+
| | 0x0E
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Group X offset
 
|-
 
|-
| style="background:rgb(255,255,255);" | Triangles count
+
| | 0x10
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Group Y offset
 
|-
 
|-
| style="background:rgb(255,255,255);" | UNKNOWN, zeroes
+
| | 0x12
| style="background:rgb(255,255,255);" | 14
+
| | WORD
 +
| | Group Z offset
 
|-
 
|-
| style="background:rgb(255,255,255);" | Pointer to vertex table, counting from first byte of model
+
| | 0x14
| style="background:rgb(255,255,255);" | 4
+
| | DWORD
 +
| | Pointer to Bone Data Chunk
 
|-
 
|-
| style="background:rgb(255,255,255);" | Pointer to vertices, counting from first byte of model
+
| | 0x18
| style="background:rgb(255,255,255);" | 4
+
| | DWORD
 +
| | Pointer to Vertex Data Chunk
 
|-
 
|-
| style="background:rgb(255,255,255);" | Pointer to quad block with triangles, counting from first byte of model
+
| | 0x1C
| style="background:rgb(255,255,255);" | 4
+
| | DWORD
 +
| | Pointer to Polygon Data Chunk
 
|-
 
|-
| style="background:rgb(255,255,255);" | Pointer to texture coordinates, counting from first byte of model
+
| | 0x20
| style="background:rgb(255,255,255);" | 4
+
| | DWORD
 +
| | Pointer to Texture Mapping Data Chunk
 
|-
 
|-
| style="background:rgb(255,255,255);" | Pointer to the end of object, counting from first byte of model
+
| | 0x24
| style="background:rgb(255,255,255);" | 4
+
| | DWORD
 +
| | Pointer to End-of-Group
 
|}
 
|}
  
  
'''Vertex table'''
+
'''Bone Data Chunk'''
  
In this table there is information about count of vertex connected to every bone. Every record is 2-byte. If count of bones is odd, there is 2-byte padding.
+
Local group data for bones, one data chunk per bone of the group.<br />
 +
Size: 4 bytes
  
  
'''Vertices'''
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 +
! style="background:rgb(204,204,204);" align="center" | Description
 +
|-
 +
| | 0x00
 +
| | DWORD
 +
| | Number of vertices connected to the bone
 +
|}
  
Here there is information about all vertices of selected object. Vertex record is 3-byte and is of next structure:
 
  
{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
+
'''Vertex Data Chunk'''
! style="background:rgb(204,204,204);" align="center" | Data
+
 
! style="background:rgb(204,204,204);" align="center" | Length (bytes)
+
Local group data for vertices, one data chunk per vertex of the group.<br />
 +
Size: 8 bytes
 +
 
 +
 
 +
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
 +
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 +
! style="background:rgb(204,204,204);" align="center" | Description
 
|-
 
|-
| style="background:rgb(255,255,255);" | X
+
| | 0x00
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | X-Coordinate (signed value)
 
|-
 
|-
| style="background:rgb(255,255,255);" | Y
+
| | 0x02
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Y-Coordinate (signed value)
 
|-
 
|-
| style="background:rgb(255,255,255);" | Z
+
| | 0x04
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Z-Coordinate (signed value)
 
|-
 
|-
| style="background:rgb(255,255,255);" | Bone number
+
| | 0x06
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | ID of the bone the vertex is connected to
 
|-
 
|-
| style="background:rgb(255,255,255);" | UnkNown
+
| | 0x07
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | Unknown
 
|}
 
|}
  
Point coordinates are in local coordinate system of given bones. Vertex count begins from 0. For every model object it counts from 0.
 
  
 +
'''Polygon Data Chunk'''
  
'''Quad and Triangle block'''
+
Local group data for polygons.<br />
 +
There are six different types of polygons, three types of polygons made out of four vertices (quadrangle) and three types of polygons made out of three vertices (triangle).
  
First there is block of quads, next there is triangles. Count of quads and triangles is in object table.
 
  
    '''''Quad record:'''''
+
''Quadrangle Type-A''
{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
+
 
! style="background:rgb(204,204,204);" align="center" | Data
+
Size: 24 bytes
! style="background:rgb(204,204,204);" align="center" | Length (bytes)
+
 
|-
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
| style="background:rgb(255,255,255);" | 1-st vertex index
+
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
| style="background:rgb(255,255,255);" | 2
+
! style="background:rgb(204,204,204);" align="center" width="80" | Size
|-
+
! style="background:rgb(204,204,204);" align="center" | Description
| style="background:rgb(255,255,255);" | 2-nd vertex index
 
| style="background:rgb(255,255,255);" | 2
 
 
|-
 
|-
| style="background:rgb(255,255,255);" | 3-rd vertex index
+
| | 0x00
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 1
 
|-
 
|-
| style="background:rgb(255,255,255);" | 4-th vertex index
+
| | 0x02
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 2
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for first vertex.
+
| | 0x04
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 3
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for second vertex.
+
| | 0x06
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 4
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for third vertex.
+
| | 0x08
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Texture index 1
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for fourth vertex.
+
| | 0x0A
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Texture index 2
 
|-
 
|-
| style="background:rgb(255,255,255);" | Color R (I think)
+
| | 0x0C
| style="background:rgb(255,255,255);" | 1
+
| | WORD
 +
| | Texture index 3
 
|-
 
|-
| style="background:rgb(255,255,255);" | Color G (I think)
+
| | 0x0E
| style="background:rgb(255,255,255);" | 1
+
| | WORD
 +
| | Texture index 4
 
|-
 
|-
| style="background:rgb(255,255,255);" | Color B (I think)
+
| | 0x10
| style="background:rgb(255,255,255);" | 1
+
| | 24BIT
 +
| | Vertex colour (R8G8B8) ?
 
|-
 
|-
| style="background:rgb(255,255,255);" | (Texture information?)
+
| | 0x13
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | Texture material index
 
|-
 
|-
| style="background:rgb(255,255,255);" | (Texture information?)
+
| | 0x14
| style="background:rgb(255,255,255);" | 4
+
| | DWORD
 +
| | Unknown
 
|}
 
|}
  
 +
''Triangle Type-A''
  
    '''''Triangle record:'''''
+
Size: 20 bytes
  
{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
! style="background:rgb(204,204,204);" align="center" | Data
+
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
! style="background:rgb(204,204,204);" align="center" | Length (bytes)
+
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 +
! style="background:rgb(204,204,204);" align="center" | Description
 
|-
 
|-
| style="background:rgb(255,255,255);" | 1-st vertex index
+
| | 0x00
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 1
 
|-
 
|-
| style="background:rgb(255,255,255);" | 2-nd vertex index
+
| | 0x02
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 2
 
|-
 
|-
| style="background:rgb(255,255,255);" | 3-rd vertex index
+
| | 0x04
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Vertex index 3
 
|-
 
|-
| style="background:rgb(255,255,255);" | (Texture information?)
+
| | 0x06
| style="background:rgb(255,255,255);" | 2
+
| | BYTE
 +
| | Texture material index
 
|-
 
|-
| style="background:rgb(255,255,255);" | Color R (I think)
+
| | 0x07
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | Unknown
 
|-
 
|-
| style="background:rgb(255,255,255);" | Color G (I think)
+
| | 0x08
| style="background:rgb(255,255,255);" | 1
+
| | 24BIT
 +
| | Vertex colour (R8G8B8) ?
 
|-
 
|-
| style="background:rgb(255,255,255);" | Color B (I think)
+
| | 0x0B
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | Unknown
 
|-
 
|-
| style="background:rgb(255,255,255);" | (Texture information?)
+
| | 0x0C
| style="background:rgb(255,255,255);" | 1
+
| | WORD
 +
| | Texture index 1
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for first vertex.
+
| | 0x0E
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Texture index 2
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for second vertex.
+
| | 0x10
| style="background:rgb(255,255,255);" | 2
+
| | WORD
 +
| | Texture index 3
 
|-
 
|-
| style="background:rgb(255,255,255);" | Coordinate index from block of coordinates of texturation for third vertex.
+
| | 0x12
| style="background:rgb(255,255,255);" | 2
+
| | DWORD
|-
+
| | Unknown (possible padding)
| style="background:rgb(255,255,255);" | (Texture information?)
 
| style="background:rgb(255,255,255);" | 2
 
 
|}
 
|}
  
 +
''Quadrangle Type-B''
 +
 +
Size: 32 bytes
 +
 +
 +
''Triangle Type-B''
 +
 +
Size: 24 bytes
 +
 +
 +
''Quadrangle Type-C''
 +
 +
Size: 24 bytes
 +
 +
 +
''Triangle Type-C''
  
'''Texture coordinates'''
+
Size: 20 bytes
  
In this block there is texture coordinate of selected object. Values of given table used for applying texture to quads and triangles of object. To elements of given table points «Coordinate index from block of coordinates of texturation for <N> vertex.» from triangle and quad records.
 
  
 +
'''Texture Mapping Data Chunk'''
  
Records counting from 0.
+
Local group data for texture mapping.<br />
 +
The number of texture mapping coordinates are: Number of quadrangle polygons (any type) * 4 + Number of triangle polygons (any type) * 3.<br />
 +
Size: 2 bytes
  
Texture coordinate record:
 
  
{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
+
{| border="0" cellspacing="1" cellpadding="3" width="640" style="background: rgb(255,255,255)" align="center"
! style="background:rgb(204,204,204);" align="center" | Data
+
! style="background:rgb(204,204,204);" align="center" width="80" | Offset
! style="background:rgb(204,204,204);" align="center" | Length (bytes)
+
! style="background:rgb(204,204,204);" align="center" width="80" | Size
 +
! style="background:rgb(204,204,204);" align="center" | Description
 
|-
 
|-
| style="background:rgb(255,255,255);" | Texture coordinate U
+
| | 0x00
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | U-Coordinate
 
|-
 
|-
| style="background:rgb(255,255,255);" | Texture coordinate V
+
| | 0x01
| style="background:rgb(255,255,255);" | 1
+
| | BYTE
 +
| | V-Coordinate
 
|}
 
|}

Revision as of 20:23, 15 January 2009

3D Model Header

Global header for the 3D model, one per model.
Size: 20 bytes


Offset Size Description
0x00 WORD NULL (0x0000)
0x02 BYTE Number of Bones
0x03 BYTE Number of Groups
0x04 WORD Total size of data, excl. all headers (3D Model/Bone/Object-Group Headers)
0x06 WORD Unknown (possible an ID)
0x08 WORD Unknown (possible an ID)
0x0A WORD Unknown (possible an ID)
0x0C DWORD Pointer to Bone Header(s)
0x10 WORD Pointer to Group Header(s)


Bone Header

Global header for bones, one header per bone.
Size: 4 bytes


Offset Size Description
0x00 24BIT Length
0x03 BYTE Parent Bone


Group Header

Global header for groups, one header per group.
Size: 40 bytes


Offset Size Description
0x00 WORD Size of the group's data (excluding the header).
0x02 WORD Number of Quadrangle Polygons (Type-A)
0x04 WORD Number of Triangle Polygons (Type-A)
0x06 WORD Number of Quadrangle Polygons (Type-B)
0x08 WORD Number of Triangle Polygons (Type-B)
0x0A WORD Number of Quadrangle Polygons (Type-C)
0x0C WORD Number of Triangle Polygons (Type-C)
0x0E WORD Group X offset
0x10 WORD Group Y offset
0x12 WORD Group Z offset
0x14 DWORD Pointer to Bone Data Chunk
0x18 DWORD Pointer to Vertex Data Chunk
0x1C DWORD Pointer to Polygon Data Chunk
0x20 DWORD Pointer to Texture Mapping Data Chunk
0x24 DWORD Pointer to End-of-Group


Bone Data Chunk

Local group data for bones, one data chunk per bone of the group.
Size: 4 bytes


Offset Size Description
0x00 DWORD Number of vertices connected to the bone


Vertex Data Chunk

Local group data for vertices, one data chunk per vertex of the group.
Size: 8 bytes


Offset Size Description
0x00 WORD X-Coordinate (signed value)
0x02 WORD Y-Coordinate (signed value)
0x04 WORD Z-Coordinate (signed value)
0x06 BYTE ID of the bone the vertex is connected to
0x07 BYTE Unknown


Polygon Data Chunk

Local group data for polygons.
There are six different types of polygons, three types of polygons made out of four vertices (quadrangle) and three types of polygons made out of three vertices (triangle).


Quadrangle Type-A

Size: 24 bytes

Offset Size Description
0x00 WORD Vertex index 1
0x02 WORD Vertex index 2
0x04 WORD Vertex index 3
0x06 WORD Vertex index 4
0x08 WORD Texture index 1
0x0A WORD Texture index 2
0x0C WORD Texture index 3
0x0E WORD Texture index 4
0x10 24BIT Vertex colour (R8G8B8) ?
0x13 BYTE Texture material index
0x14 DWORD Unknown

Triangle Type-A

Size: 20 bytes

Offset Size Description
0x00 WORD Vertex index 1
0x02 WORD Vertex index 2
0x04 WORD Vertex index 3
0x06 BYTE Texture material index
0x07 BYTE Unknown
0x08 24BIT Vertex colour (R8G8B8) ?
0x0B BYTE Unknown
0x0C WORD Texture index 1
0x0E WORD Texture index 2
0x10 WORD Texture index 3
0x12 DWORD Unknown (possible padding)

Quadrangle Type-B

Size: 32 bytes


Triangle Type-B

Size: 24 bytes


Quadrangle Type-C

Size: 24 bytes


Triangle Type-C

Size: 20 bytes


Texture Mapping Data Chunk

Local group data for texture mapping.
The number of texture mapping coordinates are: Number of quadrangle polygons (any type) * 4 + Number of triangle polygons (any type) * 3.
Size: 2 bytes


Offset Size Description
0x00 BYTE U-Coordinate
0x01 BYTE V-Coordinate