Collision Map Asset (MW3)

From COD Engine Research
Jump to: navigation, search

The collision map (or clip map) has existed on every Call of Duty so far and is part of the D3DBSP system produced by Radiant. Modern Warfare 3 is the first Call of Duty to have only one clip map asset type per executable (col_map_mp on MP and col_map_sp on SP).

typedef char cbrushedge_t;
#pragma pack(push, 4)
struct cplane_s
  float normal[3];
  float dist;
  char type;
  char signbits;
struct cStaticModel_s
  XModel *xmodel;
  float origin[3];
  float invScaledAxis[3][3];
  float absmin[3];
  float absmax[3];
struct dmaterial_t
  char * material;
  int surfaceFlags;
  int contentFlags;
struct cbrushside_t
  cplane_s *plane;
  unsigned int materialNum;
struct cNode_t
  cplane_s *plane;
  __int16 children[2];
struct cLeaf_t
  unsigned __int16 firstCollAabbIndex;
  unsigned __int16 collAabbCount;
  int brushContents;
  int terrainContents;
  float mins[3];
  float maxs[3];
  int leafBrushNode;
struct cLeafBrushNodeLeaf_t
  unsigned __int16 *brushes;
struct cLeafBrushNodeChildren_t
  float dist;
  float range;
  unsigned __int16 childOffset[6];
union cLeafBrushNodeData_t
  cLeafBrushNodeLeaf_t leaf;
  cLeafBrushNodeChildren_t children;
struct cLeafBrushNode_s
  char axis;
  __int16 leafBrushCount;
  int contents;
  cLeafBrushNodeData_t data;
struct CollisionBorder
  float distEq[3];
  float zBase;
  float zSlope;
  float start;
  float length;
struct CollisionPartition
  char triCount;
  char borderCount;
  int firstTri;
  CollisionBorder *borders;
union CollisionAabbTreeIndex
  int firstChildIndex;
  int partitionIndex;
struct CollisionAabbTree
  float origin[3];
  float halfSize[3];
  unsigned __int16 materialIndex;
  unsigned __int16 childCount;
  CollisionAabbTreeIndex u;
struct cbrush_t
  int contents;
  cbrushside_t * sides;
  cbrushedge_t * edge;
       char unknown[0x18];
enum DynEntityType
struct GfxPlacement
  float quat[4];
  float origin[3];
struct PhysMass
  float centerOfMass[3];
  float momentsOfInertia[3];
  float productsOfInertia[3];
  int contents;
struct DynEntityDef
  DynEntityType type;
  GfxPlacement pose;
  XModel *xModel;
  unsigned __int16 brushModel;
  unsigned __int16 physicsBrushModel;
  FxEffectDef *destroyFx;
  PhysPreset *physPreset;
  int health;
  PhysMass mass;
       char (*unknown)[0x2C];
struct DynEntityPose
  GfxPlacement pose;
  float radius;
struct DynEntityClient
  int physObjId;
  unsigned int flags;
  unsigned __int16 lightingHandle;
  int health;
struct DynEntityColl
  unsigned __int16 sector;
  unsigned __int16 nextEntInSector;
  float linkMins[2];
  float linkMaxs[2];
struct unknownInternalClipMapStruct1
  int planeCount;
  cplane_s *planes;
  unsigned int numMaterials;
  dmaterial_t *materials;
  unsigned int numBrushSides;
  cbrushside_t *brushsides;
  unsigned int numBrushEdges;
  cbrushedge_t *brushEdges;
  unsigned int leafbrushNodesCount;
  cLeafBrushNode_s *leafbrushNodes;
  unsigned int numLeafBrushes;
  unsigned __int16 *leafbrushes;
  unsigned __int16 numBrushes;
  cbrush_t *brushes;
       char * unknown1;   //Size = ((numBrushes << 1) + numBrushes) << 3
  unsigned int *leafsurfaces;   //Count = numBrushes
struct unknownInternalClipMapStruct2
  char * unknownString;
  char unknown[0x10];
struct clipMap_t
  const char *name;
       int unknown1;
       unknownInternalClipMapStruct1 unknownEmbeddedStruct1;
       unknownInternalClipMapStruct1 * unknownStruct1;
  unsigned int numStaticModels;
  cStaticModel_s *staticModelList;
  unsigned int numNodes;
  cNode_t *nodes;
  unsigned int numLeafs;
  cLeaf_t *leafs;
  unsigned int vertCount;
  float (*verts)[3];
  int triCount;
  unsigned __int16 *triIndices;
  char *triEdgeIsWalkable; //Size = ((triCount << 1) + triCount + 0x1F) >> 3 << 2
  int borderCount;
  CollisionBorder *borders;
  int partitionCount;
  CollisionPartition *partitions;
  int aabbTreeCount;
  CollisionAabbTree *aabbTrees;
       unsigned int unknownCount1;
       unknownInternalClipMapStruct1 * unknownStructArray1; //Count = unknownCount1;
  MapEnts *mapEnts;
       unknownInternalClipMapStruct2 * unknownStructArray2; //Count = unknownCount2;
       byte unknownCount2;
       unknownInternalMapEnts1 unknownEmbeddedStruct2; //Refer to the map_ents asset
       unsigned short unknownCount3;
       char * unknown2;   //This is loaded before unknownStructArray1, Size = unknownCount3 * 0x1C
  unsigned __int16 dynEntCount[2];
  DynEntityDef *dynEntDefList[2];
  DynEntityPose *dynEntPoseList[2];
  DynEntityClient *dynEntClientList[2];
  DynEntityColl *dynEntCollList[2];
  char unknown5[0x18];
#pragma pack(pop)

Keep in mind that the checksum is checked on other clients using the mapcrc dvar.

Source Format

The currently accepted source format is to dump the verticies and faces to "raw/maps/mp/(MAPNAME).d3dbsp.obj" because obj files are simple and easy to dump to. This clearly skips most of the clip map, so a more effiecient dumping method must be found.