Collision Map Asset (BO2)

From COD Engine Research
Revision as of 22:39, 19 January 2014 by CraigChrist8239 (talk | contribs) (Created page with "__NOTOC__ Category:Assets Category:BO2 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. B...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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. Black Ops 2 still has 2 clip map asset types (col_map_sp and col_map_mp) and they are loaded exactly the same.

struct cStaticModelWritable
{
  unsigned __int16 nextModelInWorldSector;
};

#pragma pack(push, 2)
struct cbrushside_t
{
  cplane_s *plane;
  unsigned int materialNum;
  __int16 firstAdjacentSideOffset;
  char edgeCount;
};
#pragma pack(pop)

struct __declspec(align(16)) cbrush_t
{
  float mins[3];
  int contents;
  float maxs[3];
  unsigned int numsides;
  cbrushside_t *sides;
       char unknown1[0x34];
       char (*unknown2)[0xC];
       int unknown3;
};

enum DynEntityType
{
  DYNENT_TYPE_INVALID = 0x0,
  DYNENT_TYPE_CLUTTER = 0x1,
  DYNENT_TYPE_DESTRUCT = 0x2,
  DYNENT_TYPE_COUNT = 0x3,
};

#pragma pack(push, 4)
struct cplane_s
{
  float normal[3];
  float dist;
  char type;
  char signbits;
};

struct cStaticModel_s
{
  cStaticModelWritable writable;
  XModel *xmodel;
  float origin[3];
  float invScaledAxis[3][3];
  float absmin[3];
  float absmax[3];
       int unknown;
};

struct dmaterial_t
{
  char *material;
  int surfaceFlags;
  int contentFlags;
};

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;
  __int16 cluster;
};

struct cLeafBrushNodeLeaf_t
{
  unsigned __int16 *brushes;
};

struct cLeafBrushNodeChildren_t
{
  float dist;
  float range;
  unsigned __int16 childOffset[2];
};

union cLeafBrushNodeData_t
{
  cLeafBrushNodeLeaf_t leaf;
  cLeafBrushNodeChildren_t children;
};

struct cLeafBrushNode_s
{
  char axis;
  __int16 leafBrushCount;
  int contents;
  cLeafBrushNodeData_t data;
};

struct CollisionBorder
{
  float zBase;
  float zSlope;
  float start;
  float length;
};

union CollisionAabbTreeIndex
{
  int firstChildIndex;
  int partitionIndex;
};

struct CollisionAabbTree
{
  float origin[3];
  float halfSize[3];
  unsigned __int16 materialIndex;
  unsigned __int16 childCount;
  CollisionAabbTreeIndex u;
};

struct GfxPlacement
{
  float quat[4];
  float origin[3];
};

struct XModelPiece
{
  XModel *model;
  float offset[3];
};

struct XModelPieces
{
  const char * name;
  int numpieces;
  XModelPiece *pieces;
};

struct PhysMass
{
  float centerOfMass[3];
  float momentsOfInertia[3];
};

struct DynEntityDef
{
  DynEntityType type;
  GfxPlacement pose;
  XModel *xModel;
  unsigned __int16 brushModel;
  unsigned __int16 physicsBrushModel;
  FxEffectDef *destroyFx;
  XModelPieces *destroyPieces;
  PhysPreset *physPreset;
  int health;
  PhysMass mass;
       ScriptString unknown[2];
};

struct DynEntityPose
{
  GfxPlacement pose;
  float radius;
};

struct unknownInternalClipMapStruct1
{
  int planeCount;
  cplane_s *planes;
  unsigned int numMaterials;
  dmaterial_t *materials;
  unsigned int numBrushSides;
  cbrushside_t *brushsides;
  unsigned int leafbrushNodesCount;
  cLeafBrushNode_s *leafbrushNodes;
  unsigned int numLeafBrushes;
  unsigned __int16 *leafbrushes;
  unsigned int brushVertCount;
  float (*brushVerts)[3];
  unsigned int uindsCount;
  unsigned short * uinds;
  unsigned __int16 numBrushes;
  cbrush_t *brushes;
       char * unknown1;   //Size = ((numBrushes << 1) + numBrushes) << 3
  unsigned int *leafsurfaces;   //Count = numBrushes
};

struct clipMap_t
{
  const char *name;
       int unknown;
       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 aabbTreeCount;
  CollisionAabbTree *aabbTrees;
       int unknownCount1;
       unknownInternalClipMapStruct1 * unknownStructArray1;
  int numClusters;
  int clusterBytes;
  char *visibility; //Size = numClusters * clusterBytes
  int vised;
  MapEnts *mapEnts;
       unknownInternalClipMapStruct1 unknownEmbeddedStruct2;
       int unknown1;
       unsigned short unknown3;
  unsigned __int16 dynEntCount[4];  //Refer to DYNENT_COLL_TYPE
  DynEntityDef *dynEntDefList[2];
  DynEntityPose *dynEntPoseList[2];
       char * dynEntClientList[2]; //Size = ((dynEntCount[i] << 2) + dynEntCount[i]) << 2
       char * dynEntServerList[2]; //Size =  dynEntCount[i] << 3
       char * dynEntCollList[4]; //Size = dynEntCount[i] << 5
  unsigned int constraintCount;
  PhysConstraint * constraints; //Refer to PhysConstraints asset.
  unsigned int ropeCount;
       char * ropes;  //Size = ropeCount * 0xC74
  int checksum;
};
#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.