GTA 3 & Vice

- Home
- DFF Format
- Sourceforge
- Contact ME

Chronetal

- Back Home

Donations:

Hosted By:

- 34SP


DFF File Format (RenderWare Model File)

Structure Overview

The file is split up into many sections, each stated with its own header, so the file will always be of format:

|FILE START|

  • (Section Header)
    • 4 bytes - int - Section Type
    • 4 bytes - int - Section Size
    • 2 bytes - int - Unknown
    • 2 bytes - int - Version Number
  • (Section Data)
    • [Section Size] bytes - data - Data
  • etc.
|FILE END|

Where etc. could be another section or the end of the file.

The [Section Type] determines how the data should be handled. Basically, if the [Section Type] is either an rwDATA, rwSTRING, rwFRAME or rwMATERIALSPLIT then it should be parsed accordingly, otherwise it should be parsed for more headers. For example, it could look something like this (this is just a made up clip):

|FILE START| (File Size = 60 bytes)

  • (Section Header)
    • 4 bytes - int - rwCLUMP
    • 4 bytes - int - 48
    • 2 bytes - int - Unknown
    • 2 bytes - int - 4099
  • (Section Data)
    • (Section Header)
      • 4 bytes - int - rwDATA
      • 4 bytes - int - 8
      • 2 bytes - int - Unknown
      • 2 bytes - int - 4099
    • (Section Data)
      • 4 bytes - int - Some Number
      • 4 bytes - int - Some Number

    • (Section Header)
      • 4 bytes - int - rwSTRING
      • 4 bytes - int - 16
      • 2 bytes - int - Unknown
      • 2 bytes - int - 4099
    • (Section Data)
      • 16 bytes - string - Data
|FILE END|

Anyway, here are the following possibilities of [Section Type]:

  • 1 = rwDATA
  • 2 = rwSTRING
  • 3 = rwEXTENSION
  • 6 = rwTEXTURE
  • 7 = rwMATERIAL
  • 8 = rwMATERIALLIST
  • 14 = rwFRAMELIST
  • 15 = rwGEOMETRY
  • 16 = rwCLUMP
  • 20 = rwATOMIC
  • 26 = rwGEOMETRYLIST
  • 1294 = rwMATERIALSPLIT
  • 39056126 = rwFRAME

So now we should be able to see how the structure of the file works, and follow through the file in a hex editor, or write a little program to output what goes where, but now we have to interpret the data in the rwDATA, rwSTRING, rwFRAME or rwMATERIALSPLIT of various sections of the file. As the contents of the rwDATA will differ depending on what it belongs to, for example, the rwDATA of the rwGEOMETRY section holds all the vertices, normals of the 3d object, whereas the rwDATA of the rwGEOMETRYLIST holds the number of geometry items in that section.

P.S: rwEXTENSION is either empty or holds more sections


Contents List

Key: * There can be more than one of these sections


Section: Clump

Clump - Data

|SECTION START|

  • 4 bytes - int - Object Count
|SECTION END|


Section: Frame List

Frame List - Data

|SECTION START|

  • 4 bytes - int - Frame Count
  • (Frame Information)
    {ARRAY OF SIZE: [Frame Count]}
    • 36 bytes - float matrix (3 x 3) - Rotational Matrix
    • 12 bytes - float - Coordinates Offset
    • 4 bytes - int - Parent Frame
    • 4 bytes - int - Unknown
    {END ARRAY}
|SECTION END|

Frame List - Frame

|SECTION START|

  • [Section Size] bytes - string - Frame Name
|SECTION END|


Section: Geometry List

Geometry List - Data

|SECTION START|

  • 4 bytes - int - Geometry Count
|SECTION END|

Geometry List - Material Split

|SECTION START|

  • (Header)
    • 4 bytes - int - Triangle Strip
    • 4 bytes - int - Split Count
    • 4 bytes - int - Face Count
  • (Split Information)
    {ARRAY OF SIZE: [Header - Split Count]}
    • 4 bytes - int - Face Index
    • 4 bytes - int - Material Index
    • (Vertex Information)
      {ARRAY OF SIZE: [Face Index]}
      • 4 bytes - int - Vertex 1
    {END ARRAY}
|SECTION END|


