Difference between revisions of "Collision Map Asset (WaW)"

From COD Engine Research
Jump to: navigation, search
 
Line 22: Line 22:
 
};
 
};
 
#pragma pack(pop)
 
#pragma pack(pop)
 
typedef char unknownVariable1[0xC];
 
  
 
struct __declspec(align(16)) cbrush_t
 
struct __declspec(align(16)) cbrush_t
Line 32: Line 30:
 
   unsigned int numsides;
 
   unsigned int numsides;
 
   cbrushside_t *sides;
 
   cbrushside_t *sides;
   __int16 axialMaterialNum[2][3];
+
   short axialMaterialNum[2][3];
 
   cbrushedge_t *baseAdjacentSide;
 
   cbrushedge_t *baseAdjacentSide;
   __int16 firstAdjacentSideOffsets[2][3];
+
   short firstAdjacentSideOffsets[2][3];
 
   char edgeCount[2][3];
 
   char edgeCount[2][3];
      unknownVariable1 *unknown;  
+
  unsigned int numVerts;
 +
  float *verts;  
 
};
 
};
  
Line 131: Line 130:
 
   char borderCount;
 
   char borderCount;
 
   int firstTri;
 
   int firstTri;
      int unknown[2];
+
  int nuinds;
 +
  int fuinds;
 
   CollisionBorder *borders;
 
   CollisionBorder *borders;
 
};
 
};
Line 201: Line 201:
 
   XModelPieces *destroyPieces;
 
   XModelPieces *destroyPieces;
 
   PhysPreset *physPreset;
 
   PhysPreset *physPreset;
 +
  unsigned char physConstraints[4];
 
   int health;
 
   int health;
 
   PhysMass mass;
 
   PhysMass mass;
      ScriptString unknown;
+
  int flags;
 +
  int contents;
 +
  ScriptString targetname;
 
};
 
};
  
Line 210: Line 213:
 
   GfxPlacement pose;
 
   GfxPlacement pose;
 
   float radius;
 
   float radius;
 +
};
 +
 +
struct DynEntityClient
 +
{
 +
  int physObjId;
 +
  unsigned short flags;
 +
  unsigned short lightingHandle;
 +
  int health;
 +
  unsigned short burnTime;
 +
  unsigned short fadeTime;
 +
};
 +
 +
struct DynEntityServer
 +
{
 +
  unsigned short flags;
 +
  int health;
 +
};
 +
 +
struct DynEntityColl
 +
{
 +
  unsigned short sector;
 +
  unsigned short nextEntInSector;
 +
  float linkMins[3];
 +
  float linkMaxs[3];
 +
  int contents;
 
};
 
};
  
Line 215: Line 243:
 
{
 
{
 
   const char *name;
 
   const char *name;
      int unknown;
+
  int isInUse;
 
   int planeCount;
 
   int planeCount;
 
   cplane_s *planes;
 
   cplane_s *planes;
Line 233: Line 261:
 
   cLeafBrushNode_s *leafbrushNodes; //Leafbrushes loaded before this in FFs.
 
   cLeafBrushNode_s *leafbrushNodes; //Leafbrushes loaded before this in FFs.
 
   unsigned int numLeafBrushes;
 
   unsigned int numLeafBrushes;
   unsigned __int16 *leafbrushes;
+
   unsigned short *leafbrushes;
 
   unsigned int numLeafSurfaces;
 
   unsigned int numLeafSurfaces;
 
   unsigned int *leafsurfaces;
 
   unsigned int *leafsurfaces;
Line 240: Line 268:
 
   unsigned int brushVertCount;
 
   unsigned int brushVertCount;
 
   float (*brushVerts)[3];
 
   float (*brushVerts)[3];
   unsigned int uindsCount;
+
   unsigned int nuinds;
 
   unsigned short * uinds;
 
   unsigned short * uinds;
 
   int triCount;
 
   int triCount;
   unsigned __int16 *triIndices;
+
   unsigned short *triIndices;
 
   char *triEdgeIsWalkable; //Size = ((triCount << 1) + triCount + 0x1F) >> 3 << 2
 
   char *triEdgeIsWalkable; //Size = ((triCount << 1) + triCount + 0x1F) >> 3 << 2
 
   int borderCount;
 
   int borderCount;
Line 253: Line 281:
 
   unsigned int numSubModels;
 
   unsigned int numSubModels;
 
   cmodel_t *cmodels;
 
   cmodel_t *cmodels;
   unsigned __int16 numBrushes;
+
   unsigned short numBrushes;
 
   cbrush_t *brushes;
 
   cbrush_t *brushes;
 
   int numClusters;
 
   int numClusters;
Line 262: Line 290:
 
   cbrush_t *box_brush;
 
   cbrush_t *box_brush;
 
   cmodel_t box_model;
 
   cmodel_t box_model;
      unsigned short unknown3;
+
  unsigned short originalDynEntCount;
   unsigned __int16 dynEntCount[4];  //Refer to DYNENT_COLL_TYPE
+
   unsigned short dynEntCount[4];  //Refer to DYNENT_COLL_TYPE
 
   DynEntityDef *dynEntDefList[2];
 
   DynEntityDef *dynEntDefList[2];
 
   DynEntityPose *dynEntPoseList[2];
 
   DynEntityPose *dynEntPoseList[2];
      char * dynEntClientList[2];
+
  DynEntityClient *dynEntClientList[2];
      char * dynEntServerList[2];
+
  DynEntityServer *dynEntServerList[2];
      char * dynEntCollList[4];
+
  DynEntityColl *dynEntCollList[4];
   unsigned int constraintCount;
+
   int num_constraints;
   PhysConstraint * constraints;
+
   PhysConstraint *constraints;
      int unknown9;
+
  unsigned int checksum;
 
};
 
};
 
