version 1
--------------------------------------------
DIF File Format Specification

InteriorResource Version MARBLE_BLAST_GOLD
Interior Version MARBLE_BLAST_GOLD

ORIGINAL DOCUMENTATION:
(InteriorResourceFileVersion 44; InteriorFileVersion 14)
http://rustycode.com/tutorials/DIF_File_Format_44_14.html

KEY:
Red: Change/Addition (compared to v44_14).
Dark grey: Not tested (usually unused features).
Light grey: Not included in this version.
 
U32 interiorResourceFileVersion
bool previewIncluded 
     if (previewIncluded) 
          PNG previewBitmap 
U32 numDetailLevels 
     for 0 to numDetailLevels 
          Interior  
               U32 interiorFileVersion
               U32 detailLevel
               U32 minPixels
               BoxF boundingBox
               SphereF boundingSphere
               Bool hasAlarmState
               U32 numLightStateEntries
               U32 numNormals
                    for 0 to numNormals
                         Point3F normal
               U32 numPlanes
                    for 0 to numPlanes
                         U16 normalIndex
                         F32 planeDistance
               U32 numPoints
                    for 0 to numPoints
                         Point3F point
               U32 numPointVisibilities
                    for 0 to numPointVisibilities
                         U8 pointVisibility
               U32 numTexGenEqs
                    for 0 to numTexGenEQs
                         PlaneF planeX
                         PlaneF planeY
               U32 numBSPNodes
                    for 0 to numBSPNodes
                         U16 planeIndex
                         U16 frontIndex
                         U16 backIndex
               U32 numBSPSolidLeaves
                    for 0 to numBSPSolidLeaves
                         U32 surfaceIndex
                         U16 surfaceCount
               MaterialList
                    U8 version
                    U32 numMaterials
                    for 0 to numMaterials
                         String
                              U8 length
                                   for 0 to length
                                        U8 character
               U32 numWindings
                    for 0 to numWindings
                         U32 index
               U32 numWindingIndices
                    for 0 to numWindingIndices
                         U32 windingStart
                         U32 windingCount
               U32 numEdges
                    for 0 to numEdges
                         S32 pointIndex0
                         S32 pointIndex1
                         S32 surfaceIndex0
                         S32 surfaceIndex1
               U32 numZones
                    for 0 to numZones
                         U16 portalStart
                         U16 portalCount
                         U32 surfaceStart
                         U32 surfaceCount
                         U32 staticMeshStart
                         U32 staticMeshCount
                         U16 flags
               U32 numZoneSurfaces
                    for 0 to numZoneSurfaces
                         U16 zoneSurface
               U32 numZonePortalList
                    for 0 to numZonePortalList
                         U16 zonePortalList
               U32 numPortals
                    for 0 to numPortals
                         U16 planeIndex
                         U16 triFanCount
                         U32 triFanStart
                         U16 zoneFront
                         U16 zoneBack
               U32 numSurfaces
                    for 0 to numSurfaces
                         U32 windingStart
                         U8   windingCount
                         U16 planeIndex
                         U16 textureIndex
                         U32 texGenIndex
                         U8   surfaceFlags
                         U32 fanMask
                         LightMapTexGen
                              U16 finalWord
                              F32 texGenXDistance
                              F32 texGenYDistance
                         U16 lightCount
                         U32 lightStateInfoStart
                         U8   mapOffsetX
                         U8   mapOffsetY        //unsure of these, thinking it could be two U16s
                         U8   mapSizeX
                         U8   mapSizeY
                         bool unused 
               U32 numNormalLMapIndices
                    for 0 to numNormalLMapIndices
                         U32 normalLMapIndex
               U32 numAlarmLMapIndices
                    for 0 to numAlarmLMapIndices
                         U32 alarmLMapIndex
               U32 numNullSurfaces
                    for 0 to numNullSurfaces
                         U32 windingStart
                         U16 planeIndex
                         U8   surfaceFlags  //not 100% sure about these, but I think it's close
                         U8   windingCount
               U32 numLightMaps
                    for 0 to numLightMaps
                         PNG lightMap
                         PNG lightDirMap
                         bool keepLightMap
               U32 numSolidLeafSurfaces
                    for 0 to numSolidLeafSurfaces
                         U32 solidLeafSurface
               U32 numAnimatedLights
                    for 0 to numAnimatedLights
                         U32 nameIndex
                         U32 stateIndex
                         U16 stateCount
                         U16 flags
                         U32 duration
               U32 numLightStates
                    for 0 to numLightStates
                         U8   red
                         U8   green
                         U8   blue
                         U32 activeTime
                         U32 dataIndex
                         U16 dataCount
               U32 numStateDatas
                    for 0 to numStateData
                         U32 surfaceIndex
                         U32 mapIndex
                         U16 lightStateIndex
               U32 numStateDataBuffers
               U32 flags
                    for 0 to numStateDataBuffers
                         U8 stateDataBuffer
               U32 numNameBuffers
                    for 0 to numNameBuffers
                         S8 character
               U32 numSubObjects
                    for 0 to numSubObjects
                         InteriorSubObject object
               U32 numConvexHulls
                    for 0 to numConvexHulls
                         U32 hullStart
                         U16 hullCount
                         F32 minX
                         F32 maxX
                         F32 minY
                         F32 maxY
                         F32 minZ
                         F32 maxZ
                         U32 surfaceStart
                         U16 surfaceCount
                         U32 planeStart
                         U32 polyListPlaneStart
                         U32 polyListPointStart
                         U32 polyListStringStart
                         bool staticMesh
               U32 numConvexHullEmitStrings
                    for 0 to numConvexHullEmitStrings
                         U8 convexHullEmitStringCharacter
               U32 numHullIndices
                    for 0 to numHullIndices
                         U32 hullIndex
               U32 numHullPlaneIndices
                    for 0 to numHullPlaneIndices
                         U16 hullPlaneIndex
               U32 numHullEmitStringIndices
                    for 0 to numHullEmitStringIndices
                         U32 hullEmitStringIndex
               U32 numHullSurfaceIndices
                    for 0 to numHullSurfaceIndices
                         U32 hullSurfaceIndex
               U32 numPolyListPlanes
                    for 0 to numPolyListPlanes
                         U16 ployListPlaneIndex
               U32 numPolyListPoints
                    for 0 to numPolyListPoints
                         U32 polyListPointIndex
               U32 numPolyListStrings
                    for 0 to numPolyListStrings
                         U8 polyListStringCharacter
               for 0 to NumCoordBins * NumCoordBins (16 * 16 by default)
                    U32 binStart
                    U32 binCount
               U32 numCoordBinIndices
                    for 0 to numCoordBinIndices
                         U16 coordBinIndex
               U32 coordBinMode
               ColorF baseAmbientColor
                    U8 red
                    U8 green
                    U8 blue
                    U8 alpha
               ColorF alarmAmbientColor
                    U8 red
                    U8 green
                    U8 blue
                    U8 alpha
               U32 numStaticMeshes
                    for 0 to numStaticMeshes
                         ConstructorSimpleMesh
                              U32 numPrimitives
                                   for 0 to numPrimitives
                                        bool alpha
                                        U32 texS
                                        U32 texT
                                        S32 diffuseIndex
                                        S32 lightMapIndex
                                        U32 start
                                        U32 count
                                        PlaneF lightMapEquationX
                                        PlaneF lightMapEquationY
                                        Point2I lightMapOffset
                                        Point2I lightMapSize
                              U32 numIndices
                                   for 0 to numIndices
                                        U16 index
                              U32 numVertices
                                   for 0 to numVertices
                                        Point3F vertex
                              U32 numNormals
                                   for 0 to numNormals
                                        Point3F normal
                              U32 numDiffuseUVs
                                   for 0 to numDiffuseUVs
                                        Point2F diffuseUV
                              U32 numLightmapUVs
                                   for 0 to numLightmapUVs
                                        Point2F lightmapUV
                              bool hasMaterialList
                                   if (hasMaterialList)
                                        TSMaterialList
                                             MaterialList baseMaterialList  
                                             for 0 to materialCount
                                                  U32 flags
                                             for 0 to materialCount
                                                  U32 reflectanceMap
                                             for 0 to materialCount
                                                  U32 bumpMap
                                             for 0 to materialCount
                                                  U32 detailMap
                                             for 0 to materialCount
                                                  U32 lightMap
                                             for 0 to materialCount
                                                  U32 detailScale
                                             for 0 to materialCount
                                                  U32 reflectionAmount
                              U32 numDiffuseBitmaps
                                   for 0 to numDiffuseBitmaps
                                        bool hasBitmap
                                             if (hasBitmap)
                                                  PNG bitmap
                              bool hasSolid
                              bool hasTranslucency
                              Box3F bounds
                              MatrixF transform
                              Point3F scale
               U32 numNormals
                    for 0 to numNormals
                         Point3F normal
               U32 numTexMatrices
                     for 0 to numTexMatrices
                         S32 T
                         S32 N
                         S32 B
               U32 numTexMatIndices
                    for 0 to numTexMatIndices
                         U32 texMatIndex
               U32 extendedLightMapData
                    if (extendedLightMapData == 1)
                         U32 lightMapBorderSize
                         U32 dummy
