Difference between revisions of "BFRES (File Format)"

From Deep Sea Knowledge
Jump to navigation Jump to search
m (Categorize page.)
(Document the FMDL section, and the dictionary structure.)
Line 32: Line 32:
 
| 0x20 || UInt64 || Offset to the file name length.
 
| 0x20 || UInt64 || Offset to the file name length.
 
|-  
 
|-  
| 0x28 || UInt64 || FMDL offset.
+
| 0x28 || UInt64 || [[#FMDL|FMDL]] offset.
 
|-  
 
|-  
| 0x30 || UInt64 || FMDL dictionary offset.
+
| 0x30 || UInt64 || [[#FMDL|FMDL]] dictionary offset.
 
|-  
 
|-  
 
| 0x38 || UInt64 || Skeletal animations offset.
 
| 0x38 || UInt64 || Skeletal animations offset.
Line 84: Line 84:
 
| 0xD0 || || End of file header.
 
| 0xD0 || || End of file header.
 
|}
 
|}
 +
 +
== FMDL ==
 +
The FMDL section handles the actual model information, where it stores skeleton structures, shapes, and more.
 +
 +
{|class="wikitable"
 +
|-
 +
! Offset !! Type !! Description
 +
|-
 +
| 0x00 || String || '''Section magic'''. Always "FMDL" in ASCII.
 +
|-
 +
| 0x04 || UInt32 || Header size.
 +
|-
 +
| 0x08 || UInt64 || Header size, duplicate.
 +
|-
 +
| 0x10 || UInt64 || Model name offset.
 +
|-
 +
| 0x18 || UInt64 || String table end offset.
 +
|-
 +
| 0x20 || UInt64 || FSKL offset.
 +
|-
 +
| 0x28 || UInt64 || FVTX offset.
 +
|-
 +
| 0x30 || Uint64 || FSHP offset.
 +
|-
 +
| 0x38 || UInt64 || FSHP dictionary offset.
 +
|-
 +
| 0x40 || UInt64 || FMAT offset.
 +
|-
 +
| 0x48 || UInt64 || FMAT dictionary offset.
 +
|-
 +
| 0x50 || UInt64 || User data offset.
 +
|-
 +
| 0x58 || Byte[16]] || Padding.
 +
|-
 +
| 0x68 || UInt16 || Vertex array count.
 +
|-
 +
| 0x6A || UInt16 || Shape count.
 +
|-
 +
| 0x6C || UInt16 || Material count.
 +
|-
 +
| 0x6E || UInt16 || User data count.
 +
|-
 +
| 0x70 || UInt32 || Total vertex count.
 +
|-
 +
| 0x74 || Byte[4] || Padding.
 +
|-
 +
| 0x78 || || End of FMDL header.
 +
|}
 +
 +
Directly after the FMDL header, there is a structure that defines a buffer for resources.
 +
 +
{|class="wikitable"
 +
|-
 +
! Offset !! Type !! Description
 +
|-
 +
| 0x00 || UInt32 || Unknown.
 +
|-
 +
| 0x04 || UInt32 || Size.
 +
|-
 +
| 0x08 || UInt64 || Buffer offset.
 +
|-
 +
| 0x10 || Byte[16] || Padding.
 +
|-
 +
| 0x20 || || End of buffer structure.
 +
|}
 +
 +
Then after this structure, a model [[#Dictionary|dictionary]] is present.
  
 
[[Category:File formats]]
 
[[Category:File formats]]
 +
 +
== Dictionary ==
 +
A dictionary is a structure that can store [[#Dictionary_Node|nodes]] that reference each other, to create a tree for storing data.
 +
 +
=== Header ===
 +
The header defines the structure of the dictionary.
 +
{|class="wikitable"
 +
|-
 +
! Offset !! Type !! Description
 +
|-
 +
| 0x00 || UInt32 || Size.
 +
|-
 +
| 0x04 || UInt32 || Number of nodes in this dictionary. This does NOT include the root node.
 +
|-
 +
| 0x08 || [[#Dictionary_Node|Dictionary Nodes]] || Node definitions.
 +
|-
 +
| 0x08 + (numNodes * 0x10) || || End of dictionary.
 +
|}
 +
 +
=== Dictionary Node ===
 +
{|class="wikitable"
 +
|-
 +
! Offset !! Type !! Description
 +
|-
 +
| 0x00 || UInt32 || Reference node. -1 for root node.
 +
|-
 +
| 0x04 || UInt16 || ID of the node to the left of this node.
 +
|-
 +
| 0x06 || UInt16 || ID of the node to the right of this node.
 +
|-
 +
| 0x08 || UInt64 || Offset to the string in the string table that is associated with this node.
 +
|-
 +
| 0x10 || || End of dictionary node.
 +
|}

Revision as of 16:30, 31 October 2018

BFRES, known as Binary CaFe RESource, stores information relating to any 3D model data.

Header

The header contains all of the information needed to parse the entire file, include counts and offsets to data.

Offset Type Description
0x00 String File magic. Always "FRES" in ASCII.
0x04 UInt32 Signature.
0x08 UInt32 Version.
0x0C UInt16 Byte Order Mark (BOM): 0xFEFF for big endian and 0xFFFE for little endian.
0x0E Byte Byte alignment.
0x0F Byte Target address size. Usually 0.
0x10 UInt32 File name offset.
0x14 Uint16 Flags.
0x16 UInt16 Block offset.
0x18 UInt32 Relocation table offset.
0x1C UInt32 BFRES Size.
0x20 UInt64 Offset to the file name length.
0x28 UInt64 FMDL offset.
0x30 UInt64 FMDL dictionary offset.
0x38 UInt64 Skeletal animations offset.
0x40 UInt64 Skeletal animations dictionary.
0x48 UInt64 Material animations offset.
0x50 UInt64 Material animations dictionary.
0x58 UInt64 Bone visibility animation array offset.
0x60 UInt64 Bone visibility animation array dictionary.
0x68 UInt64 Shape animation array offset.
0x70 UInt64 Shape animation dictionary offset.
0x78 UInt64 Scene animation array offset.
0x80 UInt64 Scene animation dictionary offset.
0x88 UInt64 Unknown.
0x90 UInt64 Unknown.
0x98 UInt64 External files offset.
0xA0 UInt64 Embedded file dictionary offset.
0xA8 Byte[8] Padding.
0xB0 UInt64 String table offset.
0xB8 UInt32 Unknown.
0xBC UInt16 Model count.
0xBE UInt16 Skeletal animation count.
0xC0 UInt16 Material animation count.
0xC2 Byte[6] Padding.
0xC8 UInt16 External file count.
0xCA Byte[6] Padding.
0xD0 End of file header.

FMDL

The FMDL section handles the actual model information, where it stores skeleton structures, shapes, and more.

Offset Type Description
0x00 String Section magic. Always "FMDL" in ASCII.
0x04 UInt32 Header size.
0x08 UInt64 Header size, duplicate.
0x10 UInt64 Model name offset.
0x18 UInt64 String table end offset.
0x20 UInt64 FSKL offset.
0x28 UInt64 FVTX offset.
0x30 Uint64 FSHP offset.
0x38 UInt64 FSHP dictionary offset.
0x40 UInt64 FMAT offset.
0x48 UInt64 FMAT dictionary offset.
0x50 UInt64 User data offset.
0x58 Byte[16]] Padding.
0x68 UInt16 Vertex array count.
0x6A UInt16 Shape count.
0x6C UInt16 Material count.
0x6E UInt16 User data count.
0x70 UInt32 Total vertex count.
0x74 Byte[4] Padding.
0x78 End of FMDL header.

Directly after the FMDL header, there is a structure that defines a buffer for resources.

Offset Type Description
0x00 UInt32 Unknown.
0x04 UInt32 Size.
0x08 UInt64 Buffer offset.
0x10 Byte[16] Padding.
0x20 End of buffer structure.

Then after this structure, a model dictionary is present.

Dictionary

A dictionary is a structure that can store nodes that reference each other, to create a tree for storing data.

Header

The header defines the structure of the dictionary.

Offset Type Description
0x00 UInt32 Size.
0x04 UInt32 Number of nodes in this dictionary. This does NOT include the root node.
0x08 Dictionary Nodes Node definitions.
0x08 + (numNodes * 0x10) End of dictionary.

Dictionary Node

Offset Type Description
0x00 UInt32 Reference node. -1 for root node.
0x04 UInt16 ID of the node to the left of this node.
0x06 UInt16 ID of the node to the right of this node.
0x08 UInt64 Offset to the string in the string table that is associated with this node.
0x10 End of dictionary node.