mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-06 00:37:26 +00:00
refactor: use templated xmodel loading and dumping code for iw4
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "Asset/GlobalAssetPoolsLoader.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/XModel/LoaderXModelIW4.h"
|
||||
#include "Leaderboard/LoaderLeaderboardIW4.h"
|
||||
#include "LightDef/LoaderLightDefIW4.h"
|
||||
#include "Localize/LoaderLocalizeIW4.h"
|
||||
@@ -123,7 +124,7 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModelSurfs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModel>(memory));
|
||||
collection.AddAssetCreator(CreateXModelLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreatePixelShaderLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateVertexShaderLoader(memory, searchPath));
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#options GAME(IW5, T5, T6)
|
||||
#options GAME(IW4, IW5, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/XModel/LoaderXModel" + GAME + ".cpp"
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#set CONSTANTS_HEADER "\"Game/" + GAME + "/XModel/XModelConstants" + GAME + ".h\""
|
||||
#set JSON_HEADER "\"Game/" + GAME + "/XModel/JsonXModel" + GAME + ".h\""
|
||||
|
||||
#if GAME == "IW5"
|
||||
#if GAME == "IW4"
|
||||
#define FEATURE_IW4
|
||||
#elif GAME == "IW5"
|
||||
#define FEATURE_IW5
|
||||
#elif GAME == "T5"
|
||||
#define FEATURE_T5
|
||||
@@ -191,7 +193,7 @@ namespace
|
||||
if (common.m_bone_weight_data.weights.empty())
|
||||
return;
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
vec3_t minCoordinate, maxCoordinate;
|
||||
auto& offset = info.bounds.midPoint;
|
||||
#else
|
||||
@@ -236,7 +238,7 @@ namespace
|
||||
const Eigen::Vector3f maxEigen(maxCoordinate.x, maxCoordinate.y, maxCoordinate.z);
|
||||
const Eigen::Vector3f boundsCenter = (minEigen + maxEigen) * 0.5f;
|
||||
const Eigen::Vector3f halfSizeEigen = maxEigen - boundsCenter;
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
|
||||
info.bounds.halfSize.x = halfSizeEigen.x();
|
||||
info.bounds.halfSize.y = halfSizeEigen.y();
|
||||
@@ -727,7 +729,7 @@ namespace
|
||||
lodInfo.partBits[i] |= surface.partBits[i];
|
||||
}
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
auto* modelSurfs = m_memory.Alloc<XModelSurfs>();
|
||||
const auto modelSurfsName = std::format("{}_lod{}", xmodel.name, lodNumber);
|
||||
modelSurfs->name = m_memory.Dup(modelSurfsName.c_str());
|
||||
@@ -752,7 +754,7 @@ namespace
|
||||
|
||||
static void CalculateModelBounds(XModel& xmodel)
|
||||
{
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
if (!xmodel.lodInfo[0].modelSurfs || !xmodel.lodInfo[0].modelSurfs->surfs)
|
||||
return;
|
||||
|
||||
@@ -768,7 +770,7 @@ namespace
|
||||
|
||||
for (auto surfaceIndex = 0u; surfaceIndex < xmodel.lodInfo[0].numsurfs; surfaceIndex++)
|
||||
{
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
const auto& surface = surfs[surfaceIndex];
|
||||
#else
|
||||
const auto& surface = xmodel.surfs[surfaceIndex + xmodel.lodInfo[0].surfIndex];
|
||||
@@ -790,7 +792,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
const Eigen::Vector3f minEigen(minCoordinate.x, minCoordinate.y, minCoordinate.z);
|
||||
const Eigen::Vector3f maxEigen(maxCoordinate.x, maxCoordinate.y, maxCoordinate.z);
|
||||
const Eigen::Vector3f boundsCenter = (minEigen + maxEigen) * 0.5f;
|
||||
@@ -876,7 +878,7 @@ namespace
|
||||
xmodel.physPreset = nullptr;
|
||||
}
|
||||
|
||||
#if defined(FEATURE_IW5)
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
if (jXModel.physCollmap)
|
||||
{
|
||||
auto* physCollmap = context.LoadDependency<AssetPhysCollMap>(jXModel.physCollmap.value());
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#options GAME (IW5, T5, T6)
|
||||
#options GAME (IW4, IW5, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/XModel/LoaderXModel" + GAME + ".h"
|
||||
|
||||
|
Reference in New Issue
Block a user