Add loading of iw4 assets clipmap and mapents

This commit is contained in:
Jan 2020-09-15 10:44:45 +02:00
parent 14666ed944
commit fb93d7cb2f
6 changed files with 409 additions and 29 deletions

View File

@ -15,11 +15,11 @@ ZoneCode.Assets = {
"snd_alias_list_t",
"SndCurve",
"LoadedSound",
-- "clipMap_t",
"clipMap_t",
-- "ComWorld",
-- "GameWorldSp",
-- "GameWorldMp",
-- "MapEnts",
"MapEnts",
-- "FxWorld",
-- "GfxWorld",
"GfxLightDef",

View File

@ -15,11 +15,11 @@ asset GfxImage ASSET_TYPE_IMAGE;
asset snd_alias_list_t ASSET_TYPE_SOUND;
asset SndCurve ASSET_TYPE_SOUND_CURVE;
asset LoadedSound ASSET_TYPE_LOADED_SOUND;
// asset clipMap_t ASSET_TYPE_CLIPMAP_MP;
asset clipMap_t ASSET_TYPE_CLIPMAP_MP;
// asset ComWorld ASSET_TYPE_COMWORLD;
// asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP;
// asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP;
// asset MapEnts ASSET_TYPE_MAP_ENTS;
asset MapEnts ASSET_TYPE_MAP_ENTS;
// asset FxWorld ASSET_TYPE_FXWORLD;
// asset GfxWorld ASSET_TYPE_GFXWORLD;
asset GfxLightDef ASSET_TYPE_LIGHT_DEF;
@ -400,6 +400,113 @@ set condition info::data_ptr never;
set condition info::initial_ptr never;
set action SetSoundData(MssSound);
// =========================================
// clipMap_t
// =========================================
use clipMap_t;
set string name;
set name name;
set reusable planes;
set count planes planeCount;
set count staticModelList numStaticModels;
set count materials numMaterials;
set count brushsides numBrushSides;
set count brushEdges numBrushEdges;
set count nodes numNodes;
set count leafs numLeafs;
set count leafbrushNodes leafbrushNodesCount;
set count leafbrushes numLeafBrushes;
set count leafsurfaces numLeafSurfaces;
set count verts vertCount;
set count triIndices 3 * triCount;
set count triEdgeIsWalkable ((3 * triCount + 31) / 32) * 4;
set count borders borderCount;
set count partitions partitionCount;
set count aabbTrees aabbTreeCount;
set count cmodels numSubModels;
set count brushes numBrushes;
set count brushBounds numBrushes;
set count brushContents numBrushes;
set count smodelNodes smodelNodeCount;
set count dynEntDefList[0] dynEntCount[0];
set count dynEntDefList[1] dynEntCount[1];
set block dynEntPoseList XFILE_BLOCK_RUNTIME;
set count dynEntPoseList[0] dynEntCount[0];
set count dynEntPoseList[1] dynEntCount[1];
set block dynEntClientList XFILE_BLOCK_RUNTIME;
set count dynEntClientList[0] dynEntCount[0];
set count dynEntClientList[1] dynEntCount[1];
set block dynEntCollList XFILE_BLOCK_RUNTIME;
set count dynEntCollList[0] dynEntCount[0];
set count dynEntCollList[1] dynEntCount[1];
reorder:
name
planes
staticModelList
materials
brushsides
brushEdges
nodes
leafs
leafbrushes
leafbrushNodes
leafsurfaces
verts
triIndices
triEdgeIsWalkable
borders
partitions
aabbTrees
cmodels
brushes
brushBounds
brushContents
smodelNodes
mapEnts
dynEntDefList
dynEntPoseList
dynEntClientList
dynEntCollList;
// ClipMaterial
set string ClipMaterial::name;
// cNode_t
set reusable cNode_t::plane;
// cLeafBrushNode_s
use cLeafBrushNode_s;
set condition data::leaf leafBrushCount > 0;
set reusable data::leaf::brushes;
set count data::leaf::brushes leafBrushCount;
// CollisionPartition
use CollisionPartition;
set reusable borders;
// cbrush_t
use cbrush_t;
set reusable sides;
set reusable baseAdjacentSide;
// =========================================
// MapEnts
// =========================================
use MapEnts;
set string name;
set name name;
set count entityString numEntityChars;
set count stages stageCount;
// MapTriggers
use MapTriggers;
set count models count;
set count hulls hullCount;
set count slabs slabCount;
// Stage
set string Stage::name;
// =========================================
// LocalizeEntry
// =========================================

View File

@ -116,11 +116,11 @@ GameAssetPoolIW4::GameAssetPoolIW4(const int priority)
m_sound = nullptr;
m_sound_curve = nullptr;
m_loaded_sound = nullptr;
// m_clip_map = nullptr;
m_clip_map = nullptr;
// m_com_world = nullptr;
// m_game_world_sp = nullptr;
// m_game_world_mp = nullptr;
// m_map_ents = nullptr;
m_map_ents = nullptr;
// m_fx_world = nullptr;
// m_gfx_world = nullptr;
m_gfx_light_def = nullptr;
@ -168,12 +168,12 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
// CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
@ -228,12 +228,12 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
// CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
@ -297,12 +297,12 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
// CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap);
// CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap);
// CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
// CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
// CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
// CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
// CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld);
// CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
@ -357,12 +357,12 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
// CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map);
// CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map);
// CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
// CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp);
// CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp);
// CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
// CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world);
// CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);

View File

@ -28,11 +28,11 @@ public:
std::unique_ptr<AssetPool<IW4::snd_alias_list_t>> m_sound;
std::unique_ptr<AssetPool<IW4::SndCurve>> m_sound_curve;
std::unique_ptr<AssetPool<IW4::LoadedSound>> m_loaded_sound;
// std::unique_ptr<AssetPool<IW4::clipMap_t>> m_clip_map;
std::unique_ptr<AssetPool<IW4::clipMap_t>> m_clip_map;
// std::unique_ptr<AssetPool<IW4::ComWorld>> m_com_world;
// std::unique_ptr<AssetPool<IW4::GameWorldSp>> m_game_world_sp;
// std::unique_ptr<AssetPool<IW4::GameWorldMp>> m_game_world_mp;
// std::unique_ptr<AssetPool<IW4::MapEnts>> m_map_ents;
std::unique_ptr<AssetPool<IW4::MapEnts>> m_map_ents;
// std::unique_ptr<AssetPool<IW4::FxWorld>> m_fx_world;
// std::unique_ptr<AssetPool<IW4::GfxWorld>> m_gfx_world;
std::unique_ptr<AssetPool<IW4::GfxLightDef>> m_gfx_light_def;

View File

@ -87,11 +87,11 @@ namespace IW4
struct snd_alias_list_t;
struct SndCurve;
struct LoadedSound;
// struct clipMap_t;
struct clipMap_t;
// struct ComWorld;
// struct GameWorldSp;
// struct GameWorldMp;
// struct MapEnts;
struct MapEnts;
// struct FxWorld;
// struct GfxWorld;
struct GfxLightDef;
@ -127,11 +127,11 @@ namespace IW4
snd_alias_list_t* sound;
SndCurve* sndCurve;
LoadedSound* loadSnd;
// clipMap_t* clipMap;
clipMap_t* clipMap;
// ComWorld* comWorld;
// GameWorldSp* gameWorldSp;
// GameWorldMp* gameWorldMp;
// MapEnts* mapEnts;
MapEnts* mapEnts;
// FxWorld* fxWorld;
// GfxWorld* gfxWorld;
GfxLightDef* lightDef;
@ -1788,6 +1788,279 @@ namespace IW4
StructuredDataDef* defs;
};
struct TriggerModel
{
int contents;
unsigned __int16 hullCount;
unsigned __int16 firstHull;
};
struct TriggerHull
{
Bounds bounds;
int contents;
unsigned __int16 slabCount;
unsigned __int16 firstSlab;
};
struct TriggerSlab
{
float dir[3];
float midPoint;
float halfSize;
};
struct MapTriggers
{
unsigned int count;
TriggerModel* models;
unsigned int hullCount;
TriggerHull* hulls;
unsigned int slabCount;
TriggerSlab* slabs;
};
struct Stage
{
const char* name;
float origin[3];
unsigned __int16 triggerIndex;
char sunPrimaryLightIndex;
};
struct MapEnts
{
const char* name;
char* entityString;
int numEntityChars;
MapTriggers trigger;
Stage* stages;
char stageCount;
};
typedef unsigned short LeafBrush;
struct cStaticModel_s
{
XModel* xmodel;
float origin[3];
float invScaledAxis[3][3];
Bounds absBounds;
};
struct ClipMaterial
{
const char* name;
int surfaceFlags;
int contents;
};
struct cNode_t
{
cplane_s* plane;
__int16 children[2];
};
struct cLeafBrushNodeLeaf_t
{
LeafBrush* 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;
char firstVertSegment;
int firstTri;
CollisionBorder* borders;
};
union CollisionAabbTreeIndex
{
int firstChildIndex;
int partitionIndex;
};
struct __declspec(align(16)) CollisionAabbTree
{
float midPoint[3];
unsigned __int16 materialIndex;
unsigned __int16 childCount;
float halfSize[3];
CollisionAabbTreeIndex u;
};
struct cLeaf_t
{
unsigned __int16 firstCollAabbIndex;
unsigned __int16 collAabbCount;
int brushContents;
int terrainContents;
Bounds bounds;
int leafBrushNode;
};
struct cmodel_t
{
Bounds bounds;
float radius;
cLeaf_t leaf;
};
struct cbrush_t
{
unsigned __int16 numsides;
unsigned __int16 glassPieceIndex;
cbrushside_t* sides;
char* baseAdjacentSide;
__int16 axialMaterialNum[2][3];
char firstAdjacentSideOffsets[2][3];
char edgeCount[2][3];
};
struct SModelAabbNode
{
Bounds bounds;
unsigned __int16 firstChild;
unsigned __int16 childCount;
};
struct GfxPlacement
{
float quat[4];
float origin[3];
};
enum DynEntityType
{
DYNENT_TYPE_INVALID = 0x0,
DYNENT_TYPE_CLUTTER = 0x1,
DYNENT_TYPE_DESTRUCT = 0x2,
DYNENT_TYPE_COUNT = 0x3,
};
struct DynEntityDef
{
DynEntityType type;
GfxPlacement pose;
XModel* xModel;
unsigned __int16 brushModel;
unsigned __int16 physicsBrushModel;
FxEffectDef* destroyFx;
PhysPreset* physPreset;
int health;
PhysMass mass;
int contents;
};
struct DynEntityPose
{
GfxPlacement pose;
float radius;
};
struct DynEntityClient
{
int physObjId;
unsigned __int16 flags;
unsigned __int16 lightingHandle;
int health;
};
struct DynEntityColl
{
unsigned __int16 sector;
unsigned __int16 nextEntInSector;
float linkMins[2];
float linkMaxs[2];
};
typedef __declspec(align(128)) cbrush_t cbrush_array_t;
typedef __declspec(align(128)) Bounds BoundsArray;
struct clipMap_t
{
const char* name;
int isInUse;
int planeCount;
cplane_s* planes;
unsigned int numStaticModels;
cStaticModel_s* staticModelList;
unsigned int numMaterials;
ClipMaterial* 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;
unsigned int numLeafBrushes;
LeafBrush* leafbrushes;
unsigned int numLeafSurfaces;
unsigned int* leafsurfaces;
unsigned int vertCount;
vec3_t* verts;
int triCount;
unsigned __int16* triIndices;
char* triEdgeIsWalkable;
int borderCount;
CollisionBorder* borders;
int partitionCount;
CollisionPartition* partitions;
int aabbTreeCount;
CollisionAabbTree* aabbTrees;
unsigned int numSubModels;
cmodel_t* cmodels;
unsigned __int16 numBrushes;
cbrush_array_t* brushes;
BoundsArray* brushBounds;
int* brushContents;
MapEnts* mapEnts;
unsigned __int16 smodelNodeCount;
SModelAabbNode* smodelNodes;
unsigned __int16 dynEntCount[2];
DynEntityDef* dynEntDefList[2];
DynEntityPose* dynEntPoseList[2];
DynEntityClient* dynEntClientList[2];
DynEntityColl* dynEntCollList[2];
unsigned int checksum;
char padding[48];
};
#ifndef __zonecodegenerator
}
#endif

