Graphics Map Asset (BO2)

From COD Engine Research
Jump to: navigation, search

The graphics map (or gfx_map) has existed on every Call of Duty so far and is part of the D3DBSP system produced by Radiant. Where the collision map is used for collision data in the map, the graphics map holds visual systems such as lights and particularly the dPVS system. The Dynamic Potentially Visible Sets (dPVS) were developed by Umbra Software to compute visibility databases in real time, and power the Call of Duty engine to this day.

struct XModelDrawInfo
{
  char state;
  char lod;
  unsigned __int16 surfId;
};
 
struct GfxSceneDynModel
{
  XModelDrawInfo info;
  unsigned __int16 dynEntId;
  char primaryLightIndex;
  char reflectionProbeIndex;
};
 
struct BModelDrawInfo
{
  unsigned __int16 surfId;
};
 
struct GfxSceneDynBrush
{
  BModelDrawInfo info;
  unsigned __int16 dynEntId;
};
 
struct GfxStreamingAabbTree
{
  vec4_t mins;
  vec4_t maxs;
  float maxStreamingDistance;
  unsigned __int16 firstItem;
  unsigned __int16 itemCount;
  unsigned __int16 firstChild;
  unsigned __int16 childCount;
  unsigned __int16 smodelCount;
  unsigned __int16 surfaceCount;
};
 
struct GfxWorldStreamInfo
{
  int aabbTreeCount;
  GfxStreamingAabbTree *aabbTrees;
  int leafRefCount;
  int *leafRefs;
};
 
union GfxColor
{
  unsigned int packed;
  char array[4];
};
 
union PackedUnitVec
{
  unsigned int packed;
};
 
struct GfxWorldVertex
{
  float xyz[3];
  float binormalSign;
  GfxColor color;
  float texCoord[2];
  float lmapCoord[2];
  PackedUnitVec normal;
  PackedUnitVec tangent;
};
 
struct GfxWorldVertexData0
{
  GfxWorldVertex *vertices0;
  D3DVertexBuffer worldVb;
  unsigned int vertexDataSize1; 
  GfxWorldVertex * vertices1;
};
 
struct GfxWorldVertexData1
{
  char *data;
  D3DVertexBuffer layerVb;
};
 
struct __declspec(align(16)) GfxLight //Notice this is aligned to a 0x10 byte buffer meaning there should be 0xC bytes of padding at the end
{
  char type;
  char canUseShadowMap;
  char shadowmapVolume;
  __int16 cullDist;
  vec3_t color;
  vec3_t dir;
  vec3_t origin;
  float radius;
  float cosHalfFovOuter;
  float cosHalfFovInner;
  int exponent;
  unsigned int spotShadowIndex;
  float dAttenuation;
  float roundness;
  vec3_t angles;
  float spotShadowHiDistance;
  vec4_t diffuseColor;
  vec4_t shadowColor;
  vec4_t falloff;
  vec4_t aAbB;
  vec4_t cookieControl[3];
  __declspec(align(16)) vec4_t viewMatrix[4]; //Again this has to be on a 4 byte buffer, so there should be 8 bytes of padding before this.
  vec4_t projMatrix[4];
  GfxLightDef *def;
};
 
struct GfxLightingSH
{
  vec4_t V[3];
};
 
struct GfxReflectionProbeVolumeData
{
  vec4_t volumePlanes[6];
};
 
struct GfxReflectionProbe
{
  vec3_t origin;
  GfxLightingSH lightingSH;
  GfxImage *reflectionImage;
  GfxReflectionProbeVolumeData *probeVolumes;
       char (*unknown2)[0x70];
  unsigned int probeVolumeCount;
  float mipLodBias;
};
 
struct GfxWorldDpvsPlanes
{
  int cellCount;
  cplane_s *planes;
  unsigned __int16 *nodes;
  unsigned int *sceneEntCellBits;
};
 
