2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-05 16:27:27 +00:00

refactor: template remaining xmodel files for iw5,t5,t6

This commit is contained in:
Jan
2025-07-09 21:57:22 +01:00
parent 1b8eff17f0
commit a9c693d04d
10 changed files with 99 additions and 235 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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

View File

@@ -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