mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-16 13:37:26 +00:00
chore: implement basics for t6 collmap dumping
This commit is contained in:
@@ -6863,10 +6863,23 @@ namespace T6
|
||||
XSurfaceCollisionLeaf* leafs;
|
||||
};
|
||||
|
||||
enum PhysicsGeomType : int
|
||||
{
|
||||
PHYS_GEOM_NONE,
|
||||
PHYS_GEOM_BOX,
|
||||
PHYS_GEOM_BRUSH,
|
||||
PHYS_GEOM_CYLINDER,
|
||||
PHYS_GEOM_CYLINDER_LARGE,
|
||||
PHYS_GEOM_CAPSULE,
|
||||
PHYS_GEOM_POINT,
|
||||
|
||||
PHYS_GEOM_COUNT,
|
||||
};
|
||||
|
||||
struct PhysGeomInfo
|
||||
{
|
||||
BrushWrapper* brush;
|
||||
int type;
|
||||
PhysicsGeomType type;
|
||||
vec3_t orientation[3];
|
||||
vec3_t offset;
|
||||
vec3_t halfLengths;
|
||||
|
@@ -150,4 +150,9 @@ namespace xmodel
|
||||
{
|
||||
return std::format("xmodel/{}.json", assetName);
|
||||
}
|
||||
|
||||
std::string GetFileNameForCollMap(const std::string& collMapName)
|
||||
{
|
||||
return std::format("phys_collmaps/{}.map", collMapName);
|
||||
}
|
||||
} // namespace xmodel
|
||||
|
@@ -133,4 +133,5 @@ typedef DistinctMapper<VertexMergerPos> VertexMerger;
|
||||
namespace xmodel
|
||||
{
|
||||
std::string GetJsonFileNameForAssetName(const std::string& assetName);
|
||||
std::string GetFileNameForCollMap(const std::string& collMapName);
|
||||
}
|
||||
|
80
src/ObjWriting/Game/T6/XModel/XModelCollMapDumperT6.cpp
Normal file
80
src/ObjWriting/Game/T6/XModel/XModelCollMapDumperT6.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "XModelCollmapDumperT6.h"
|
||||
|
||||
#include "Maps/MapFileDumper.h"
|
||||
#include "XModel/XModelCommon.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace xmodel
|
||||
{
|
||||
void DumpCollMap(const std::string& collMapName, const AssetDumpingContext& context, const Collmap& collMap)
|
||||
{
|
||||
if (!collMap.geomList)
|
||||
return;
|
||||
|
||||
const auto& geomList = *collMap.geomList;
|
||||
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForCollMap(collMapName));
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
MapFileDumper mapFileDumper(*assetFile);
|
||||
mapFileDumper.Init();
|
||||
|
||||
if (geomList.count <= 0 || !geomList.geoms)
|
||||
return;
|
||||
|
||||
mapFileDumper.BeginEntity();
|
||||
|
||||
mapFileDumper.WriteKeyValue("classname", "worldspawn");
|
||||
|
||||
for (auto i = 0u; i < geomList.count; i++)
|
||||
{
|
||||
const auto& geom = geomList.geoms[i];
|
||||
mapFileDumper.BeginBrush();
|
||||
|
||||
switch (geom.type)
|
||||
{
|
||||
case PHYS_GEOM_BOX:
|
||||
mapFileDumper.WritePhysicsBox({
|
||||
{geom.offset.x, geom.offset.y, geom.offset.z },
|
||||
{geom.halfLengths.x, geom.halfLengths.y, geom.halfLengths.z },
|
||||
{geom.orientation[0].x, geom.orientation[0].y, geom.orientation[0].z},
|
||||
{geom.orientation[1].x, geom.orientation[1].y, geom.orientation[1].z},
|
||||
{geom.orientation[2].x, geom.orientation[2].y, geom.orientation[2].z}
|
||||
});
|
||||
break;
|
||||
|
||||
case PHYS_GEOM_BRUSH:
|
||||
// TODO
|
||||
mapFileDumper.WriteComment("TODO: Brush data");
|
||||
break;
|
||||
|
||||
case PHYS_GEOM_CYLINDER:
|
||||
mapFileDumper.WritePhysicsCylinder({
|
||||
{geom.offset.x, geom.offset.y, geom.offset.z },
|
||||
geom.halfLengths.x,
|
||||
geom.halfLengths.z * 2,
|
||||
{geom.orientation[0].x, geom.orientation[0].y, geom.orientation[0].z}
|
||||
});
|
||||
break;
|
||||
|
||||
case PHYS_GEOM_NONE:
|
||||
case PHYS_GEOM_CYLINDER_LARGE:
|
||||
case PHYS_GEOM_CAPSULE:
|
||||
case PHYS_GEOM_POINT:
|
||||
|
||||
default:
|
||||
// These do not seem to appear inside any coll maps
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
mapFileDumper.EndBrush();
|
||||
}
|
||||
|
||||
mapFileDumper.EndEntity();
|
||||
}
|
||||
} // namespace xmodel
|
9
src/ObjWriting/Game/T6/XModel/XModelCollMapDumperT6.h
Normal file
9
src/ObjWriting/Game/T6/XModel/XModelCollMapDumperT6.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace xmodel
|
||||
{
|
||||
void DumpCollMap(const std::string& collMapName, const AssetDumpingContext& context, const T6::Collmap& collMap);
|
||||
} // namespace xmodel
|
@@ -5,6 +5,7 @@
|
||||
#set DUMPER_HEADER "\"XModelDumper" + GAME + ".h\""
|
||||
#set COMMON_HEADER "\"Game/" + GAME + "/Common" + GAME + ".h\""
|
||||
#set JSON_HEADER "\"Game/" + GAME + "/XModel/JsonXModel" + GAME + ".h\""
|
||||
#set COLL_MAP_DUMPER_HEADER "\"Game/" + GAME + "/XModel/XModelCollMapDumper" + GAME + ".h\""
|
||||
|
||||
#if GAME == "IW3"
|
||||
#define FEATURE_IW3
|
||||
@@ -31,6 +32,9 @@
|
||||
|
||||
#include COMMON_HEADER
|
||||
#include JSON_HEADER
|
||||
#ifdef FEATURE_T6
|
||||
#include COLL_MAP_DUMPER_HEADER
|
||||
#endif
|
||||
|
||||
#include "ObjWriting.h"
|
||||
#include "Utils/DistinctMapper.h"
|
||||
@@ -674,6 +678,27 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEATURE_T6
|
||||
void DumpXModelCollMaps(const AssetDumpingContext& context, const XAssetInfo<XModel>* asset)
|
||||
{
|
||||
const auto* model = asset->Asset();
|
||||
|
||||
if (!model->collmaps)
|
||||
return;
|
||||
|
||||
for (auto currentCollMap = 0u; currentCollMap < model->numCollmaps; currentCollMap++)
|
||||
{
|
||||
std::string collMapName;
|
||||
if (model->numCollmaps > 1)
|
||||
collMapName = std::format("{}_coll{}", model->name, currentCollMap);
|
||||
else
|
||||
collMapName = model->name;
|
||||
|
||||
xmodel::DumpCollMap(collMapName, context, model->collmaps[currentCollMap]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class JsonDumper
|
||||
{
|
||||
public:
|
||||
@@ -863,5 +888,8 @@ namespace xmodel
|
||||
{
|
||||
DumpXModelJson(context, asset);
|
||||
DumpXModelSurfs(context, asset);
|
||||
#ifdef FEATURE_T6
|
||||
DumpXModelCollMaps(context, asset);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user