XModel Surface Asset

From COD Engine Research
Jump to: navigation, search

The xmodel surface (xmodelsurf) is an asset dedicated to holding the XSurfaces from the XModel. This asset was added on Modern Warfare 2, and stayed for Modern Warfare 3 and Ghosts, Treyarch however continues to keep this part of the XModel asset.

Modern Warfare 2

struct XSurfaceVertexInfo
{
  __int16 vertCount[4];
  unsigned __int16 *vertsBlend;
 
  /*Count... Ok, here we go...
 
   (((vertCount[2] << 2) + vertCount[2]) +
  ((vertCount[3] << 3) - vertCount[3]) +
  ((vertCount[1] << 1) + vertCount[1])
  + vertCount[0]) << 1*/
};
 
union GfxColor
{
  unsigned int packed;
  char array[4];
};
 
union PackedTexCoords
{
  unsigned int packed;
};
 
union PackedUnitVec
{
  unsigned int packed;
};
 
struct GfxPackedVertex
{
  float xyz[3];
  float binormalSign;
  GfxColor color;
  PackedTexCoords texCoord;
  PackedUnitVec normal;
  PackedUnitVec tangent;
};
 
struct XSurfaceCollisionAabb
{
  unsigned __int16 mins[3];
  unsigned __int16 maxs[3];
};
 
struct XSurfaceCollisionNode
{
  XSurfaceCollisionAabb aabb;
  unsigned __int16 childBeginIndex;
  unsigned __int16 childCount;
};
 
struct XSurfaceCollisionLeaf
{
  unsigned __int16 triangleBeginIndex;
};
 
struct XSurfaceCollisionTree
{
  float trans[3];
  float scale[3];
  unsigned int nodeCount;
  XSurfaceCollisionNode *nodes;
  unsigned int leafCount;
  XSurfaceCollisionLeaf *leafs;
};
 
struct XRigidVertList
{
  unsigned __int16 boneOffset;
  unsigned __int16 vertCount;
  unsigned __int16 triOffset;
  unsigned __int16 triCount;
  XSurfaceCollisionTree *collisionTree;
};
 
struct XSurface
{
  char tileMode;
  bool deformed;
  unsigned __int16 vertCount;
  unsigned __int16 triCount;
  short _pad;
  unsigned __int16 (*triIndices)[3];                  //Count = triCount * 3 (groups of 3)
  XSurfaceVertexInfo vertexInfo;
  GfxPackedVertex * packedVerticies;
  IDirect3DVertexBuffer9 vertexBuffer;
  unsigned int vertListCount;
  XRigidVertList * rigidVertLists;
  IDirect3DIndexBuffer9 indexBuffer;
       char unknown[0x18];
};
 
struct ModelSurface
{
  char * name;
  XSurface * xSurficies;
  short xSurficiesCount; //This is a copy of the count, the actual count is loaded from the parent XModelStreamInfo
  short _pad;
       char unknown[0x18];
};

Modern Warfare 3

struct XSurfaceVertexInfo
{
  __int16 vertCount[4];
  unsigned __int16 *vertsBlend;
 
  /*
  Count... Ok, here we go...
 
   (((vertCount[2] << 2) + vertCount[2]) +
  ((vertCount[3] << 3) - vertCount[3]) +
  ((vertCount[1] << 1) + vertCount[1])
  + vertCount[0]) << 1*/
};
 
union GfxColor
{
  unsigned int packed;
  char array[4];
};
 
union PackedTexCoords
{
  unsigned int packed;
};
 
union PackedUnitVec
{
  unsigned int packed;
};
 
struct GfxPackedVertex
{
  float xyz[3];
  float binormalSign;
  GfxColor color;
  PackedTexCoords texCoord;
  PackedUnitVec normal;
  PackedUnitVec tangent;
};
 
struct XSurfaceCollisionAabb
{
  unsigned __int16 mins[3];
  unsigned __int16 maxs[3];
};
 
struct XSurfaceCollisionNode
{
  XSurfaceCollisionAabb aabb;
  unsigned __int16 childBeginIndex;
  unsigned __int16 childCount;
};
 
struct XSurfaceCollisionLeaf
{
  unsigned __int16 triangleBeginIndex;
};
 
struct XSurfaceCollisionTree
{
  float trans[3];
  float scale[3];
  unsigned int nodeCount;
  XSurfaceCollisionNode *nodes;
  unsigned int leafCount;
  XSurfaceCollisionLeaf *leafs;
};
 
struct XRigidVertList
{
  unsigned __int16 boneOffset;
  unsigned __int16 vertCount;
  unsigned __int16 triOffset;
  unsigned __int16 triCount;
  XSurfaceCollisionTree *collisionTree;
};
 
struct unknownUnion
{
  GfxPackedVertex * packedVerticies;
       char * unknown1;  //Size = ((vertCount << 1) + vertCount) << 3
       char * unknown2;  //Size = ((vertCount << 2) + vertCount) << 2
};
 
struct XSurface
{
  char tileMode;
  bool deformed;
  unsigned __int16 vertCount;
  unsigned __int16 triCount;
  short _padding;
       int unknown1;
  unsigned __int16 (*triIndices)[3];                  //Count = triCount * 3 (groups of 3)
  XSurfaceVertexInfo vertexInfo;
        unknownUnion verticies;
  IDirect3DVertexBuffer9 vertexBuffer;
  unsigned int vertListCount;
  XRigidVertList * rigidVertLists;
  IDirect3DIndexBuffer9 indexBuffer;
       char unknown2[0x18];
};
 
struct ModelSurface
{
  char * name;
  XSurface * xSurficies;
  short xSurficiesCount; //This is a copy of the count, the actual count is loaded from the parent XModelStreamInfo
  short _pad;
  char unknown[0x18];
};

Ghosts

union GfxColor
{
  unsigned int packed;
  char array[4];
};
 
union PackedTexCoords
{
  unsigned int packed;
};
 
union PackedUnitVec
{
  unsigned int packed;
};
 
struct GfxPackedVertex
{
  float xyz[3];
  float binormalSign;
  GfxColor color;
  PackedTexCoords texCoord;
  PackedUnitVec normal;
  PackedUnitVec tangent;
};
 
struct XSurfaceCollisionAabb
{
  unsigned __int16 mins[3];
  unsigned __int16 maxs[3];
};
 
struct XSurfaceCollisionNode
{
  XSurfaceCollisionAabb aabb;
  unsigned __int16 childBeginIndex;
  unsigned __int16 childCount;
};
 
struct XSurfaceCollisionLeaf
{
  unsigned __int16 triangleBeginIndex;
};
 
struct XSurfaceCollisionTree
{
  float trans[3];
  float scale[3];
  unsigned int nodeCount;
  XSurfaceCollisionNode *nodes;
  unsigned int leafCount;
  XSurfaceCollisionLeaf *leafs;
};
 
struct XRigidVertList
{
  unsigned __int16 boneOffset;
  unsigned __int16 vertCount;
  unsigned __int16 triOffset;
  unsigned __int16 triCount;
  XSurfaceCollisionTree *collisionTree;
};
 
union unknownUnion
{
  GfxPackedVertex * packedVerticies;
       char * unknown1;  //Size = vertCount << 5
       char * unknown2;  //Size = ((vertCount << 1) + vertCount) << 3
       char * unknown3;  //Size = ((vertCount << 1) + vertCount) << 3
       char * unknown4;  //Size = ((vertCount << 2) + vertCount) << 2
};
 
struct XSurface
{
  char tileMode;
  bool deformed;
  unsigned __int16 vertCount;
  byte vertListCount;
  unsigned __int16 triCount;
  __int16 vertCount[4];
       unknownUnion verticies;
       char * unknown2; //Size = ((vertCount << 1) + vertCount) << 1
  IDirect3DVertexBuffer9 vertexBuffer;
  IDirect3DIndexBuffer9 indexBuffer;
  XRigidVertList * rigidVertLists;
  unsigned __int16 *vertsBlend;
       char unknown3[0x20];
};
 
struct ModelSurface
{
  char * name;
  XSurface * xSurficies;
  short xSurficiesCount; //This is a copy of the count, the actual count is loaded from the parent XModelStreamInfo
  short unknownShort;
  char unknown[0x18];
};