mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-11 13:41:50 +00:00
refactor: template remaining xmodel files for iw5,t5,t6
This commit is contained in:
@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
std::optional<std::string> physCollmap;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModel, lods, collLod, physPreset, physCollmap, flags);
|
||||
} // namespace IW5
|
@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
inline const char* HITLOC_NAMES[]{
|
||||
// clang-format off
|
||||
"none",
|
||||
"helmet",
|
||||
"head",
|
||||
"neck",
|
||||
"torso_upper",
|
||||
"torso_lower",
|
||||
"right_arm_upper",
|
||||
"left_arm_upper",
|
||||
"right_arm_lower",
|
||||
"left_arm_lower",
|
||||
"right_hand",
|
||||
"left_hand",
|
||||
"right_leg_upper",
|
||||
"left_leg_upper",
|
||||
"right_leg_lower",
|
||||
"left_leg_lower",
|
||||
"right_foot",
|
||||
"left_foot",
|
||||
"gun",
|
||||
"shield",
|
||||
// clang-format on
|
||||
};
|
||||
static_assert(std::extent_v<decltype(HITLOC_NAMES)> == HITLOC_COUNT);
|
||||
} // namespace IW5
|
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
std::optional<std::string> physConstraints;
|
||||
unsigned flags;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModel, lods, collLod, physPreset, physConstraints, flags);
|
||||
} // namespace T5
|
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
inline const char* HITLOC_NAMES[]{
|
||||
// clang-format off
|
||||
"none",
|
||||
"helmet",
|
||||
"head",
|
||||
"neck",
|
||||
"torso_upper",
|
||||
"torso_lower",
|
||||
"right_arm_upper",
|
||||
"left_arm_upper",
|
||||
"right_arm_lower",
|
||||
"left_arm_lower",
|
||||
"right_hand",
|
||||
"left_hand",
|
||||
"right_leg_upper",
|
||||
"left_leg_upper",
|
||||
"right_leg_lower",
|
||||
"left_leg_lower",
|
||||
"right_foot",
|
||||
"left_foot",
|
||||
"gun",
|
||||
// clang-format on
|
||||
};
|
||||
static_assert(std::extent_v<decltype(HITLOC_NAMES)> == HITLOC_COUNT);
|
||||
} // namespace T5
|
@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
std::optional<std::string> physConstraints;
|
||||
unsigned flags;
|
||||
JsonVec3 lightingOriginOffset;
|
||||
float lightingOriginRange;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModel, lods, collLod, physPreset, physConstraints, flags, lightingOriginOffset, lightingOriginRange);
|
||||
} // namespace T6
|
71
src/ObjCommon/XModel/JsonXModel.h.template
Normal file
71
src/ObjCommon/XModel/JsonXModel.h.template
Normal file
@ -0,0 +1,71 @@
|
||||
#options GAME (IW5, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/XModel/JsonXModel" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
|
||||
#if GAME == "IW5"
|
||||
#define FEATURE_IW5
|
||||
#elif GAME == "T5"
|
||||
#define FEATURE_T5
|
||||
#elif GAME == "T6"
|
||||
#define FEATURE_T6
|
||||
#endif
|
||||
|
||||
// This file was templated.
|
||||
// See JsonXModel.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace GAME
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
#if defined(FEATURE_IW5)
|
||||
std::optional<std::string> physCollmap;
|
||||
#elif defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
std::optional<std::string> physConstraints;
|
||||
#endif
|
||||
#if defined(FEATURE_T6)
|
||||
JsonVec3 lightingOriginOffset;
|
||||
float lightingOriginRange;
|
||||
#endif
|
||||
unsigned flags;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(
|
||||
JsonXModel,
|
||||
lods,
|
||||
collLod,
|
||||
physPreset,
|
||||
#if defined(FEATURE_IW5)
|
||||
physCollmap,
|
||||
#elif defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
physConstraints,
|
||||
#endif
|
||||
#if defined(FEATURE_T6)
|
||||
lightingOriginOffset,
|
||||
lightingOriginRange,
|
||||
#endif
|
||||
flags
|
||||
);
|
||||
} // namespace GAME
|
@ -1,17 +1,36 @@
|
||||
#options GAME (IW5, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/XModel/XModelConstants" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
|
||||
#if GAME == "IW5"
|
||||
#define FEATURE_IW5
|
||||
#elif GAME == "T5"
|
||||
#define FEATURE_T5
|
||||
#elif GAME == "T6"
|
||||
#define FEATURE_T6
|
||||
#endif
|
||||
|
||||
// This file was templated.
|
||||
// See JsonXModel.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
#pragma once
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#include GAME_HEADER
|
||||
|
||||
namespace T6
|
||||
namespace GAME
|
||||
{
|
||||
inline const char* HITLOC_NAMES[]{
|
||||
// clang-format off
|
||||
"none",
|
||||
"helmet",
|
||||
"head",
|
||||
"neck",
|
||||
"torso_upper",
|
||||
#if defined(FEATURE_T6)
|
||||
"torso_middle",
|
||||
#endif
|
||||
"torso_lower",
|
||||
"right_arm_upper",
|
||||
"left_arm_upper",
|
||||
@ -26,8 +45,9 @@ namespace T6
|
||||
"right_foot",
|
||||
"left_foot",
|
||||
"gun",
|
||||
#if defined(FEATURE_IW5) || defined(FEATURE_T6)
|
||||
"shield",
|
||||
// clang-format on
|
||||
#endif
|
||||
};
|
||||
static_assert(std::extent_v<decltype(HITLOC_NAMES)> == HITLOC_COUNT);
|
||||
} // namespace T6
|
||||
} // namespace GAME
|
@ -1,55 +0,0 @@
|
||||
// #include "LoaderXModelIW5.h"
|
||||
|
||||
// #include "Game/IW5/IW5.h"
|
||||
// #include "Game/IW5/XModel/XModelLoaderIW5.h"
|
||||
// #include "Pool/GlobalAssetPool.h"
|
||||
|
||||
// #include <cstring>
|
||||
// #include <format>
|
||||
// #include <iostream>
|
||||
|
||||
// using namespace IW5;
|
||||
|
||||
// namespace
|
||||
// {
|
||||
// class XModelLoader final : public AssetCreator<AssetXModel>
|
||||
// {
|
||||
// public:
|
||||
// XModelLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
// : m_memory(memory),
|
||||
// m_search_path(searchPath)
|
||||
// {
|
||||
// }
|
||||
|
||||
// AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
// {
|
||||
// const auto file = m_search_path.Open(std::format("xmodel/{}.json", assetName));
|
||||
// if (!file.IsOpen())
|
||||
// return AssetCreationResult::NoAction();
|
||||
|
||||
// auto* xmodel = m_memory.Alloc<XModel>();
|
||||
// xmodel->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
// AssetRegistration<AssetXModel> registration(assetName, xmodel);
|
||||
// if (!LoadXModel(*file.m_stream, *xmodel, m_memory, context, registration))
|
||||
// {
|
||||
// std::cerr << std::format("Failed to load xmodel \"{}\"\n", assetName);
|
||||
// return AssetCreationResult::Failure();
|
||||
// }
|
||||
|
||||
// return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
// }
|
||||
|
||||
// private:
|
||||
// MemoryManager& m_memory;
|
||||
// ISearchPath& m_search_path;
|
||||
// };
|
||||
// } // namespace
|
||||
|
||||
// namespace IW5
|
||||
// {
|
||||
// std::unique_ptr<AssetCreator<AssetXModel>> CreateXModelLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
// {
|
||||
// return std::make_unique<XModelLoader>(memory, searchPath);
|
||||
// }
|
||||
// } // namespace IW5
|
@ -1,13 +0,0 @@
|
||||
// #pragma once
|
||||
|
||||
// #include "Asset/IAssetCreator.h"
|
||||
// #include "Game/IW5/IW5.h"
|
||||
// #include "SearchPath/ISearchPath.h"
|
||||
// #include "Utils/MemoryManager.h"
|
||||
|
||||
// #include <memory>
|
||||
|
||||
// namespace IW5
|
||||
// {
|
||||
// std::unique_ptr<AssetCreator<AssetXModel>> CreateXModelLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
// } // namespace IW5
|
@ -66,7 +66,7 @@ namespace
|
||||
{
|
||||
MaterialTextureDef* def = &material->textureTable[textureIndex];
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW5)
|
||||
if (def->semantic == TS_COLOR_MAP)
|
||||
potentialTextureDefs.push_back(def);
|
||||
#else
|
||||
@ -155,7 +155,7 @@ namespace
|
||||
|
||||
bool GetSurfaces(const XModel* model, const unsigned lod, XSurface*& surfs, unsigned& surfCount)
|
||||
{
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW5)
|
||||
if (!model->lodInfo[lod].modelSurfs || !model->lodInfo[lod].modelSurfs->surfs)
|
||||
return false;
|
||||
|
||||
@ -722,7 +722,7 @@ namespace
|
||||
if (xmodel.physPreset && xmodel.physPreset->name)
|
||||
jXModel.physPreset = AssetName(xmodel.physPreset->name);
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW5)
|
||||
if (xmodel.physCollmap && xmodel.physCollmap->name)
|
||||
jXModel.physCollmap = AssetName(xmodel.physCollmap->name);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user