#pragma pack(pop)
 
#pragma pack(pop)

Latest revision as of 18:05, 7 February 2015

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

typedef char cbrushedge_t;
 
struct cStaticModelWritable
{
  unsigned __int16 nextModelInWorldSector;
};
 
struct cplane_s;
 
#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;
  short axialMaterialNum[2][3];
  cbrushedge_t *baseAdjacentSide;
  short firstAdjacentSideOffsets[2][3];
  char edgeCount[2][3];
  unsigned int numVerts;
  float *verts; 
};
 
enum DYNENT_COLL_TYPE
{
  DYNENT_CLIENT_MODEL,
  DYNENT_CLIENT_BRUSH,
  DYNENT_SERVER_MODEL,
  DYNENT_SERVER_BRUSH
};
 
#pragma pack(push, 4)
struct cStaticModel_s
{
  cStaticModelWritable writable;
  XModel *xmodel;
  float origin[3];
  float invScaledAxis[3][3];
  float absmin[3];
  float absmax[3];
};
 
struct cplane_s
{
  float normal[3];
  float dist;
  char type;
  char signbits;
};
 
struct dmaterial_t
{
  char material[64];
  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 distEq[3];
  float zBase;
  float zSlope;
  float start;
  float length;
};
 
struct CollisionPartition
{
  char triCount;
  char borderCount;
  int firstTri;
  int nuinds;
  int fuinds;
  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 cmodel_t
{
  float mins[3];
  float maxs[3];
  float radius;
  cLeaf_t leaf;
};
 
enum DynEntityType
{
  DYNENT_TYPE_INVALID = 0x0,
  DYNENT_TYPE_CLUTTER = 0x1,
  DYNENT_TYPE_DESTRUCT = 0x2,
  DYNENT_TYPE_COUNT = 0x3,
};
 
struct GfxPlacement
{
  float quat[4];
  float origin[3];
};
 
struct XModelPiece
{
  XModel *model;
  float offset[3];
};
 
struct XModelPieces //Keep in mind that in WaW, XModelPieces is an unused asset
{
  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;
  unsigned char physConstraints[4];
  int health;
  PhysMass mass;
  int flags;
  int contents;
  ScriptString targetname;
};
 
struct DynEntityPose
{
  GfxPlacement pose;
  float radius;
};
 
struct DynEntityClient
{
  int physObjId;
  unsigned short flags;
  unsigned short lightingHandle;
  int health;
  unsigned short burnTime;
  unsigned short fadeTime;
};
 
struct DynEntityServer
{
  unsigned short flags;
  int health;
};
 
struct DynEntityColl
{
  unsigned short sector;
  unsigned short nextEntInSector;
  float linkMins[3];
  float linkMaxs[3];
  int contents;
};
 
struct clipMap_t
{
  const char *name;
  int isInUse;
  int planeCount;
  cplane_s *planes;
  unsigned int numStaticModels;
  cStaticModel_s *staticModelList;
  unsigned int numMaterials;
  dmaterial_t *materials;
  unsigned int numBrushSides;
  cbrushside_t *brushsides;
  unsigned int numBrushEdges;
  cbrushedge_t *brushEdges;
  unsigned int numNodes;
  cNode_t *nodes;
  unsigned int numLeafs;
  cLeaf_t *leafs;
  unsigned int leafbrushNodesCount;
  cLeafBrushNode_s *leafbrushNodes; //Leafbrushes loaded before this in FFs.
  unsigned int numLeafBrushes;
  unsigned short *leafbrushes;
  unsigned int numLeafSurfaces;
  unsigned int *leafsurfaces;
  unsigned int vertCount;
  float (*verts)[3];
  unsigned int brushVertCount;
  float (*brushVerts)[3];
  unsigned int nuinds;
  unsigned short * uinds;
  int triCount;
  unsigned short *triIndices;
  char *triEdgeIsWalkable; //Size = ((triCount << 1) + triCount + 0x1F) >> 3 << 2
  int borderCount;
  CollisionBorder *borders;
  int partitionCount;
  CollisionPartition *partitions;
  int aabbTreeCount;
  CollisionAabbTree *aabbTrees;
  unsigned int numSubModels;
  cmodel_t *cmodels;
  unsigned short numBrushes;
  cbrush_t *brushes;
  int numClusters;
  int clusterBytes;
  char *visibility; //Size = numClusters * clusterBytes
  int vised;
  MapEnts *mapEnts;
  cbrush_t *box_brush;
  cmodel_t box_model;
  unsigned short originalDynEntCount;
  unsigned short dynEntCount[4];  //Refer to DYNENT_COLL_TYPE
  DynEntityDef *dynEntDefList[2];
  DynEntityPose *dynEntPoseList[2];
  DynEntityClient *dynEntClientList[2];
  DynEntityServer *dynEntServerList[2];
  DynEntityColl *dynEntCollList[4];
  int num_constraints;
  PhysConstraint *constraints;
  unsigned 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.