U32 numSubObjects
     for 0 to numSubObjects  // NOTE: These are not InteriorSubObjects (separate class); 
          Interior subObject      //            MPs are included here, for example.
U32 numTriggers
     for 0 to numTriggers
          String name
          String datablock 
          Dictionary
               U32 size
                    for 0 to size
                         String name
                         String value
          U32 numPolyHedronPoints
               for 0 to numPolyHedronPoints
                    Point3F point
          U32 numPolyHedronPlanes
               for 0 to numPolyHedronPlanes
                    PlaneF plane
          U32 numPolyHedronEdges
               for 0 to numPolyHedronEdges
                    U32 face0
                    U32 face1
                    U32 vertex0
                    U32 vertex1
          Point3F offset
U32 numInteriorPathFollowers
      for 0 to numInteriorPathFollowers
          String name
          String datablock
          U32 interiorResIndex
          Point3F offset
          Dictionary
               U32 size
                    for 0 to size
                         String name
                         String value
          U32 numTriggerIds
               for 0 to numTriggerIds
                    U32 triggerId
          U32 numWayPoints
               for 0 to numWayPoints
                    Point3F pos
                    QuatF   rot
                    U32 msToNext
                    U32 smoothingType
          U32 totalMS
U32 numForceFields
     for 0 to numForceFields
          U32 forceFieldFileVersion
          String name
          U32 numTriggers
               for 0 to numTriggers
                    String trigger
          Box3F boundingBox
          SphereF boundingSphere
          U32 numNormals
               for 0 to numNormals
                    Point3F normal
          U32 numPlanes
               for 0 to numPlanes
                    U32 normalIndex
                    F32 planeDistance
          U32 numBSPNodes
               for 0 to numBSPNodes
                    U16 planeIndex
                    U16 frontIndex
                    U16 backIndex
          U32 numBSPSolidLeaves
               for 0 to numBSPSolidLeaves
                    U32 surfaceIndex
                    U16 surfaceCount
          U32 numWindings
               U32 index
          U32 numSurfaces
               for 0 to numSurfaces
                    U32 windingStart
                    U8   windingCount
                    U16 planeIndex
                    U8   surfaceFlags
                    U32 fanMask
          U32 numSolideLeafSurfaces
          for 0 to numSolideLeafSurfaces
               U32 surfaceIndex
          ColorI
               U8 red
               U8 green
               U8 blue
               U8 alpha