View File

@ -5,7 +5,7 @@
#include <cassert>
//#include "Game/IW4/XAssets/addonmapents/addonmapents_load_db.h"
//#include "Game/IW4/XAssets/clipmap_t/clipmap_t_load_db.h"
#include "Game/IW4/XAssets/clipmap_t/clipmap_t_load_db.h"
//#include "Game/IW4/XAssets/comworld/comworld_load_db.h"
//#include "Game/IW4/XAssets/font_s/font_s_load_db.h"
#include "Game/IW4/XAssets/fxeffectdef/fxeffectdef_load_db.h"
@ -19,7 +19,7 @@
#include "Game/IW4/XAssets/leaderboarddef/leaderboarddef_load_db.h"
#include "Game/IW4/XAssets/loadedsound/loadedsound_load_db.h"
#include "Game/IW4/XAssets/localizeentry/localizeentry_load_db.h"
//#include "Game/IW4/XAssets/mapents/mapents_load_db.h"
#include "Game/IW4/XAssets/mapents/mapents_load_db.h"
#include "Game/IW4/XAssets/material/material_load_db.h"
#include "Game/IW4/XAssets/materialpixelshader/materialpixelshader_load_db.h"
#include "Game/IW4/XAssets/materialtechniqueset/materialtechniqueset_load_db.h"
@ -116,12 +116,12 @@ void ContentLoaderIW4::LoadXAsset(const bool atStreamStart)
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound);
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve);
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd);
// LOAD_ASSET(ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap);
// LOAD_ASSET(ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap);
LOAD_ASSET(ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap);
LOAD_ASSET(ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap);
// LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld);
// LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp);
// LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp);
// LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts);
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts);
// LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld);
// LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld);
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef);