mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-02 01:27:55 -05:00
Reformat code with clang format
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
#include "AssetDumperGfxImage.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "ObjWriting.h"
|
||||
#include "Image/IwiWriter6.h"
|
||||
#include "Image/DdsWriter.h"
|
||||
#include "Image/IwiWriter6.h"
|
||||
#include "ObjWriting.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Image/IImageWriter.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
|
||||
@ -21,4 +21,4 @@ namespace IW3
|
||||
public:
|
||||
AssetDumperGfxImage();
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -11,41 +11,25 @@ bool AssetDumperLoadedSound::ShouldDump(XAssetInfo<LoadedSound>* asset)
|
||||
|
||||
void AssetDumperLoadedSound::DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream)
|
||||
{
|
||||
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF)
|
||||
+ sizeof(uint32_t)
|
||||
+ sizeof(WAV_WAVE_ID)
|
||||
+ sizeof(WavChunkHeader)
|
||||
+ sizeof(WavFormatChunkPcm)
|
||||
+ sizeof(WavChunkHeader)
|
||||
+ sizeof(asset->sound.info.data_len);
|
||||
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF) + sizeof(uint32_t) + sizeof(WAV_WAVE_ID) + sizeof(WavChunkHeader) + sizeof(WavFormatChunkPcm)
|
||||
+ sizeof(WavChunkHeader) + sizeof(asset->sound.info.data_len);
|
||||
|
||||
stream.write(reinterpret_cast<const char*>(&WAV_CHUNK_ID_RIFF), sizeof(WAV_CHUNK_ID_RIFF));
|
||||
stream.write(reinterpret_cast<const char*>(&riffMasterChunkSize), sizeof(riffMasterChunkSize));
|
||||
stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof(WAV_WAVE_ID));
|
||||
|
||||
const WavChunkHeader formatChunkHeader
|
||||
{
|
||||
WAV_CHUNK_ID_FMT,
|
||||
sizeof(WavFormatChunkPcm)
|
||||
};
|
||||
const WavChunkHeader formatChunkHeader{WAV_CHUNK_ID_FMT, sizeof(WavFormatChunkPcm)};
|
||||
stream.write(reinterpret_cast<const char*>(&formatChunkHeader), sizeof(formatChunkHeader));
|
||||
|
||||
WavFormatChunkPcm formatChunk
|
||||
{
|
||||
WavFormat::PCM,
|
||||
static_cast<uint16_t>(asset->sound.info.channels),
|
||||
asset->sound.info.rate,
|
||||
asset->sound.info.rate * asset->sound.info.channels * asset->sound.info.bits / 8,
|
||||
static_cast<uint16_t>(asset->sound.info.block_size),
|
||||
static_cast<uint16_t>(asset->sound.info.bits)
|
||||
};
|
||||
WavFormatChunkPcm formatChunk{WavFormat::PCM,
|
||||
static_cast<uint16_t>(asset->sound.info.channels),
|
||||
asset->sound.info.rate,
|
||||
asset->sound.info.rate * asset->sound.info.channels * asset->sound.info.bits / 8,
|
||||
static_cast<uint16_t>(asset->sound.info.block_size),
|
||||
static_cast<uint16_t>(asset->sound.info.bits)};
|
||||
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
|
||||
|
||||
const WavChunkHeader dataChunkHeader
|
||||
{
|
||||
WAV_CHUNK_ID_DATA,
|
||||
asset->sound.info.data_len
|
||||
};
|
||||
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, asset->sound.info.data_len};
|
||||
stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
|
||||
stream.write(asset->sound.data, asset->sound.info.data_len);
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ namespace IW3
|
||||
bool ShouldDump(XAssetInfo<LoadedSound>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "AssetDumperLocalizeEntry.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Localize/LocalizeCommon.h"
|
||||
#include "Dumping/Localize/StringFileDumper.h"
|
||||
#include "Localize/LocalizeCommon.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
@ -40,4 +40,4 @@ void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<
|
||||
{
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ namespace IW3
|
||||
public:
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -11,4 +11,4 @@ namespace IW3
|
||||
bool ShouldDump(XAssetInfo<MapEnts>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "AssetDumperMaterial.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "Game/IW3/MaterialConstantsIW3.h"
|
||||
#include "Game/IW3/TechsetConstantsIW3.h"
|
||||
|
||||
//#define FLAGS_DEBUG 1
|
||||
#include <iomanip>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// #define FLAGS_DEBUG 1
|
||||
|
||||
using namespace IW3;
|
||||
using json = nlohmann::json;
|
||||
@ -21,8 +21,7 @@ namespace IW3
|
||||
return name;
|
||||
}
|
||||
|
||||
template <size_t S>
|
||||
json ArrayEntry(const char* (&a)[S], const size_t index)
|
||||
template<size_t S> json ArrayEntry(const char* (&a)[S], const size_t index)
|
||||
{
|
||||
assert(index < S);
|
||||
if (index < S)
|
||||
@ -73,20 +72,8 @@ namespace IW3
|
||||
|
||||
json BuildSamplerStateJson(unsigned char samplerState)
|
||||
{
|
||||
static const char* samplerFilterNames[]
|
||||
{
|
||||
"none",
|
||||
"nearest",
|
||||
"linear",
|
||||
"aniso2x",
|
||||
"aniso4x"
|
||||
};
|
||||
static const char* samplerMipmapNames[]
|
||||
{
|
||||
"disabled",
|
||||
"nearest",
|
||||
"linear"
|
||||
};
|
||||
static const char* samplerFilterNames[]{"none", "nearest", "linear", "aniso2x", "aniso4x"};
|
||||
static const char* samplerMipmapNames[]{"disabled", "nearest", "linear"};
|
||||
|
||||
return json{
|
||||
{"filter", ArrayEntry(samplerFilterNames, (samplerState & SAMPLER_FILTER_MASK) >> SAMPLER_FILTER_SHIFT)},
|
||||
@ -99,21 +86,8 @@ namespace IW3
|
||||
|
||||
json BuildTextureTableJson(const MaterialTextureDef* textureTable, const size_t count)
|
||||
{
|
||||
static const char* semanticNames[]
|
||||
{
|
||||
"2d",
|
||||
"function",
|
||||
"colorMap",
|
||||
"unused1",
|
||||
"unused2",
|
||||
"normalMap",
|
||||
"unused3",
|
||||
"unused4",
|
||||
"specularMap",
|
||||
"unused5",
|
||||
"unused6",
|
||||
"waterMap"
|
||||
};
|
||||
static const char* semanticNames[]{
|
||||
"2d", "function", "colorMap", "unused1", "unused2", "normalMap", "unused3", "unused4", "specularMap", "unused5", "unused6", "waterMap"};
|
||||
|
||||
auto jArray = json::array();
|
||||
|
||||
@ -136,9 +110,9 @@ namespace IW3
|
||||
else
|
||||
{
|
||||
jEntry.merge_patch({
|
||||
{"nameHash", entry.nameHash},
|
||||
{"nameHash", entry.nameHash },
|
||||
{"nameStart", entry.nameStart},
|
||||
{"nameEnd", entry.nameEnd},
|
||||
{"nameEnd", entry.nameEnd },
|
||||
});
|
||||
}
|
||||
|
||||
@ -211,8 +185,7 @@ namespace IW3
|
||||
|
||||
json BuildStateBitsTableJson(const GfxStateBits* stateBitsTable, const size_t count)
|
||||
{
|
||||
static const char* blendNames[]
|
||||
{
|
||||
static const char* blendNames[]{
|
||||
"disabled",
|
||||
"zero",
|
||||
"one",
|
||||
@ -225,40 +198,20 @@ namespace IW3
|
||||
"destColor",
|
||||
"invDestColor",
|
||||
};
|
||||
static const char* blendOpNames[]
|
||||
{
|
||||
"disabled",
|
||||
"add",
|
||||
"subtract",
|
||||
"revSubtract",
|
||||
"min",
|
||||
"max"
|
||||
};
|
||||
static const char* depthTestNames[]
|
||||
{
|
||||
static const char* blendOpNames[]{"disabled", "add", "subtract", "revSubtract", "min", "max"};
|
||||
static const char* depthTestNames[]{
|
||||
"always",
|
||||
"less",
|
||||
"equal",
|
||||
"lessEqual",
|
||||
};
|
||||
static const char* polygonOffsetNames[]
|
||||
{
|
||||
static const char* polygonOffsetNames[]{
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"shadowMap",
|
||||
};
|
||||
static const char* stencilOpNames[]
|
||||
{
|
||||
"keep",
|
||||
"zero",
|
||||
"replace",
|
||||
"incrSat",
|
||||
"decrSat",
|
||||
"invert",
|
||||
"incr",
|
||||
"decr"
|
||||
};
|
||||
static const char* stencilOpNames[]{"keep", "zero", "replace", "incrSat", "decrSat", "invert", "incr", "decr"};
|
||||
|
||||
auto jArray = json::array();
|
||||
|
||||
@ -333,7 +286,8 @@ namespace IW3
|
||||
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)));
|
||||
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;
|
||||
@ -372,7 +326,7 @@ namespace IW3
|
||||
|
||||
return json(values);
|
||||
}
|
||||
}
|
||||
} // namespace IW3
|
||||
|
||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
||||
{
|
||||
@ -392,84 +346,72 @@ void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Mat
|
||||
|
||||
auto& stream = *assetFile;
|
||||
|
||||
static const char* cameraRegionNames[]
|
||||
{
|
||||
"lit",
|
||||
"decal",
|
||||
"emissive",
|
||||
"none"
|
||||
};
|
||||
static std::unordered_map<size_t, std::string> sortKeyNames
|
||||
{
|
||||
{0, "distortion"},
|
||||
{1, "opaque water"},
|
||||
{2, "boat hull"},
|
||||
{3, "opaque ambient"},
|
||||
{4, "opaque"},
|
||||
{5, "sky"},
|
||||
{6, "skybox - sun / moon"},
|
||||
{7, "skybox - clouds"},
|
||||
{8, "skybox - horizon"},
|
||||
{9, "decal - bottom 1"},
|
||||
{10, "decal - bottom 2"},
|
||||
{11, "decal - bottom 3"},
|
||||
{12, "decal - static decal"},
|
||||
{13, "decal - middle 1"},
|
||||
{14, "decal - middle 2"},
|
||||
{15, "decal - middle 3"},
|
||||
{24, "decal - weapon impact"},
|
||||
{29, "decal - top 1"},
|
||||
{30, "decal - top 2"},
|
||||
{31, "decal - top 3"},
|
||||
{32, "multiplicative"},
|
||||
{33, "banner / curtain"},
|
||||
{34, "hair"},
|
||||
{35, "underwater"},
|
||||
{36, "transparent water"},
|
||||
{37, "corona"},
|
||||
{38, "window inside"},
|
||||
{39, "window outside"},
|
||||
static const char* cameraRegionNames[]{"lit", "decal", "emissive", "none"};
|
||||
static std::unordered_map<size_t, std::string> sortKeyNames{
|
||||
{0, "distortion" },
|
||||
{1, "opaque water" },
|
||||
{2, "boat hull" },
|
||||
{3, "opaque ambient" },
|
||||
{4, "opaque" },
|
||||
{5, "sky" },
|
||||
{6, "skybox - sun / moon" },
|
||||
{7, "skybox - clouds" },
|
||||
{8, "skybox - horizon" },
|
||||
{9, "decal - bottom 1" },
|
||||
{10, "decal - bottom 2" },
|
||||
{11, "decal - bottom 3" },
|
||||
{12, "decal - static decal" },
|
||||
{13, "decal - middle 1" },
|
||||
{14, "decal - middle 2" },
|
||||
{15, "decal - middle 3" },
|
||||
{24, "decal - weapon impact" },
|
||||
{29, "decal - top 1" },
|
||||
{30, "decal - top 2" },
|
||||
{31, "decal - top 3" },
|
||||
{32, "multiplicative" },
|
||||
{33, "banner / curtain" },
|
||||
{34, "hair" },
|
||||
{35, "underwater" },
|
||||
{36, "transparent water" },
|
||||
{37, "corona" },
|
||||
{38, "window inside" },
|
||||
{39, "window outside" },
|
||||
{40, "before effects - bottom"},
|
||||
{41, "before effects - middle"},
|
||||
{42, "before effects - top"},
|
||||
{43, "blend / additive"},
|
||||
{48, "effect - auto sort"},
|
||||
{56, "after effects - bottom"},
|
||||
{57, "after effects - middle"},
|
||||
{58, "after effects - top"},
|
||||
{59, "viewmodel effect"},
|
||||
{42, "before effects - top" },
|
||||
{43, "blend / additive" },
|
||||
{48, "effect - auto sort" },
|
||||
{56, "after effects - bottom" },
|
||||
{57, "after effects - middle" },
|
||||
{58, "after effects - top" },
|
||||
{59, "viewmodel effect" },
|
||||
};
|
||||
|
||||
const auto foundSortKeyName = sortKeyNames.find(material->info.sortKey);
|
||||
assert(foundSortKeyName != sortKeyNames.end());
|
||||
|
||||
const json j = {
|
||||
{
|
||||
"info", {
|
||||
{"info",
|
||||
{
|
||||
#if defined(FLAGS_DEBUG) && FLAGS_DEBUG == 1
|
||||
{"gameFlags", BuildCharFlagsJson("gameFlag", material->info.gameFlags)}, // TODO: Find out what gameflags mean
|
||||
{"gameFlags", BuildCharFlagsJson("gameFlag", material->info.gameFlags)}, // TODO: Find out what gameflags mean
|
||||
#else
|
||||
{"gameFlags", material->info.gameFlags}, // TODO: Find out what gameflags mean
|
||||
{"gameFlags", material->info.gameFlags}, // TODO: Find out what gameflags mean
|
||||
#endif
|
||||
{"sortKey", foundSortKeyName != sortKeyNames.end() ? foundSortKeyName->second : std::to_string(material->info.sortKey)},
|
||||
{"textureAtlasRowCount", material->info.textureAtlasRowCount},
|
||||
{"textureAtlasColumnCount", material->info.textureAtlasColumnCount},
|
||||
{
|
||||
"drawSurf", {
|
||||
{"objectId", static_cast<unsigned>(material->info.drawSurf.fields.objectId)},
|
||||
{"reflectionProbeIndex", static_cast<unsigned>(material->info.drawSurf.fields.reflectionProbeIndex)},
|
||||
{"customIndex", static_cast<unsigned>(material->info.drawSurf.fields.customIndex)},
|
||||
{"materialSortedIndex", static_cast<unsigned>(material->info.drawSurf.fields.materialSortedIndex)},
|
||||
{"prepass", static_cast<unsigned>(material->info.drawSurf.fields.prepass)},
|
||||
{"useHeroLighting", static_cast<unsigned>(material->info.drawSurf.fields.primaryLightIndex)},
|
||||
{"surfType", static_cast<unsigned>(material->info.drawSurf.fields.surfType)},
|
||||
{"primarySortKey", static_cast<unsigned>(material->info.drawSurf.fields.primarySortKey)}
|
||||
}
|
||||
},
|
||||
{"surfaceTypeBits", BuildSurfaceTypeBitsJson(material->info.surfaceTypeBits)},
|
||||
{"hashIndex", material->info.hashIndex}
|
||||
}
|
||||
},
|
||||
{"sortKey", foundSortKeyName != sortKeyNames.end() ? foundSortKeyName->second : std::to_string(material->info.sortKey)},
|
||||
{"textureAtlasRowCount", material->info.textureAtlasRowCount},
|
||||
{"textureAtlasColumnCount", material->info.textureAtlasColumnCount},
|
||||
{"drawSurf",
|
||||
{{"objectId", static_cast<unsigned>(material->info.drawSurf.fields.objectId)},
|
||||
{"reflectionProbeIndex", static_cast<unsigned>(material->info.drawSurf.fields.reflectionProbeIndex)},
|
||||
{"customIndex", static_cast<unsigned>(material->info.drawSurf.fields.customIndex)},
|
||||
{"materialSortedIndex", static_cast<unsigned>(material->info.drawSurf.fields.materialSortedIndex)},
|
||||
{"prepass", static_cast<unsigned>(material->info.drawSurf.fields.prepass)},
|
||||
{"useHeroLighting", static_cast<unsigned>(material->info.drawSurf.fields.primaryLightIndex)},
|
||||
{"surfType", static_cast<unsigned>(material->info.drawSurf.fields.surfType)},
|
||||
{"primarySortKey", static_cast<unsigned>(material->info.drawSurf.fields.primarySortKey)}}},
|
||||
{"surfaceTypeBits", BuildSurfaceTypeBitsJson(material->info.surfaceTypeBits)},
|
||||
{"hashIndex", material->info.hashIndex}}},
|
||||
{"stateBitsEntry", std::vector(std::begin(material->stateBitsEntry), std::end(material->stateBitsEntry))},
|
||||
#if defined(FLAGS_DEBUG) && FLAGS_DEBUG == 1
|
||||
{"stateFlags", BuildCharFlagsJson("stateFlag", material->stateFlags)},
|
||||
|
@ -11,4 +11,4 @@ namespace IW3
|
||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -11,4 +11,4 @@ namespace IW3
|
||||
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -11,4 +11,4 @@ namespace IW3
|
||||
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "AssetDumperXModel.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
#include "ObjWriting.h"
|
||||
#include "Game/IW3/CommonIW3.h"
|
||||
#include "Math/Quaternion.h"
|
||||
#include "Model/XModel/XModelExportWriter.h"
|
||||
#include "ObjWriting.h"
|
||||
#include "Utils/HalfFloat.h"
|
||||
#include "Utils/QuatInt16.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
bool AssetDumperXModel::ShouldDump(XAssetInfo<XModel>* asset)
|
||||
@ -273,7 +273,8 @@ void AssetDumperXModel::AddXModelBones(const AssetDumpingContext& context, Abstr
|
||||
bone.globalOffset[0] = model->baseMat[boneNum].trans[0];
|
||||
bone.globalOffset[1] = model->baseMat[boneNum].trans[1];
|
||||
bone.globalOffset[2] = model->baseMat[boneNum].trans[2];
|
||||
bone.globalRotation = Quaternion32(model->baseMat[boneNum].quat[0], model->baseMat[boneNum].quat[1], model->baseMat[boneNum].quat[2], model->baseMat[boneNum].quat[3]);
|
||||
bone.globalRotation =
|
||||
Quaternion32(model->baseMat[boneNum].quat[0], model->baseMat[boneNum].quat[1], model->baseMat[boneNum].quat[2], model->baseMat[boneNum].quat[3]);
|
||||
|
||||
if (boneNum < model->numRootBones)
|
||||
{
|
||||
@ -287,12 +288,10 @@ void AssetDumperXModel::AddXModelBones(const AssetDumpingContext& context, Abstr
|
||||
bone.localOffset[0] = model->trans[boneNum - model->numRootBones][0];
|
||||
bone.localOffset[1] = model->trans[boneNum - model->numRootBones][1];
|
||||
bone.localOffset[2] = model->trans[boneNum - model->numRootBones][2];
|
||||
bone.localRotation = Quaternion32(
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]),
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]),
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]),
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3])
|
||||
);
|
||||
bone.localRotation = Quaternion32(QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][0]),
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][1]),
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][2]),
|
||||
QuatInt16::ToFloat(model->quats[boneNum - model->numRootBones][3]));
|
||||
}
|
||||
|
||||
writer.AddBone(std::move(bone));
|
||||
@ -398,7 +397,10 @@ void AssetDumperXModel::AllocateXModelBoneWeights(const XModel* model, const uns
|
||||
weightCollection.weights = std::make_unique<XModelBoneWeight[]>(weightCollection.totalWeightCount);
|
||||
}
|
||||
|
||||
void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModel* model, const unsigned lod, XModelVertexBoneWeightCollection& weightCollection)
|
||||
void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
const XModel* model,
|
||||
const unsigned lod,
|
||||
XModelVertexBoneWeightCollection& weightCollection)
|
||||
{
|
||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
@ -417,17 +419,11 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto* boneWeightOffset = &weightCollection.weights[weightOffset];
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
static_cast<int>(vertList.boneOffset / sizeof(DObjSkelMat)),
|
||||
1.0f
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<int>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
|
||||
boneWeightOffset,
|
||||
1
|
||||
});
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 1});
|
||||
}
|
||||
handledVertices += vertList.vertCount;
|
||||
}
|
||||
@ -441,17 +437,11 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
{
|
||||
const auto* boneWeightOffset = &weightCollection.weights[weightOffset];
|
||||
const auto boneIndex0 = static_cast<int>(surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat));
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex0,
|
||||
1.0f
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
|
||||
boneWeightOffset,
|
||||
1
|
||||
});
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 1});
|
||||
}
|
||||
|
||||
// 2 bone weights
|
||||
@ -463,21 +453,12 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
const auto boneWeight1 = HalfFloat::ToFloat(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex0,
|
||||
boneWeight0
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex1,
|
||||
boneWeight1
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
|
||||
vertsBlendOffset += 3;
|
||||
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
|
||||
boneWeightOffset,
|
||||
2
|
||||
});
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 2});
|
||||
}
|
||||
|
||||
// 3 bone weights
|
||||
@ -491,25 +472,13 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
const auto boneWeight2 = HalfFloat::ToFloat(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex0,
|
||||
boneWeight0
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex1,
|
||||
boneWeight1
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex2,
|
||||
boneWeight2
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
|
||||
|
||||
vertsBlendOffset += 5;
|
||||
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
|
||||
boneWeightOffset,
|
||||
3
|
||||
});
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 3});
|
||||
}
|
||||
|
||||
// 4 bone weights
|
||||
@ -525,29 +494,14 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
const auto boneWeight3 = HalfFloat::ToFloat(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex0,
|
||||
boneWeight0
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex1,
|
||||
boneWeight1
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex2,
|
||||
boneWeight2
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{
|
||||
boneIndex3,
|
||||
boneWeight3
|
||||
};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex3, boneWeight3};
|
||||
|
||||
vertsBlendOffset += 7;
|
||||
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
|
||||
boneWeightOffset,
|
||||
4
|
||||
});
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{boneWeightOffset, 4});
|
||||
}
|
||||
|
||||
handledVertices += surface.vertInfo.vertCount[0] + surface.vertInfo.vertCount[1] + surface.vertInfo.vertCount[2] + surface.vertInfo.vertCount[3];
|
||||
@ -555,10 +509,7 @@ void AssetDumperXModel::AddXModelVertexBoneWeights(AbstractXModelWriter& writer,
|
||||
|
||||
for (; handledVertices < surface.vertCount; handledVertices++)
|
||||
{
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{
|
||||
nullptr,
|
||||
0
|
||||
});
|
||||
writer.AddVertexBoneWeights(XModelVertexBoneWeights{nullptr, 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
#include "Utils/DistinctMapper.h"
|
||||
#include "Model/XModel/AbstractXModelWriter.h"
|
||||
#include "Model/Obj/ObjWriter.h"
|
||||
#include "Model/XModel/AbstractXModelWriter.h"
|
||||
#include "Utils/DistinctMapper.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
@ -27,7 +27,8 @@ namespace IW3
|
||||
static void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, unsigned lod);
|
||||
static void AddXModelVertices(AbstractXModelWriter& writer, const XModel* model, unsigned lod);
|
||||
static void AllocateXModelBoneWeights(const XModel* model, unsigned lod, XModelVertexBoneWeightCollection& weightCollection);
|
||||
static void AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModel* model, unsigned lod, XModelVertexBoneWeightCollection& weightCollection);
|
||||
static void
|
||||
AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModel* model, unsigned lod, XModelVertexBoneWeightCollection& weightCollection);
|
||||
static void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModel* model, unsigned lod);
|
||||
static void DumpXModelExportLod(const AssetDumpingContext& context, XAssetInfo<XModel>* asset, unsigned lod);
|
||||
static void DumpXModelExport(const AssetDumpingContext& context, XAssetInfo<XModel>* asset);
|
||||
@ -36,4 +37,4 @@ namespace IW3
|
||||
bool ShouldDump(XAssetInfo<XModel>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<XModel>* asset) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "ZoneDumperIW3.h"
|
||||
|
||||
#include "ObjWriting.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
|
||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||
#include "AssetDumpers/AssetDumperLoadedSound.h"
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
@ -13,6 +9,9 @@
|
||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||
#include "AssetDumpers/AssetDumperXModel.h"
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "ObjWriting.h"
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
@ -23,11 +22,11 @@ bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
||||
|
||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
{
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||
if(assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(context, assetPools->poolName.get()); \
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \
|
||||
if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(context, assetPools->poolName.get()); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolIW3*>(context.m_zone->m_pools.get());
|
||||
|
@ -9,4 +9,4 @@ namespace IW3
|
||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
||||
bool DumpZone(AssetDumpingContext& context) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW3
|
||||
|
Reference in New Issue
Block a user