Section: Geometry

Geometry - Data

|SECTION START|

  • (Header)
    • 2 bytes - int - Flags
    • 2 bytes - int - Unknown
    • 4 bytes - int - Triangle Count
    • 4 bytes - int - Vertex Count
    • 4 bytes - int - Morph Target Count
  • (Lighting Header)
    {IF Version Number = 4099 THEN}
    • 4 bytes - float - Ambient
    • 4 bytes - float - Diffuse
    • 4 bytes - float - Specular
    {END IF}
  • (Colour Information)
    {IF rwOBJECT_VERTEX_COLOR in [Header - Flags] THEN}
    • {ARRAY OF SIZE: [Header - Vertex Count]}
      • 1 byte - byte - Red
      • 1 byte - byte - Green
      • 1 byte - byte - Blue
      • 1 byte - byte - Alpha
      {END ARRAY}
    {END IF}
  • (Texture Mapping Information)
    {IF rwOBJECT_VERTEX_UV in [Header - Flags] THEN}
    • {ARRAY OF SIZE: [Header - Vertex Count]}
      • 4 bytes - float - U
      • 4 bytes - float - V
      {END ARRAY}
    {END IF}
  • (Face Information)
    {ARRAY OF SIZE: [Header - Triangle Count]}
    • 2 bytes - int - Vertex 2
    • 2 bytes - int - Vertex 1
    • 2 bytes - int - Flags
    • 2 bytes - int - Vertex 3
    {END ARRAY}
  • (Unknown)
    • 4 bytes - float - Bounding Sphere X
    • 4 bytes - float - Bounding Sphere Y
    • 4 bytes - float - Bounding Sphere Z
    • 4 bytes - float - Bounding Sphere Radius
    • 4 bytes - int - Has Position
    • 4 bytes - int - Has Normals
  • (Vertex Information)
    {ARRAY OF SIZE: [Header - Vertex Count]}
    • 4 bytes - float - X
    • 4 bytes - float - Y
    • 4 bytes - float - Z
    {END ARRAY}
  • (Normal Information)
    {IF rwOBJECT_VERTEX_NORMAL in [Header - Flags] THEN}
    • {ARRAY OF SIZE: [Header - Vertex Count]}
      • 4 bytes - float - X
      • 4 bytes - float - Y
      • 4 bytes - float - Z
      {END ARRAY}
    {END IF}
|SECTION END|

And here are the constants used above:

  • 4 = rwOBJECT_VERTEX_UV
  • 8 = rwOBJECT_VERTEX_COLOR
  • 16 = rwOBJECT_VERTEX_NORMAL

Section: Material List

Material List - Data

|SECTION START|

  • 4 bytes - int - Material Count
|SECTION END|


Section: Material

Material - Data

|SECTION START|

  • 4 bytes - int - Unknown
  • 12 bytes - RGBA - Colour
  • 4 bytes - int - Unknown
  • 4 bytes - int - Texture Count
  • 4 bytes - float - Unknown
  • 4 bytes - float - Unknown
  • 4 bytes - float - Unknown
|SECTION END|


Section: Texture

Texture - Data

|SECTION START|

  • 2 bytes - int - Texture Filter Mode Flags
  • 2 bytes - int - Unknown
|SECTION END|


Section: Atomic

Atomic - Data

|SECTION START|

  • 4 bytes - int - Frame Number
  • 4 bytes - int - Geometry Number
  • 4 bytes - int - Unknown
  • 4 bytes - int - Unknown
|SECTION END|


Conclusion

Please remember that all hex values are little endian, that means 0F 00 00 00 in hex is 16 and not 00 00 00 0F. If you do not understand then look it up on the web, this is a very common way of storing values.

This is basically all the work that I've managed to do on decoding the DFF file format. I hope someone can help progress this further, or use what I've done so far to help create an importer of some kind. If you need any help or more information then feel free to let me know and I will do my best to help! Also, if none of this seem to make any sense then I would leave it to someone else to figure out! (or get revising on your data analysis skills)

- KCow (Alastair Burr)

p

Copyright © 2000-2003 Alastair Burr (KCow). All Rights Reserved - http://www.chronetal.co.uk Valid HTML 4.01! Valid CSS!