mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
Add base for physcollmap dumper
This commit is contained in:
@ -0,0 +1,84 @@
|
||||
#include "AssetDumperPhysCollmap.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
#include "Dumping/MapFile/MapFileDumper.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
std::string AssetDumperPhysCollmap::GetAssetFilename(const std::string& assetName)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << "phys_collmaps/" << assetName << ".map";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool AssetDumperPhysCollmap::ShouldDump(XAssetInfo<PhysCollmap>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperPhysCollmap::DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysCollmap>* asset)
|
||||
{
|
||||
const auto* physCollmap = asset->Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetAssetFilename(asset->m_name));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
MapFileDumper mapFileDumper(*assetFile);
|
||||
mapFileDumper.Init();
|
||||
|
||||
if (physCollmap->count <= 0 || physCollmap->geoms == nullptr)
|
||||
return;
|
||||
|
||||
mapFileDumper.BeginEntity();
|
||||
|
||||
mapFileDumper.WriteKeyValue("classname", "worldspawn");
|
||||
|
||||
for (auto i = 0u; i < physCollmap->count; i++)
|
||||
{
|
||||
const auto& geom = physCollmap->geoms[i];
|
||||
mapFileDumper.BeginBrush();
|
||||
|
||||
switch (geom.type)
|
||||
{
|
||||
case PHYS_GEOM_NONE:
|
||||
break;
|
||||
case PHYS_GEOM_BOX:
|
||||
mapFileDumper.WritePhysicsBox({
|
||||
{geom.bounds.midPoint[0], geom.bounds.midPoint[1], geom.bounds.midPoint[2]},
|
||||
{geom.bounds.halfSize[0], geom.bounds.halfSize[1], geom.bounds.halfSize[2]},
|
||||
{geom.orientation[0][0], geom.orientation[0][1], geom.orientation[0][2]},
|
||||
{geom.orientation[1][0], geom.orientation[1][1], geom.orientation[1][2]},
|
||||
{geom.orientation[2][0], geom.orientation[2][1], geom.orientation[2][2]}
|
||||
});
|
||||
break;
|
||||
|
||||
case PHYS_GEOM_CYLINDER:
|
||||
mapFileDumper.WritePhysicsCylinder({
|
||||
{geom.bounds.midPoint[0], geom.bounds.midPoint[1], geom.bounds.midPoint[2]},
|
||||
geom.bounds.halfSize[0],
|
||||
geom.bounds.halfSize[2] * 2,
|
||||
{geom.orientation[0][0], geom.orientation[0][1], geom.orientation[0][2]}
|
||||
});
|
||||
break;
|
||||
|
||||
case PHYS_GEOM_BRUSHMODEL:
|
||||
case PHYS_GEOM_BRUSH:
|
||||
case PHYS_GEOM_COLLMAP:
|
||||
case PHYS_GEOM_CAPSULE:
|
||||
case PHYS_GEOM_GLASS:
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
mapFileDumper.EndBrush();
|
||||
}
|
||||
|
||||
mapFileDumper.EndEntity();
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperPhysCollmap final : public AbstractAssetDumper<PhysCollmap>
|
||||
{
|
||||
static std::string GetAssetFilename(const std::string& assetName);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<PhysCollmap>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysCollmap>* asset) override;
|
||||
};
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
#include "AssetDumpers/AssetDumperMenuDef.h"
|
||||
#include "AssetDumpers/AssetDumperMenuList.h"
|
||||
#include "AssetDumpers/AssetDumperPhysCollmap.h"
|
||||
#include "AssetDumpers/AssetDumperPhysPreset.h"
|
||||
#include "AssetDumpers/AssetDumperRawFile.h"
|
||||
#include "AssetDumpers/AssetDumperSndCurve.h"
|
||||
@ -38,7 +39,7 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolIW4*>(context.m_zone->m_pools.get());
|
||||
|
||||
DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP)
|
||||
DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL)
|
||||
|
Reference in New Issue
Block a user