DIF File Format Specification
InteriorResource Version 44
Interior Version 14
U32 interiorResourceFileVersion
bool previewIncluded
if (previewIncluded)
PNG previewBitmap
U32 numDetailLevels
for 0 to numDetailLevels
Interior
U32 detailLevel
U32 minPixels
BoxF boundingBox
SphereF boundingSphere
Bool hasAlarmState
U32 numNormals
for 0 to numNormals
Point3F normal
U32 numPlanes
for 0 to numPlanes
U32 normalIndex
F32 planeDistance
U32 numPoints
for 0 to numPoints
Point3F point
for 0 to numPointVisibilities
U8 pointVisibility
U32 numTexGenEqs
for 0 to numTexGenEQs
PlaneF planeX
PlaneF planeY
U32 numBSPNodes
for 0 to numBSPNodes
U16 planeIndex
U32 frontIndex
U32 backIndex
for 0 to numBSPSolidLeaves
U32 surfaceIndex
U16 surfaceCount
U32 numMaterials
for 0 to numMaterials
String
for 0 to length
U8 character
U32 numWindings
for 0 to numWindings
U32 index
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
U16 surfaceCount
U32 staticMeshStart
U32 staticMeshCount
U16 flags
U32 numZoneSurfaces
for 0 to numZoneSurfaces
U16 zoneSurface
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
U32 windingCount
U16 planeIndex
U16 textureIndex
U32 texGenIndex
U8 surfaceFlags
U32 fanMask
LightMapTexGen
U16 finalWord
F32 texGenXDistance
F32 texGenYDistance
U16 lightCount
U32 lightStateInfoStart
U32 mapOffsetX
U32 mapOffsetY
U32 mapSizeX
U32 mapSizeY
bool unused
for 0 to numNormalLMapIndices
U32 normalLMapIndex
for 0 to numAlarmLMapIndices
U32 alarmLMapIndex
U32 numNullSurfaces
for 0 to numNullSurfaces
U32 windingStart
U16 planeIndex
U8 surfaceFlags
U32 windingCount
U32 numLightMaps
for 0 to numLightMaps
PNG lightMap
PNG lightDirMap
bool keepLightMap
for 0 to numSolidLeafSurfaces
U32 solidLeafSurface
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 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
for 0 to numConvexHullEmitStrings
U8 convexHullEmitStringCharacter
U32 numHullIndices
for 0 to numHullIndices
U32 hullIndex
for 0 to numHullPlaneIndices
U16 hullPlaneIndex
for 0 to numHullEmitStringIndices
U32 hullEmitStringIndex
for 0 to numHullSurfaceIndices
U32 hullSurfaceIndex
for 0 to numPolyListPlanes
U16 ployListPlaneIndex
for 0 to numPolyListPoints
U32 polyListPointIndex
for 0 to numPolyListStrings
U8 polyListStringCharacter
for 0 to NumCoordBins * NumCoordBins (16 * 16 by default)
U32 binStart
U32 binCount
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
if (extendedLightMapData == 1)
U32 lightMapBorderSize
U32 dummy
U32 numSubObjects
for 0 to numSobObjects
Interior subObject
U32 numTriggers
for 0 to numTriggers
String name
String datablock
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
for 0 to numInteriorPathFollowers
String name
String datablock
U32 interiorResIndex
Point3F offset
Dictionary
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
for 0 to numAISpecialNodes
String name
Point3F position
U32 readVehicleCollision
if (readVehicleCollision == 1)
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 readGameEntities
if (readGameEntities == 2)
U32 numGameEntities
for 0 to numGameEntities
ItrGameEntity
String datablock
String gameClass
Point3F position
Dictionary properties
U32 dummy
Descriptions
interiorResourceFileVersion
The file version for this InteriorResource. Not to be confused with the file version for the Interior read.
Depreciated - A preview bitmap can be in inserted into the InteriorResource
mDetailLevels
Each DIF/InteriorResource can actually have multiple Interior files saved into it to be used as the different levels of detail
for rendering.
The file version for this Interior
The detail number that this Interior corresponds to
The minimum pixel size that this Interior should start rendering at if there is more that one LOD in the InteriorInstance
An axis-aligned bounding box should exactly encompess all of the geometry
A sphere that completely encloses the geometry
Depreciated - denotes whether or not the Interior has alarm lighting baked in
Depreciated
These planes are used by the surfaces, bsp nodes, and hulls for collision and clipping. They are defined by a normal and a
distance along that normal. This allows the normals to be shared to save on file size. The planes are written out as a list of
normals and then a list of indices into those normals and a distance along that normal. For most of the data in the Interior
(bsp node plane indices being the exception), the plane indices can be stored with an |= 0x8000 to indicate that it is an
inverted version of the plane indexed.
These are all of the Point3F's that make up the geometry in the Interior
These aren't used by the engine for anything but they match up 1:1 to the mPoints. A value of 1 indicates
that the point is part of the visible geometry while a value of 0 indicates that the point is only
used as part of the collision hulls.
The list of texgens that the surfaces index into. Each texgen is comprised of a PlaneF for calculating the u
coordinates and a PlaneF for calculating the v coordinates for each vertex of each surface.
The bsp nodes are used primarily for ray cast collisions. They include an index into the planes as well as an
index to the a front node and a back node. If either of the node indices is masked by 0x80000 then it is a
leaf index. If the leaf index is masked by 0x40000 then it is an empty leaf and you can get its zone by using
(index & ~0xC0000). If it is not a leaf index then it is an index into the solid bsp leaves. You can retrieve the
solid leaf index with (index & ~0xC0000). It is important to note that the engine does not support "inverted"
plane indices for bsp nodes.
The solid bsp leaves that are used for ray cast collision. They reference a starting point and number of surfaces
A list of the textures used by the surfaces. They should not include path information directly in the material
name. The IO for MaterialList's is handled external to the Interior code and its format can change.
A list of indices into mPoints which are used by the surfaces and portals.
The winding indices are pairs of start and count values used by the portals to get at their list of indices from mWindings.
A list of all of the edges in the Interior. It defines the edge with two indices into mPoints and two indices into mSurfaces.
The Interior is split into multiple zones which are rendered according to which portals are in view of the camera.
Each zone references a list of surfaces that belong to it and a list of portals which are attached to it.
A list of the surfaces that belong to the zones in the Interior. These are used to decide which surfaces
are rendered.
A list of the portals that belong to the zones in the Interior.
Portals are coplanar (planeIndex) triangle fans that link two zones together. The triangle fans are indexed by using a list
of mWindingIndices (triFanStart and triFanCount) which index into the mWindings array.
The surfaces are the core geometry of the Interior. The are used by the zones, the bsp solid leaves, and the convex hulls.
They are also the only geometry in the Interior intended for rendering.
Each surface is defined by a list of indices (windingStart and windingCount) from mWindings, an index (planeIndex) into mPlanes
(which may be masked as inverted), an index (textureIndex) into the MaterialList for its texture, an index (texGenIndex) into the
mTexGenEqs, a set of surfaceFlags (which indicate whether or not it is an outside surface or a static mesh surface), and a
fanMask (used to determine if a point should be in a collision fan - points inserted to fix t-junctions should not).
The lightCount and lightStateInfoStart data are used for animated lights and are depreciated.
The surface's lightmap index can be found in mNormalLMapIndices (1:1 relationship with the surfaces). It actually only uses a small
subset of a larger shared lightmap sheet as defined by mapSizeX, mapSizeY, mapOffsetX, and mapOffsetY. The lightmap texgens
are stored in an encoded form in the surface data (see readLMapTexGen() for more information).
An index into the lightmaps. There is one for each surface.
Depreciated - An index into the lightmaps. There is one for each surface. A value of 255 indicates that the
index is unsued.
Null surfaces are surfaces that are used for collision but not rendering. The surfaces are defined by a list of
indices and a plane. Note that the null surfaces are not a triangle strip while the surfaces are.
The lightmaps used for rendering the surfaces. Multiple lightmaps are packed into a larger sheets. Each lightmap
has a flag to indicate whether or not to keep the lightmap bits after uploading them to the Lightmap Manager.
List of indices into surfaces and null surfaces used by the solid bsp leaves. Null surface indices are masked by
0x80000000.
Depreciated - Animated lights
Depreciated - The color states and info for animated lights
Depreciated - Used for tracking the various states of animated lights
Depreciated - Used to store intesity maps for animated lights
Depreciated - Used to store the name of animated lights
Mirrors are currently the only InteriorSubObject's that are implemented. Please refer to MirrorSubObject::_readISO() for more
information on its file format.
The convex hulls are the closed convex volumes that are used to gather collision data in Torque (getFeatures() and getPolyList()).
Each convex references a list of surfaces (surfaceStart and surfaceCount), a list of indices (hullStart and hullCount) that translates
its local point indices into mPoints, a list of indices (planeStart) that translates its local plane indices into mPlanes, a list of indices
(hullStart) into the emit strings, a list of indices (polyListPlaneStart) that translates its local plane indices into mPlanes for the polylist
system, a list of indices (polyListPointStart) that translates its local point indices into mPoints, and an index in mPolyListStrings for
where its polylist string starts.
The convex hull emit strings and supporting index arrays are used primarily for getFeatures() which is integral to the GJK convex-to-
convex collision system in Torque. Each emit string describes a convex silhouette of a the convex hull from each of the points on the
convex hull.
The polylist and supporting index arrays are primarily used for getPolyList() which is used in various other collision subsystems (like
Player) and in the calculation of dynamic shadows. It describes the convex hull in its entirety (points, indices, planes).
Also included in the convex hull data are the max and min points of its axis aligned bounding box.
The convex hull emit strings are used to get a convex silhouette of a convex hull for use in Torque's GJK collisions (getFeatures()).
The emit string for a point has this format:
numVertices
for 0 to numVertices
a relative index into this hull's mHullIndices which map the hull's local vertex indices to the Interior's mPoints
numEdges (it is important to note that this includes all of the edges of the faces attached to the point we are emitting for)
for 0 to numEdges
a relative index into the vertex list above for the first vertex on the edge
a relative index into the vertex list above for the other vertex on the edge
numFaces
for 0 to numFaces
numPoints
a relative index into mHullPlaneIndices for the face's plane
for 0 to numPoints
a relative index into the vertex list above
The convex hull emit strings can and often are shared by multiple hulls since they use relative indices (a corner on a cube looks like
the corner on another cube no matter what the actual vertex values are when using indices that are local to the convexes).
These remap the local point indices of the convex hulls to the Interior's mPoints array.
These remap the local plane indices of the convex hulls to the Interior's mPlanes array.
The hull emit string indices are a list of indices into the mConvexHullEmitStrings (which can be shared by multiple hull points). There
should be an emit string index for each point on each hull (as referenced by hullStart and hullCount).
A list of indices into mSurfaces which indicates which surfaces belong to which convex collision hull (as referenced by surfaceStart and surfaceCount).
Null surface indices are masked by 0x80000000.
These remap the local plane indices of the convex hulls to the Interior's mPlanes array.
These remap the local point indices of the convex hulls to the Interior's mPoints array.
The poly list strings are used for quickly getting at the geometry data of the convex hulls. It must describe a closed convex volume.
This data can easily be generated by processHullPolyLists() if the convex hull surfaces are already set up. The format is:
numPlanes
for 0 to numPlanes
a relative index into mPolyListPlanes
numPoints high byte
numPoints low byte
for 0 to numPoints
a relative index into mPolyListPoints
numSurfaces
for 0 to numSurfaces
numSurfacePoints
mask
a relative index into the plane list above
for 0 to numSurfacePoints
a relative index into the poly list above high bit
a relative index into the poly list above low bit
The coord bins are a 2d grid of the volume of the Interior's bounding box. The convex hulls are then sorted into their respective bins according to
to their bounding boxes.
A list of the indices of the convex brushes that belong in each bin (binStart through binCount).
Depreciated - used to indicate which two axii are used for the 2d bins grid...currently only BinsXY is used
Depreciated - the base ambient color for the Interior lightmaps
Depreciated - the base alarm ambient color for the Interior alarm lightmaps
These are the lightmapped detail meshes that get baked into the Interior. They include simple mesh data (vertices, indices, uvs, textures, and lightmaps).
There is also some extended data (hasSolid, hasTranslucency, bounds, transform, scale) that are used in the rendering of the mesh.
Two things are important to note here:
1) Baking the diffuse bitmaps into the Interior file has been depreciated in favor of having the textures external to the Interior file and as such may not
work correctly
2) The IO for static meshes is implemented externally to the Interior code and can change from the format specified here
These are the actual normals used by the texture matrices. They can and often are shared among multiple texture matrices.
The texture matrices are used to properly transform lighting operations into texture space. This is mostly used by shaders and is essential for smooth
shading on Interiors but you can also use it to get point normals by accessing the N normal. Each texture matrix is comprised of three indices into the
mNormals array. They are mapped to each vertex on each face through mTexMatIndices.
Each point on each surface should have an index into the mTexMatrices array for its own texture matrix.
If extendedLightMapData is set to 1 then the next value read will be the padding around the lightmaps. This is used to combat the lightmap
bleeding that can occur when anti-aliasing is enabled on a video card (since it samples outside the uv coords).
Used for storing Interior based subobjects
Depreciated - Allows the InteriorInstance to manager its own set of Trigger objects...mostly used in conjunction with PathedInteriors
Depreciated - Stores a list of PathedInterior object along with their paths and links to triggers
Depreciated - Special collision brushes designed to block moving objects in the world
Depreciated - Nodes used for AI navigation
Special convex brushes that are used only for vehicle collision. These are used in place where you don't want the vehicle to be able to procede or in places
where the normal brushes are dense enough to cause collision slow downs. These brushes' emit strings and polylist strings are constructed in the same way
that convex hulls' are.
Game Entities are placeholders for in-game objects. By running the magicButton() script command on an InteriorInstance you can instantiate these entities
into the current mission.