struct GfxAabbTree
{
  vec3_t mins;
  vec3_t maxs;
  unsigned __int16 childCount;
  unsigned __int16 surfaceCount;
  unsigned __int16 startSurfIndex;
  unsigned __int16 smodelIndexCount;
  unsigned __int16 *smodelIndexes;
  int childrenOffset;
};
 
struct GfxLightGridEntry
{
  unsigned __int16 colorsIndex;
  char primaryLightIndex;
  char visibility;
};
 
struct GfxCompressedLightGridColors
{
  char rgb[56][3];
};
 
struct GfxStaticModelInst
{
  vec3_t mins;
  vec3_t maxs;
  vec3_t lightingOrigin;
};
 
struct srfTriangles_t
{
  vec3_t mins;
  int vertexDataOffset0;
  vec3_t maxs;
  int vertexDataOffset1;
  int firstVertex;
  float himipRadiusInvSq;
  unsigned __int16 vertexCount;
  unsigned __int16 triCount;
  int baseIndex;
};
 
struct GfxSurface
{
  srfTriangles_t tris;
  Material *material;
  char lightmapIndex;
  char reflectionProbeIndex;
  char primaryLightIndex;
  char flags;
  vec3_t bounds[2];
};
 
struct GfxDrawSurfFields
{
  __int64 _bf0;
};
 
union GfxDrawSurf
{
  GfxDrawSurfFields fields;
  unsigned __int64 packed;
};
 
struct GfxWorldDpvsStatic
{
  unsigned int smodelCount;
  unsigned int staticSurfaceCount;
  unsigned int litSurfsBegin;
  unsigned int litSurfsEnd;
  unsigned int litTransSurfsBegin;
  unsigned int litTransSurfsEnd;
  unsigned int emissiveSurfsBegin;
  unsigned int emissiveSurfsEnd;
  unsigned int emissiveOpaqueSurfsBegin;
  unsigned int emissiveOpaqueSurfsEnd;
  unsigned int emissiveTransSurfsBegin;
  unsigned int emissiveTransSurfsEnd;
  unsigned int smodelVisDataCount;
  unsigned int surfaceVisDataCount;
  char *smodelVisData[3];
  char *surfaceVisData[3];
  char *smodelVisDataCameraSaved;
  char *surfaceVisDataCameraSaved;
  char *surfaceCastsSunShadow;
  char *surfaceCastsShadow;
  char *smodelCastsShadow;
  unsigned __int16 *sortedSurfIndex;
  GfxStaticModelInst *smodelInsts;
  GfxSurface *surfaces;
  GfxStaticModelDrawInst *smodelDrawInsts;
  GfxDrawSurf *surfaceMaterials;
  volatile int usageCount;
};
 
#pragma pack(push, 4)
struct GfxPackedPlacement
{
  vec3_t origin;
  PackedUnitVec axis[3];
  float scale;
};
 
struct GfxStaticModelLmapVertexInfo
{
  unsigned int *lmapVertexColors;
  D3DVertexBuffer lmapVertexColorsVB;
  unsigned __int16 numLmapVertexColors;
};
 
struct GfxLightingSHQuantized
{
  unsigned __int16 V[3][4];
};
 
struct GfxStaticModelDrawInst
{
  float cullDist;
  GfxPackedPlacement placement;
  XModel *model;
  int flags;
  float invScaleSq;
  unsigned __int16 lightingHandle;
  unsigned __int16 colorsIndex;
  GfxLightingSHQuantized lightingSH;
  char primaryLightIndex;
  char visibility;
  char reflectionProbeIndex;
  unsigned int smid;
  GfxStaticModelLmapVertexInfo lmapVertexInfo[4];
};
 
struct cplane_s
{
  vec3_t normal;
  float dist;
  char type;
  char signbits;
};
 
struct GfxPortalWritable
{
  bool isQueued;
  bool isAncestor;
  char recursionDepth;
  char hullPointCount;
  vec2_t *hullPoints;
  GfxPortal *queuedParent;
};
 
struct DpvsPlane
{
  vec4_t coeffs;
  char side[3];
};
 