U32 numAISpecialNodes
     for 0 to numAISpecialNodes
          String name
          Point3F position
U32 readVehicleCollision
      if (readVehicleCollision == 1)
          VehicleCollision
               U32 vehicleCollisionFileVersion
               U32 numVehicleConvexHulls
                    for 0 to numVehicleConvexHulls
                         U32 hullStart
                         U16 hullCount
                         F32 minX
                         F32 maxX
                         F32 minY
                         F32 maxY
                         F32 minZ
                         F32 maxZ
                         U32 surfaceStart
                         U16 surfaceCount
                         U32 planeStart
                         U32 polyListPlaneStart
                         U32 polyListPointStart
                         U32 polyListStringStart
               U32 numVehicleConvexHullEmitStrings
                    for 0 to numVehicleConvexHullEmitStrings
                         U8 vehicleConvexHullEmitStringCharacter
               U32 numVehicleHullIndices
                    for 0 to numVehicleHullIndices
                         U32 vehicleHullIndex
               U32 numVehicleHullPlaneIndices
                    for 0 to numVehicleHullPlaneIndices
                         U16 vehicleHullPlaneIndex
               U32 numVehicleHullEmitStringIndices
                    for 0 to numVehicleHullEmitStringIndices
                         U32 vehicleHullEmitStringIndex
               U32 numVehicleHullSurfaceIndices
                    for 0 to numVehicleHullSurfaceIndices
                         U32 vehicleHullSurfaceIndex
               U32 numVehiclePolyListPlanes
                    for 0 to numVehiclePolyListPlanes
                         U16 vehiclePloyListPlaneIndex
               U32 numVehiclePolyListPoints
                    for 0 to numVehiclePolyListPoints
                         U32 vehiclePolyListPointIndex
               U32 numVehiclePolyListStrings
                    for 0 to numVehiclePolyListStrings
                         U8 vehiclePolyListStringCharacter
               U32 numVehicleNullSurfaces
                    for 0 to numVehicleNullSurfaces
                         U32 windingStart
                         U16 planeIndex
                         U8   surfaceFlags
                         U32 windingCount
U32 UNKNOWN
U32 UNKNOWN
U32 UNKNOWN
U32 UNKNOWN
U32 readGameEntities
     if (readGameEntities == 2)
          U32 numGameEntities
               for 0 to numGameEntities
                    ItrGameEntity
                         String datablock
                         String gameClass
                         Point3F position
                         Dictionary properties
U32 dummy