mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-09 22:14:56 +00:00
Add improvements from iw3 material dumping to iw4
This commit is contained in:
parent
c91d71e809
commit
2823a46b92
@ -791,6 +791,15 @@ namespace IW4
|
||||
unsigned int loadBits[2];
|
||||
};
|
||||
|
||||
struct infoParm_t
|
||||
{
|
||||
const char* name;
|
||||
unsigned int clearSolid;
|
||||
unsigned int surfaceFlags;
|
||||
unsigned int contents;
|
||||
unsigned int toolFlags;
|
||||
};
|
||||
|
||||
struct gcc_align(8) GfxDrawSurfFields
|
||||
{
|
||||
uint64_t objectId : 16;
|
||||
|
111
src/ObjCommon/Game/IW4/MaterialConstantsIW4.h
Normal file
111
src/ObjCommon/Game/IW4/MaterialConstantsIW4.h
Normal file
@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
inline infoParm_t infoParms[]
|
||||
{
|
||||
{"bark", 0x0, 0x100000, 0x0, 0x0},
|
||||
{"brick", 0x0, 0x200000, 0x0, 0x0},
|
||||
{"carpet", 0x0, 0x300000, 0x0, 0x0},
|
||||
{"cloth", 0x0, 0x400000, 0x0, 0x0},
|
||||
{"concrete", 0x0, 0x500000, 0x0, 0x0},
|
||||
{"dirt", 0x0, 0x600000, 0x0, 0x0},
|
||||
{"flesh", 0x0, 0x700000, 0x0, 0x0},
|
||||
{"foliage", 0x1, 0x800000, 0x2, 0x0},
|
||||
{"glass", 0x1, 0x900000, 0x10, 0x0},
|
||||
{"grass", 0x0, 0xa00000, 0x0, 0x0},
|
||||
{"gravel", 0x0, 0xb00000, 0x0, 0x0},
|
||||
{"ice", 0x0, 0xc00000, 0x0, 0x0},
|
||||
{"metal", 0x0, 0xd00000, 0x0, 0x0},
|
||||
{"mud", 0x0, 0xe00000, 0x0, 0x0},
|
||||
{"paper", 0x0, 0xf00000, 0x0, 0x0},
|
||||
{"plaster", 0x0, 0x1000000, 0x0, 0x0},
|
||||
{"rock", 0x0, 0x1100000, 0x0, 0x0},
|
||||
{"sand", 0x0, 0x1200000, 0x0, 0x0},
|
||||
{"snow", 0x0, 0x1300000, 0x0, 0x0},
|
||||
{"water", 0x1, 0x1400000, 0x20, 0x0},
|
||||
{"wood", 0x0, 0x1500000, 0x0, 0x0},
|
||||
{"asphalt", 0x0, 0x1600000, 0x0, 0x0},
|
||||
{"ceramic", 0x0, 0x1700000, 0x0, 0x0},
|
||||
{"plastic", 0x0, 0x1800000, 0x0, 0x0},
|
||||
{"rubber", 0x0, 0x1900000, 0x0, 0x0},
|
||||
{"cushion", 0x0, 0x1a00000, 0x0, 0x0},
|
||||
{"fruit", 0x0, 0x1b00000, 0x0, 0x0},
|
||||
{"paintedmetal", 0x0, 0x1c00000, 0x0, 0x0},
|
||||
{"riotshield", 0x0, 0x1d00000, 0x0, 0x0},
|
||||
{"slush", 0x0, 0x1e00000, 0x0, 0x0},
|
||||
{"opaqueglass", 0x0, 0x900000, 0x0, 0x0},
|
||||
{"clipmissile", 0x1, 0x0, 0x80, 0x0},
|
||||
{"ai_nosight", 0x1, 0x0, 0x1000, 0x0},
|
||||
{"clipshot", 0x1, 0x0, 0x2000, 0x0},
|
||||
{"playerclip", 0x1, 0x0, 0x10000, 0x0},
|
||||
{"monsterclip", 0x1, 0x0, 0x20000, 0x0},
|
||||
{"aiclipallowdeath", 0x1, 0x0, 0x4, 0x0},
|
||||
{"vehicleclip", 0x1, 0x0, 0x200, 0x0},
|
||||
{"itemclip", 0x1, 0x0, 0x400, 0x0},
|
||||
{"nodrop", 0x1, 0x0, 0x80000000, 0x0},
|
||||
{"nonsolid", 0x1, 0x4000, 0x0, 0x0},
|
||||
{"detail", 0x0, 0x0, 0x8000000, 0x0},
|
||||
{"structural", 0x0, 0x0, 0x10000000, 0x0},
|
||||
{"portal", 0x1, 0x80000000, 0x0, 0x0},
|
||||
{"canshootclip", 0x0, 0x0, 0x40, 0x0},
|
||||
{"origin", 0x1, 0x0, 0x0, 0x4},
|
||||
{"sky", 0x0, 0x4, 0x800, 0x0},
|
||||
{"nocastshadow", 0x0, 0x40000, 0x0, 0x0},
|
||||
{"physicsGeom", 0x0, 0x0, 0x0, 0x400},
|
||||
{"lightPortal", 0x0, 0x0, 0x0, 0x2000},
|
||||
{"outdoorBounds", 0x0, 0x0, 0x0, 0x8000},
|
||||
{"slick", 0x0, 0x2, 0x0, 0x0},
|
||||
{"noimpact", 0x0, 0x10, 0x0, 0x0},
|
||||
{"nomarks", 0x0, 0x20, 0x0, 0x0},
|
||||
{"nopenetrate", 0x0, 0x100, 0x0, 0x0},
|
||||
{"ladder", 0x0, 0x8, 0x0, 0x0},
|
||||
{"nodamage", 0x0, 0x1, 0x0, 0x0},
|
||||
{"mantleOn", 0x0, 0x2000000, 0x1000000, 0x0},
|
||||
{"mantleOver", 0x0, 0x4000000, 0x1000000, 0x0},
|
||||
{"stairs", 0x0, 0x200, 0x0, 0x0},
|
||||
{"soft", 0x0, 0x1000, 0x0, 0x0},
|
||||
{"nosteps", 0x0, 0x2000, 0x0, 0x0},
|
||||
{"nodraw", 0x0, 0x80, 0x0, 0x0},
|
||||
{"nolightmap", 0x0, 0x400, 0x0, 0x0},
|
||||
{"nodlight", 0x0, 0x20000, 0x0, 0x0}
|
||||
};
|
||||
|
||||
inline const char* surfaceTypeNames[]
|
||||
{
|
||||
"default",
|
||||
"bark",
|
||||
"brick",
|
||||
"carpet",
|
||||
"cloth",
|
||||
"concrete",
|
||||
"dirt",
|
||||
"flesh",
|
||||
"foliage",
|
||||
"glass",
|
||||
"grass",
|
||||
"gravel",
|
||||
"ice",
|
||||
"metal",
|
||||
"mud",
|
||||
"paper",
|
||||
"plaster",
|
||||
"rock",
|
||||
"sand",
|
||||
"snow",
|
||||
"water",
|
||||
"wood",
|
||||
"asphalt",
|
||||
"ceramic",
|
||||
"plastic",
|
||||
"rubber",
|
||||
"cushion",
|
||||
"fruit",
|
||||
"paintedmetal",
|
||||
"riotshield",
|
||||
"slush"
|
||||
};
|
||||
static_assert(std::extent_v<decltype(surfaceTypeNames)> == SURF_TYPE_NUM);
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#include <sstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "Game/IW4/MaterialConstantsIW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
|
||||
using namespace IW4;
|
||||
@ -28,7 +29,7 @@ namespace IW4
|
||||
return json{};
|
||||
}
|
||||
|
||||
json BuildComplexTableJson(complex_s* complexTable, const size_t count)
|
||||
json BuildComplexTableJson(const complex_s* complexTable, const size_t count)
|
||||
{
|
||||
auto jArray = json::array();
|
||||
|
||||
@ -325,6 +326,34 @@ namespace IW4
|
||||
|
||||
return jArray;
|
||||
}
|
||||
|
||||
json BuildSurfaceTypeBitsJson(const unsigned surfaceTypeBits)
|
||||
{
|
||||
if (!surfaceTypeBits)
|
||||
return json(surfaceTypeNames[SURF_TYPE_DEFAULT]);
|
||||
|
||||
static constexpr auto NON_SURFACE_TYPE_BITS = ~(std::numeric_limits<unsigned>::max() >> ((sizeof(unsigned) * 8) - (static_cast<unsigned>(SURF_TYPE_NUM) - 1)));
|
||||
assert((surfaceTypeBits & NON_SURFACE_TYPE_BITS) == 0);
|
||||
|
||||
std::ostringstream ss;
|
||||
auto firstSurfaceType = true;
|
||||
for (auto surfaceTypeIndex = static_cast<unsigned>(SURF_TYPE_BARK); surfaceTypeIndex < SURF_TYPE_NUM; surfaceTypeIndex++)
|
||||
{
|
||||
if ((surfaceTypeBits & (1 << (surfaceTypeIndex - 1))) == 0)
|
||||
continue;
|
||||
|
||||
if (firstSurfaceType)
|
||||
firstSurfaceType = false;
|
||||
else
|
||||
ss << ",";
|
||||
ss << surfaceTypeNames[surfaceTypeIndex];
|
||||
}
|
||||
|
||||
if (firstSurfaceType)
|
||||
return json(surfaceTypeNames[SURF_TYPE_DEFAULT]);
|
||||
|
||||
return json(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
||||
@ -357,7 +386,7 @@ void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Mat
|
||||
const json j = {
|
||||
{
|
||||
"info", {
|
||||
{"gameFlags", material->info.gameFlags},
|
||||
{"gameFlags", material->info.gameFlags}, // TODO: Find out what gameflags mean
|
||||
{"sortKey", material->info.sortKey},
|
||||
{"textureAtlasRowCount", material->info.textureAtlasRowCount},
|
||||
{"textureAtlasColumnCount", material->info.textureAtlasColumnCount},
|
||||
@ -375,7 +404,7 @@ void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Mat
|
||||
{"primarySortKey", static_cast<unsigned>(material->info.drawSurf.fields.primarySortKey)}
|
||||
}
|
||||
},
|
||||
{"surfaceTypeBits", material->info.surfaceTypeBits},
|
||||
{"surfaceTypeBits", BuildSurfaceTypeBitsJson(material->info.surfaceTypeBits)},
|
||||
{"hashIndex", material->info.hashIndex}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user