struct GfxPortal
{
  GfxPortalWritable writable;
  DpvsPlane plane;
  GfxCell * parent;
  vec3_t *vertices;
  char vertexCount;
  vec3_t hullAxis[2];
  vec3_t bounds[2];
};
 
struct GfxCell
{
  vec3_t mins;
  vec3_t maxs;
  int aabbTreeCount;
  GfxAabbTree *aabbTree;
  int portalCount;
  GfxPortal *portals;
  char reflectionProbeCount;
  char *reflectionProbes;
};
 
struct GfxLightmapArray
{
  GfxImage *primary;
  GfxImage *secondary;
};
 
struct GfxCompressedLightGridCoeffs //It is very important that this struct is not 4-byte aligned. It is 0x36 bytes EXACTLY.
{
  unsigned __int16 coeffs[9][3];
};
 
struct GfxSkyGridVolume
{
  vec3_t mins;
  vec3_t maxs;
  vec3_t lightingOrigin;
  unsigned __int16 colorsIndex;
  char primaryLightIndex;
  char visibility;
};
 
struct GfxLightGrid
{
  unsigned int sunPrimaryLightIndex;
  unsigned __int16 mins[3];
  unsigned __int16 maxs[3];
  float offset;
  unsigned int rowAxis;
  unsigned int colAxis;
  unsigned __int16 *rowDataStart;
  unsigned int rawRowDataSize;
  char *rawRowData;
  unsigned int entryCount;
  GfxLightGridEntry *entries;
  unsigned int colorCount;
  GfxCompressedLightGridColors *colors;
  unsigned int coeffCount;
  GfxCompressedLightGridCoeffs *coeffs;
  unsigned int skyGridVolumeCount;
  GfxSkyGridVolume *skyGridVolumes;
};
 
struct GfxBrushModelWritable
{
  vec3_t mins;
  float padding1;
  vec3_t maxs;
  float padding2;
};
 
struct GfxBrushModel
{
  GfxBrushModelWritable writable;
  vec3_t bounds[2];
  unsigned int surfaceCount;
  unsigned int startSurfIndex;
};
 
struct MaterialMemory
{
  Material *material;
  int memory;
};
 
struct sunflare_t
{
  bool hasValidData;
  Material *spriteMaterial;
  Material *flareMaterial;
  float spriteSize;
  float flareMinSize;
  float flareMinDot;
  float flareMaxSize;
  float flareMaxDot;
  float flareMaxAlpha;
  int flareFadeInTime;
  int flareFadeOutTime;
  float blindMinDot;
  float blindMaxDot;
  float blindMaxDarken;
  int blindFadeInTime;
  int blindFadeOutTime;
  float glareMinDot;
  float glareMaxDot;
  float glareMaxLighten;
  int glareFadeInTime;
  int glareFadeOutTime;
  vec3_t sunFxPosition;
};
 
struct GfxShadowGeometry
{
  unsigned __int16 surfaceCount;
  unsigned __int16 smodelCount;
  unsigned __int16 *sortedSurfIndex;
  unsigned __int16 *smodelIndex;
};
 
struct GfxLightRegionAxis
{
  vec3_t dir;
  float midPoint;
  float halfSize;
};
 
struct GfxLightRegionHull
{
  float kdopMidPoint[9];
  float kdopHalfSize[9];
  unsigned int axisCount;
  GfxLightRegionAxis *axis;
};
 
struct GfxLightRegion
{
  unsigned int hullCount;
  GfxLightRegionHull *hulls;
};
 
struct GfxWorldDpvsDynamic
{
  unsigned int dynEntClientWordCount[2];
  unsigned int dynEntClientCount[2];
  unsigned int *dynEntCellBits[2];
  char *dynEntVisData[2][3];
  volatile int usageCount;
};
 
struct GfxWorldFog
{
  float baseDist;
  float halfDist;
  float baseHeight;
  float halfHeight;
  float sunFogPitch;
  float sunFogYaw;
  float sunFogInner;
  float sunFogOuter;
  vec3_t fogColor;
  float fogOpacity;
  vec3_t sunFogColor;
  float sunFogOpacity;
};
 
struct GfxWorldSun
{
  unsigned int control;
  vec3_t angles;
  vec4_t ambientColor;
  vec4_t sunCd;
  vec4_t sunCs;
  vec4_t skyColor;
  float exposure;
};
 
struct SunLightParseParams
{
  char name[64];
  GfxWorldSun initWorldSun;
  float fogTransitionTime;
  GfxWorldFog initWorldFog;
};
 
struct GfxWaterBuffer
{
  unsigned int bufferSize;
  vec4_t *buffer; //Count = bufferSize
};
 
struct SSkinShaders
{
  char *pixelShaderAlign;
  char *pixelShader;
  char *vertexShader;
  int pixelShaderSize;
  int vertexShaderSize;
};
 
struct SSkinAnim
{
  int bones;
  int width;
  int frames;
  float *data;  //Count = width * frames
};
 
struct SSkinVert
{
  unsigned __int16 pos_bone[4];
  PackedUnitVec normal;
  unsigned __int16 uv[2];
};
 
struct SSkinModel
{
  int numVerts;
  int numTris;
  SSkinVert *verts;
  unsigned __int16 *tris; //Count = numTris * 3
};
 
struct SSkinInstance
{
  vec4_t mat[4];
  SkinShaders *shaders;
  SSkinModel *model;
  SSkinAnim *anim;
  SSkinVert *instVerts;
  float frame;
  int pad[3];
};
 
typedef char GfxTexture[0x34];
 
struct GfxWorldDraw
{
  unsigned int reflectionProbeCount;
  union
  {
    GfxReflectionProbe *localReflectionProbes;
    GfxReflectionProbe *reflectionProbes;
  };
  union
  {
    GfxTexture *localReflectionProbeTextures;
    GfxTexture *reflectionProbeTextures;
  };
  int lightmapCount;
  union
  {
    GfxLightmapArray *localLightmaps;
    GfxLightmapArray *lightmaps;
  };
  union
  {
    GfxTexture *localLightmapPrimaryTextures;
    GfxTexture *lightmapPrimaryTextures;
  };
  union
  {
    GfxTexture *localLightmapSecondaryTextures;
    GfxTexture *lightmapSecondaryTextures;
  };
  unsigned int vertexCount;
  unsigned int vertexDataSize0; //Note these are the raw size of the array, not the count.
  GfxWorldVertexData0 vd;
  unsigned int vertexDataSize1;
  GfxWorldVertexLayerData vld;
  int indexCount;
  unsigned __int16 *indices;
  D3DIndexBuffer indexBuffer;
};
 
struct GfxLightCorona
{
  vec3_t origin;
  float radius;
  vec3_t color;
  float intensity;
};
 
struct GfxShadowMapVolume
{
  unsigned int control;
  unsigned int padding1;
  unsigned int padding2;
  unsigned int padding3;
};
 
struct GfxVolumePlane
{
  vec4_t plane;
};
 
struct GfxExposureVolume
{
  unsigned int control;
  float exposure;
  float luminanceIncreaseScale;
  float luminanceDecreaseScale;
  float featherRange;
  float featherAdjust;
};
 
struct GfxWorldFogVolume
{
  vec3_t mins;
  unsigned int control;
  vec3_t maxs;
  float fogTransitionTime;
  unsigned int controlEx;
  GfxWorldFog volumeWorldFog;
};
 
struct GfxWorldFogModifierVolume
{
  unsigned int control;
  unsigned __int16 minX;
  unsigned __int16 minY;
  unsigned __int16 minZ;
  unsigned __int16 maxX;
  unsigned __int16 maxY;
  unsigned __int16 maxZ;
  unsigned int controlEx;
  float transitionTime;
  float depthScale;
  float heightScale;
  vec4_t colorAdjust;
};
 
struct GfxLutVolume
{
  vec3_t mins;
  unsigned int control;
  vec3_t maxs;
  float lutTransitionTime;
  unsigned int lutIndex;
};
 
struct GfxSkyDynamicIntensity
{
  float angle0;
  float angle1;
  float factor0;
  float factor1;
};
 
struct Occluder
{
  unsigned int flags;
  char name[16];
  vec3_t points[4];
};
 
struct GfxOutdoorBounds
{
  vec3_t bounds[2];
};
 
struct GfxHeroLight
{
  char type;
  char unused[3];
  vec3_t color;
  vec3_t dir;
  vec3_t origin;
  float radius;
  float cosHalfFovOuter;
  float cosHalfFovInner;
  int exponent;
};
 
struct GfxHeroLightTree
{
  vec3_t mins;
  vec3_t maxs;
  int leftNode;
  int rightNode;
};
 
struct GfxWorld
{
  const char *name;
  const char *baseName;
  int planeCount;
  int nodeCount;
  int surfaceCount;
  GfxWorldStreamInfo streamInfo;
  const char *skyBoxModel;
  SunLightParseParams sunParse;
  GfxLight *sunLight;
  unsigned int sunPrimaryLightIndex;
  unsigned int primaryLightCount;
  unsigned int coronaCount;
  GfxLightCorona *coronas;
  unsigned int shadowMapVolumeCount;
  GfxShadowMapVolume *shadowMapVolumes;
  unsigned int shadowMapVolumePlaneCount;
  GfxVolumePlane *shadowMapVolumePlanes;
  unsigned int exposureVolumeCount;
  GfxExposureVolume *exposureVolumes;
  unsigned int exposureVolumePlaneCount;
  GfxVolumePlane *exposureVolumePlanes;
  unsigned int worldFogVolumeCount;
  GfxWorldFogVolume *worldFogVolumes;
  unsigned int worldFogVolumePlaneCount;
  GfxVolumePlane *worldFogVolumePlanes;
  unsigned int worldFogModifierVolumeCount;
  GfxWorldFogModifierVolume *worldFogModifierVolumes;
  unsigned int worldFogModifierVolumePlaneCount;
  GfxVolumePlane *worldFogModifierVolumePlanes;
  unsigned int lutVolumeCount;
  GfxLutVolume *lutVolumes;
  unsigned int lutVolumePlaneCount;
  GfxVolumePlane *lutVolumePlanes;
  GfxSkyDynamicIntensity skyDynIntensity;
  GfxWorldDpvsPlanes dpvsPlanes;
  int cellBitsCount;
  GfxCell *cells;
  GfxWorldDraw draw;
  GfxLightGrid lightGrid;
  int modelCount;
  GfxBrushModel *models;
  vec3_t mins;
  vec3_t maxs;
  unsigned int checksum;
  int materialMemoryCount;
  MaterialMemory *materialMemory;
  sunflare_t sun;
  vec4_t outdoorLookupMatrix[4];
  GfxImage *outdoorImage;
  unsigned int *cellCasterBits;
  GfxSceneDynModel *sceneDynModel;
  GfxSceneDynBrush *sceneDynBrush;
  unsigned int *primaryLightEntityShadowVis;
  unsigned int *primaryLightDynEntShadowVis[2];
  unsigned int numSiegeSkinInsts;
  SSkinInstance *siegeSkinInsts;
  GfxShadowGeometry *shadowGeom;
  GfxLightRegion *lightRegion;
  GfxWorldDpvsStatic dpvs;
  GfxWorldDpvsDynamic dpvsDyn;
  float waterDirection;
  GfxWaterBuffer waterBuffers[2];
  Material *waterMaterial;
  Material *coronaMaterial;
  Material *ropeMaterial;
  Material *lutMaterial;
  unsigned int numOccluders;
  Occluder *occluders;
  unsigned int numOutdoorBounds;
  GfxOutdoorBounds *outdoorBounds;
  unsigned int heroLightCount;
  unsigned int heroLightTreeCount;
  GfxHeroLight *heroLights;
  GfxHeroLightTree *heroLightTree;
  unsigned int lightingFlags;
  int lightingQuality;
};
#pragma pack(pop)

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