Collision Map Asset (BO3)

From COD Engine Research
Revision as of 19:36, 31 October 2015 by CraigChrist8239 (talk | contribs) (Created page with "__NOTOC__ Category:Assets Category:BO3 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 3 has merged the SP and MP map types, like Infinity Ward started doing on Modern Warfare 3.

enum DynEntityCollType
{
  DYNENT_COLL_CLIENT_FIRST = 0x0,
  DYNENT_COLL_CLIENT_MODEL = 0x0,
  DYNENT_COLL_CLIENT_BRUSH = 0x1,
  DYNENT_COLL_SERVER_FIRST = 0x2,
  DYNENT_COLL_SERVER_MODEL = 0x2,
  DYNENT_COLL_SERVER_BRUSH = 0x3,
  DYNENT_COLL_COUNT = 0x4
};

struct cplane_s;
struct cmodel_t;

struct cStaticModelWritable
{
  unsigned __int16 nextModelInWorldSector;
};

#pragma pack(push, 2)
struct cbrushside_t
{
  cplane_s *plane;
  int cflags;
  int sflags;
};
#pragma pack(pop)

struct __declspec(align(8)) cbrush_t //Total size = 0x60
{
  vec3_t mins;
  int contents;
  vec3_t maxs;
  unsigned int numsides;
  cbrushside_t *sides;
  int axial_cflags[2][3];
  int axial_sflags[2][3];
  unsigned int numverts;
  vec3_t *verts; //Only 1 is loaded, at least on 360.
};

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

struct DObjAnimMat
{
  float quat[4];
  float trans[3];
  float transWeight;
};

struct cStaticModel_s
{
  cStaticModelWritable writable;
  XModel *xmodel;
  int contents;
  vec3_t origin;
  vec3_t invScaledAxis[3];
  vec3_t absmin;
  vec3_t absmax;
  unsigned int matCount;
  DObjAnimMat * mats;
       ScriptString unknownScriptString;
};
 
struct ClipMaterial
{
  const char *name;
  int surfaceFlags;
  int contentFlags;
};

struct cNode_t
{
  cplane_s *plane;
  __int32 children[2];
};

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 cLeaf_s
{
  unsigned __int16 firstCollAabbIndex;
  unsigned __int16 collAabbCount;
  int brushContents;
  int terrainContents;
  vec3_t mins;
  vec3_t maxs;
  int leafBrushNode;
  __int16 cluster;
      int unknown; //I'm not sure where the unknown 4 bytes fall, but theres an extra 4 bytes in BO3 somewhere in this struct. 
};

struct Bounds
{
  vec3_t midPoint;
  vec3_t halfSize;
};

struct ClipInfo
{
  int planeCount;
  cplane_s *planes;
  unsigned int numMaterials;
  ClipMaterial *materials;
  unsigned int numBrushSides;
  cbrushside_t *brushsides;
  unsigned int leafbrushNodesCount;
  cLeafBrushNode_s *leafbrushNodes;
  unsigned int numLeafBrushes;
  unsigned __int16 *leafbrushes;
  unsigned int brushVertCount;
  vec3_t *brushVerts;
  unsigned int nuinds;
  unsigned __int16 *uinds;
  unsigned __int16 numBrushes;
  cbrush_t *brushes;
  Bounds *brushBounds;
  int *brushContents;
};
 
struct cmodel_t
{
  vec3_t mins;
  vec3_t maxs;
  float radius;
  ClipInfo *info;
  cLeaf_s leaf;
};
 
const struct CollisionPartition
{
  char triCount;
  int firstTri;
  int nuinds;
  int fuind;
};
 
union CollisionAabbTreeIndex
{
  int firstChildIndex;
  int partitionIndex;
};
 
struct CollisionAabbTree
{
  vec3_t origin;
  unsigned __int16 materialIndex;
  unsigned __int16 childCount;
  vec3_t halfSize;
  CollisionAabbTreeIndex u;
};

struct GfxPlacement
{
  vec4_t quat;
  vec3_t origin;
};
 
struct DynEntityDef
{
  //DynEntityType type;//The first xmodel is at 0x1C so either this goes or GfxPlacement loses 4 bytes, which is unlikely since it's other references appear to be the same.
  GfxPlacement pose;
  XModel *xModel;
  XModel *destroyedxModel;
  unsigned __int16 brushModel;
  unsigned __int16 physicsBrushModel;
  FxEffectDef *destroyFx;
  unsigned int destroySound;
       FxEffectDef *unknownFx;
       FxEffectDef *unknownFxArray[3];
  PhysPreset *physPreset;
  __int16 physConstraints[4];
  int health;
  int flags;
  int contents;
  ScriptString targetname;
  ScriptString target;
};

struct DynEntityPose
{
  GfxPlacement pose;
  float radius;
};

typedef char DynEntityClient[0x80]; //This was only 0x14 on BO2, so something pretty big has been added.
 
struct DynEntityServer
{
  unsigned __int16 flags;
  int health;
};
 
struct DynEntityColl
{
  unsigned __int16 sector;
  unsigned __int16 nextEntInSector;
  vec3_t linkMins;
  vec3_t linkMaxs;
  int contents;
};

typedef char rope_t[0xE38]; //Not only has this gotten bigger but it got rid of the Material*. 

struct clipMap_t
{
  const char *name;
  int isInUse;
  ClipInfo info;
  ClipInfo *pInfo;
  unsigned int numStaticModels;
  cStaticModel_s *staticModelList;
  unsigned int numNodes;
  cNode_t *nodes;
  unsigned int numLeafs;
  cLeaf_s *leafs;
  unsigned int vertCount;
  vec3_t *verts;
  int triCount;
  unsigned __int16 *triIndices;
  char *triEdgeIsWalkable; //Size = (((triCount * 3) + 0x1F) >> 5) << 2
  int partitionCount;
  CollisionPartition *partitions;
  int aabbTreeCount;
  CollisionAabbTree *aabbTrees;
  unsigned int numSubModels;
  cmodel_t *cmodels;
  int numClusters;
  int clusterBytes;
  char *visibility; //Size = numClusters * clusterBytes
  int vised;
  MapEnts *mapEnts;
  cbrush_t *box_brush;
  cmodel_t box_model;
  unsigned __int16 originalDynEntCount;
  unsigned __int16 dynEntCount[4];  //Refer to DynEntityCollType
  DynEntityDef *dynEntDefList[2];
  DynEntityPose *dynEntPoseList[2];
  DynEntityClient *dynEntClientList[2];
  DynEntityServer *dynEntServerList[2];
  DynEntityColl *dynEntCollList[4];
  int num_constraints;
  PhysConstraint *constraints;
  int max_ropes;
  rope_t *ropes;
       ScriptString unknownScriptStringArray[0x20];
       char unknown[0x10];
  int checksum; //I'm not entirely sure that checksum is the very last item, since there are unknown elements just previous. However it has always been the last element, and probably still is.
};
#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.