mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-01-07 17:31:49 +00:00
feat: add embedded image loader for every supported game
This commit is contained in:
@@ -1515,7 +1515,8 @@ namespace IW3
|
|||||||
MAPTYPE_2D = 0x3,
|
MAPTYPE_2D = 0x3,
|
||||||
MAPTYPE_3D = 0x4,
|
MAPTYPE_3D = 0x4,
|
||||||
MAPTYPE_CUBE = 0x5,
|
MAPTYPE_CUBE = 0x5,
|
||||||
MAPTYPE_COUNT = 0x6,
|
|
||||||
|
MAPTYPE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TextureSemantic
|
enum TextureSemantic
|
||||||
|
|||||||
@@ -1181,6 +1181,18 @@ namespace IW4
|
|||||||
int platform[2];
|
int platform[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MapType
|
||||||
|
{
|
||||||
|
MAPTYPE_NONE = 0x0,
|
||||||
|
MAPTYPE_INVALID1 = 0x1,
|
||||||
|
MAPTYPE_1D = 0x2,
|
||||||
|
MAPTYPE_2D = 0x3,
|
||||||
|
MAPTYPE_3D = 0x4,
|
||||||
|
MAPTYPE_CUBE = 0x5,
|
||||||
|
|
||||||
|
MAPTYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
enum TextureSemantic
|
enum TextureSemantic
|
||||||
{
|
{
|
||||||
TS_2D = 0x0,
|
TS_2D = 0x0,
|
||||||
@@ -1197,6 +1209,19 @@ namespace IW4
|
|||||||
TS_WATER_MAP = 0xB,
|
TS_WATER_MAP = 0xB,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImageCategory
|
||||||
|
{
|
||||||
|
IMG_CATEGORY_UNKNOWN = 0x0,
|
||||||
|
IMG_CATEGORY_AUTO_GENERATED = 0x1,
|
||||||
|
IMG_CATEGORY_LIGHTMAP = 0x2,
|
||||||
|
IMG_CATEGORY_LOAD_FROM_FILE = 0x3,
|
||||||
|
IMG_CATEGORY_RAW = 0x4,
|
||||||
|
IMG_CATEGORY_FIRST_UNMANAGED = 0x5,
|
||||||
|
IMG_CATEGORY_WATER = 0x5,
|
||||||
|
IMG_CATEGORY_RENDERTARGET = 0x6,
|
||||||
|
IMG_CATEGORY_TEMP = 0x7,
|
||||||
|
};
|
||||||
|
|
||||||
struct GfxImage
|
struct GfxImage
|
||||||
{
|
{
|
||||||
GfxTexture texture;
|
GfxTexture texture;
|
||||||
|
|||||||
@@ -732,23 +732,6 @@ namespace IW5
|
|||||||
GfxImage* image;
|
GfxImage* image;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TextureSemantic
|
|
||||||
{
|
|
||||||
TS_2D = 0x0,
|
|
||||||
TS_FUNCTION = 0x1,
|
|
||||||
TS_COLOR_MAP = 0x2,
|
|
||||||
TS_DETAIL_MAP = 0x3,
|
|
||||||
TS_UNUSED_2 = 0x4,
|
|
||||||
TS_NORMAL_MAP = 0x5,
|
|
||||||
TS_UNUSED_3 = 0x6,
|
|
||||||
TS_UNUSED_4 = 0x7,
|
|
||||||
TS_SPECULAR_MAP = 0x8,
|
|
||||||
TS_UNUSED_5 = 0x9,
|
|
||||||
TS_UNUSED_6 = 0xA,
|
|
||||||
TS_WATER_MAP = 0xB,
|
|
||||||
TS_DISPLACEMENT_MAP = 0xC
|
|
||||||
};
|
|
||||||
|
|
||||||
union MaterialTextureDefInfo
|
union MaterialTextureDefInfo
|
||||||
{
|
{
|
||||||
GfxImage* image;
|
GfxImage* image;
|
||||||
@@ -1157,6 +1140,48 @@ namespace IW5
|
|||||||
int platform[2];
|
int platform[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MapType
|
||||||
|
{
|
||||||
|
MAPTYPE_NONE = 0x0,
|
||||||
|
MAPTYPE_INVALID1 = 0x1,
|
||||||
|
MAPTYPE_1D = 0x2,
|
||||||
|
MAPTYPE_2D = 0x3,
|
||||||
|
MAPTYPE_3D = 0x4,
|
||||||
|
MAPTYPE_CUBE = 0x5,
|
||||||
|
|
||||||
|
MAPTYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum TextureSemantic
|
||||||
|
{
|
||||||
|
TS_2D = 0x0,
|
||||||
|
TS_FUNCTION = 0x1,
|
||||||
|
TS_COLOR_MAP = 0x2,
|
||||||
|
TS_DETAIL_MAP = 0x3,
|
||||||
|
TS_UNUSED_2 = 0x4,
|
||||||
|
TS_NORMAL_MAP = 0x5,
|
||||||
|
TS_UNUSED_3 = 0x6,
|
||||||
|
TS_UNUSED_4 = 0x7,
|
||||||
|
TS_SPECULAR_MAP = 0x8,
|
||||||
|
TS_UNUSED_5 = 0x9,
|
||||||
|
TS_UNUSED_6 = 0xA,
|
||||||
|
TS_WATER_MAP = 0xB,
|
||||||
|
TS_DISPLACEMENT_MAP = 0xC
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImageCategory
|
||||||
|
{
|
||||||
|
IMG_CATEGORY_UNKNOWN = 0x0,
|
||||||
|
IMG_CATEGORY_AUTO_GENERATED = 0x1,
|
||||||
|
IMG_CATEGORY_LIGHTMAP = 0x2,
|
||||||
|
IMG_CATEGORY_LOAD_FROM_FILE = 0x3,
|
||||||
|
IMG_CATEGORY_RAW = 0x4,
|
||||||
|
IMG_CATEGORY_FIRST_UNMANAGED = 0x5,
|
||||||
|
IMG_CATEGORY_WATER = 0x5,
|
||||||
|
IMG_CATEGORY_RENDERTARGET = 0x6,
|
||||||
|
IMG_CATEGORY_TEMP = 0x7,
|
||||||
|
};
|
||||||
|
|
||||||
struct GfxImage
|
struct GfxImage
|
||||||
{
|
{
|
||||||
GfxTexture texture;
|
GfxTexture texture;
|
||||||
|
|||||||
@@ -1242,6 +1242,18 @@ namespace T5
|
|||||||
int platform[2];
|
int platform[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MapType
|
||||||
|
{
|
||||||
|
MAPTYPE_NONE = 0x0,
|
||||||
|
MAPTYPE_INVALID1 = 0x1,
|
||||||
|
MAPTYPE_INVALID2 = 0x2,
|
||||||
|
MAPTYPE_2D = 0x3,
|
||||||
|
MAPTYPE_3D = 0x4,
|
||||||
|
MAPTYPE_CUBE = 0x5,
|
||||||
|
|
||||||
|
MAPTYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
enum TextureSemantic
|
enum TextureSemantic
|
||||||
{
|
{
|
||||||
TS_2D = 0x0,
|
TS_2D = 0x0,
|
||||||
|
|||||||
@@ -879,6 +879,18 @@ namespace T6
|
|||||||
uint32_t valid : 1;
|
uint32_t valid : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MapType
|
||||||
|
{
|
||||||
|
MAPTYPE_NONE = 0x0,
|
||||||
|
MAPTYPE_INVALID1 = 0x1,
|
||||||
|
MAPTYPE_INVALID2 = 0x2,
|
||||||
|
MAPTYPE_2D = 0x3,
|
||||||
|
MAPTYPE_3D = 0x4,
|
||||||
|
MAPTYPE_CUBE = 0x5,
|
||||||
|
|
||||||
|
MAPTYPE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
enum TextureSemantic
|
enum TextureSemantic
|
||||||
{
|
{
|
||||||
TS_2D = 0x0,
|
TS_2D = 0x0,
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Asset/IAssetCreator.h"
|
|
||||||
#include "Game/IW3/IW3.h"
|
|
||||||
#include "SearchPath/ISearchPath.h"
|
|
||||||
#include "Utils/MemoryManager.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace image
|
|
||||||
{
|
|
||||||
std::unique_ptr<AssetCreator<IW3::AssetImage>> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath);
|
|
||||||
} // namespace image
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Game/IW3/AssetMarkerIW3.h"
|
#include "Game/IW3/AssetMarkerIW3.h"
|
||||||
#include "Game/IW3/GameIW3.h"
|
#include "Game/IW3/GameIW3.h"
|
||||||
#include "Game/IW3/IW3.h"
|
#include "Game/IW3/IW3.h"
|
||||||
|
#include "Game/IW3/Image/ImageLoaderEmbeddedIW3.h"
|
||||||
#include "Game/IW3/Image/ImageLoaderExternalIW3.h"
|
#include "Game/IW3/Image/ImageLoaderExternalIW3.h"
|
||||||
#include "Game/IW3/XModel/LoaderXModelIW3.h"
|
#include "Game/IW3/XModel/LoaderXModelIW3.h"
|
||||||
#include "Localize/AssetLoaderLocalizeIW3.h"
|
#include "Localize/AssetLoaderLocalizeIW3.h"
|
||||||
@@ -95,6 +96,7 @@ namespace
|
|||||||
collection.AddAssetCreator(xmodel::CreateLoaderIW3(memory, searchPath, zone));
|
collection.AddAssetCreator(xmodel::CreateLoaderIW3(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(material::CreateLoaderIW3(memory, searchPath));
|
collection.AddAssetCreator(material::CreateLoaderIW3(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||||
|
collection.AddAssetCreator(image::CreateLoaderEmbeddedIW3(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderExternalIW3(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderExternalIW3(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Game/IW4/AssetMarkerIW4.h"
|
#include "Game/IW4/AssetMarkerIW4.h"
|
||||||
#include "Game/IW4/GameIW4.h"
|
#include "Game/IW4/GameIW4.h"
|
||||||
#include "Game/IW4/IW4.h"
|
#include "Game/IW4/IW4.h"
|
||||||
|
#include "Game/IW4/Image/ImageLoaderEmbeddedIW4.h"
|
||||||
#include "Game/IW4/Image/ImageLoaderExternalIW4.h"
|
#include "Game/IW4/Image/ImageLoaderExternalIW4.h"
|
||||||
#include "Game/IW4/XModel/LoaderXModelIW4.h"
|
#include "Game/IW4/XModel/LoaderXModelIW4.h"
|
||||||
#include "Leaderboard/LoaderLeaderboardIW4.h"
|
#include "Leaderboard/LoaderLeaderboardIW4.h"
|
||||||
@@ -131,6 +132,7 @@ namespace
|
|||||||
collection.AddAssetCreator(shader::CreatePixelShaderLoaderIW4(memory, searchPath));
|
collection.AddAssetCreator(shader::CreatePixelShaderLoaderIW4(memory, searchPath));
|
||||||
collection.AddAssetCreator(shader::CreateVertexShaderLoaderIW4(memory, searchPath));
|
collection.AddAssetCreator(shader::CreateVertexShaderLoaderIW4(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechset>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechset>(memory));
|
||||||
|
collection.AddAssetCreator(image::CreateLoaderEmbeddedIW4(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderExternalIW4(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderExternalIW4(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||||
collection.AddAssetCreator(sound_curve::CreateLoaderIW4(memory, searchPath));
|
collection.AddAssetCreator(sound_curve::CreateLoaderIW4(memory, searchPath));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Game/IW5/AssetMarkerIW5.h"
|
#include "Game/IW5/AssetMarkerIW5.h"
|
||||||
#include "Game/IW5/GameIW5.h"
|
#include "Game/IW5/GameIW5.h"
|
||||||
#include "Game/IW5/IW5.h"
|
#include "Game/IW5/IW5.h"
|
||||||
|
#include "Game/IW5/Image/ImageLoaderEmbeddedIW5.h"
|
||||||
#include "Game/IW5/Image/ImageLoaderExternalIW5.h"
|
#include "Game/IW5/Image/ImageLoaderExternalIW5.h"
|
||||||
#include "Game/IW5/XModel/LoaderXModelIW5.h"
|
#include "Game/IW5/XModel/LoaderXModelIW5.h"
|
||||||
#include "Leaderboard/LoaderLeaderboardIW5.h"
|
#include "Leaderboard/LoaderLeaderboardIW5.h"
|
||||||
@@ -132,6 +133,7 @@ namespace
|
|||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexShader>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexShader>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexDecl>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexDecl>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||||
|
collection.AddAssetCreator(image::CreateLoaderEmbeddedIW5(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderExternalIW5(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderExternalIW5(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "Asset/GlobalAssetPoolsLoader.h"
|
#include "Asset/GlobalAssetPoolsLoader.h"
|
||||||
#include "Game/T5/AssetMarkerT5.h"
|
#include "Game/T5/AssetMarkerT5.h"
|
||||||
#include "Game/T5/GameT5.h"
|
#include "Game/T5/GameT5.h"
|
||||||
|
#include "Game/T5/Image/ImageLoaderEmbeddedT5.h"
|
||||||
#include "Game/T5/Image/ImageLoaderExternalT5.h"
|
#include "Game/T5/Image/ImageLoaderExternalT5.h"
|
||||||
#include "Game/T5/T5.h"
|
#include "Game/T5/T5.h"
|
||||||
#include "Game/T5/XModel/LoaderXModelT5.h"
|
#include "Game/T5/XModel/LoaderXModelT5.h"
|
||||||
@@ -109,6 +110,7 @@ namespace
|
|||||||
collection.AddAssetCreator(xmodel::CreateLoaderT5(memory, searchPath, zone));
|
collection.AddAssetCreator(xmodel::CreateLoaderT5(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(material::CreateLoaderT5(memory, searchPath));
|
collection.AddAssetCreator(material::CreateLoaderT5(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||||
|
collection.AddAssetCreator(image::CreateLoaderEmbeddedT5(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderExternalT5(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderExternalT5(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundBank>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundBank>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Game/T6/CommonT6.h"
|
#include "Game/T6/CommonT6.h"
|
||||||
#include "Game/T6/GameAssetPoolT6.h"
|
#include "Game/T6/GameAssetPoolT6.h"
|
||||||
#include "Game/T6/GameT6.h"
|
#include "Game/T6/GameT6.h"
|
||||||
|
#include "Game/T6/Image/ImageLoaderEmbeddedT6.h"
|
||||||
#include "Game/T6/Image/ImageLoaderExternalT6.h"
|
#include "Game/T6/Image/ImageLoaderExternalT6.h"
|
||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
#include "Game/T6/XModel/LoaderXModelT6.h"
|
#include "Game/T6/XModel/LoaderXModelT6.h"
|
||||||
@@ -394,6 +395,7 @@ namespace T6
|
|||||||
collection.AddAssetCreator(xmodel::CreateLoaderT6(memory, searchPath, zone));
|
collection.AddAssetCreator(xmodel::CreateLoaderT6(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(material::CreateLoaderT6(memory, searchPath));
|
collection.AddAssetCreator(material::CreateLoaderT6(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||||
|
collection.AddAssetCreator(image::CreateLoaderEmbeddedT6(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderExternalT6(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderExternalT6(memory, searchPath));
|
||||||
collection.AddAssetCreator(sound::CreateSoundBankLoaderT6(memory, searchPath));
|
collection.AddAssetCreator(sound::CreateSoundBankLoaderT6(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||||
|
|||||||
@@ -1,25 +1,64 @@
|
|||||||
#include "AssetLoaderImageIW3.h"
|
#options GAME (IW3, IW4, IW5, T5, T6)
|
||||||
|
|
||||||
#include "Game/IW3/IW3.h"
|
#filename "Game/" + GAME + "/Image/ImageLoaderEmbedded" + GAME + ".cpp"
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FEATURE_IW3)
|
||||||
|
#define IWI_NS iwi6
|
||||||
|
#define FLAG_CUBE IMG_FLAG_CUBEMAP
|
||||||
|
#define FLAG_3D IMG_FLAG_VOLMAP
|
||||||
|
#elif defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||||
|
#define IWI_NS iwi8
|
||||||
|
#define FLAG_CUBE IMG_FLAG_MAPTYPE_CUBE
|
||||||
|
#define FLAG_3D IMG_FLAG_MAPTYPE_3D
|
||||||
|
#elif defined(FEATURE_T5)
|
||||||
|
#define IWI_NS iwi13
|
||||||
|
#define FLAG_CUBE IMG_FLAG_CUBEMAP
|
||||||
|
#define FLAG_3D IMG_FLAG_VOLMAP
|
||||||
|
#elif defined(FEATURE_T6)
|
||||||
|
#define IWI_NS iwi27
|
||||||
|
#define FLAG_CUBE IMG_FLAG_CUBEMAP
|
||||||
|
#define FLAG_3D IMG_FLAG_VOLMAP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See ImageLoaderEmbedded.cpp.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#set LOADER_HEADER "\"ImageLoaderEmbedded" + GAME + ".h\""
|
||||||
|
#include LOADER_HEADER
|
||||||
|
|
||||||
|
#set COMMON_HEADER "\"Game/" + GAME + "/Common" + GAME + ".h\""
|
||||||
|
#include COMMON_HEADER
|
||||||
#include "Image/DdsLoader.h"
|
#include "Image/DdsLoader.h"
|
||||||
|
#include "Image/ImageCommon.h"
|
||||||
#include "Image/IwiTypes.h"
|
#include "Image/IwiTypes.h"
|
||||||
#include "Pool/GlobalAssetPool.h"
|
|
||||||
#include "Utils/Logging/Log.h"
|
#include "Utils/Logging/Log.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <format>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace GAME;
|
||||||
using namespace image;
|
using namespace image;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class ImageLoader final : public AssetCreator<AssetImage>
|
#set LOADER_CLASS "ImageLoader" + GAME
|
||||||
|
class LOADER_CLASS final : public AssetCreator<AssetImage>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageLoader(MemoryManager& memory, ISearchPath& searchPath)
|
LOADER_CLASS(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
: m_memory(memory),
|
: m_memory(memory),
|
||||||
m_search_path(searchPath)
|
m_search_path(searchPath)
|
||||||
{
|
{
|
||||||
@@ -32,10 +71,7 @@ namespace
|
|||||||
if (assetName.empty() || assetName[0] != '*')
|
if (assetName.empty() || assetName[0] != '*')
|
||||||
return AssetCreationResult::NoAction();
|
return AssetCreationResult::NoAction();
|
||||||
|
|
||||||
std::string safeAssetName = assetName;
|
const auto file = m_search_path.Open(image::GetFileNameForAsset(assetName, ".dds"));
|
||||||
std::ranges::replace(safeAssetName, '*', '_');
|
|
||||||
|
|
||||||
const auto file = m_search_path.Open(std::format("images/{}.dds", safeAssetName));
|
|
||||||
if (!file.IsOpen())
|
if (!file.IsOpen())
|
||||||
return AssetCreationResult::NoAction();
|
return AssetCreationResult::NoAction();
|
||||||
|
|
||||||
@@ -59,7 +95,9 @@ namespace
|
|||||||
image->height = static_cast<uint16_t>(texture->GetHeight());
|
image->height = static_cast<uint16_t>(texture->GetHeight());
|
||||||
image->depth = static_cast<uint16_t>(texture->GetDepth());
|
image->depth = static_cast<uint16_t>(texture->GetDepth());
|
||||||
image->category = IMG_CATEGORY_AUTO_GENERATED;
|
image->category = IMG_CATEGORY_AUTO_GENERATED;
|
||||||
|
#ifndef FEATURE_IW5
|
||||||
image->delayLoadPixels = false;
|
image->delayLoadPixels = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (texture->GetTextureType())
|
switch (texture->GetTextureType())
|
||||||
{
|
{
|
||||||
@@ -92,15 +130,23 @@ namespace
|
|||||||
loadDef->levelCount = static_cast<char>(mipCount);
|
loadDef->levelCount = static_cast<char>(mipCount);
|
||||||
loadDef->flags = 0;
|
loadDef->flags = 0;
|
||||||
if (!texture->HasMipMaps())
|
if (!texture->HasMipMaps())
|
||||||
loadDef->flags |= image::iwi6::IMG_FLAG_NOMIPMAPS;
|
loadDef->flags |= IWI_NS::IMG_FLAG_NOMIPMAPS;
|
||||||
if (texture->GetTextureType() == TextureType::T_CUBE)
|
if (texture->GetTextureType() == TextureType::T_CUBE)
|
||||||
loadDef->flags |= image::iwi6::IMG_FLAG_CUBEMAP;
|
loadDef->flags |= IWI_NS::FLAG_CUBE;
|
||||||
if (texture->GetTextureType() == TextureType::T_3D)
|
if (texture->GetTextureType() == TextureType::T_3D)
|
||||||
loadDef->flags |= image::iwi6::IMG_FLAG_VOLMAP;
|
loadDef->flags |= IWI_NS::FLAG_3D;
|
||||||
|
|
||||||
|
#if defined(FEATURE_IW3)
|
||||||
loadDef->dimensions[0] = image->width;
|
loadDef->dimensions[0] = image->width;
|
||||||
loadDef->dimensions[1] = image->height;
|
loadDef->dimensions[1] = image->height;
|
||||||
loadDef->dimensions[2] = image->depth;
|
loadDef->dimensions[2] = image->depth;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FEATURE_T6)
|
||||||
|
loadDef->format = static_cast<int>(texture->GetFormat()->GetDxgiFormat());
|
||||||
|
#else
|
||||||
loadDef->format = static_cast<int>(texture->GetFormat()->GetD3DFormat());
|
loadDef->format = static_cast<int>(texture->GetFormat()->GetD3DFormat());
|
||||||
|
#endif
|
||||||
loadDef->resourceSize = static_cast<unsigned>(dataSize);
|
loadDef->resourceSize = static_cast<unsigned>(dataSize);
|
||||||
|
|
||||||
char* currentDataBuffer = loadDef->data;
|
char* currentDataBuffer = loadDef->data;
|
||||||
@@ -118,7 +164,6 @@ namespace
|
|||||||
return AssetCreationResult::Success(context.AddAsset<AssetImage>(assetName, image));
|
return AssetCreationResult::Success(context.AddAsset<AssetImage>(assetName, image));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryManager& m_memory;
|
MemoryManager& m_memory;
|
||||||
ISearchPath& m_search_path;
|
ISearchPath& m_search_path;
|
||||||
};
|
};
|
||||||
@@ -126,8 +171,9 @@ namespace
|
|||||||
|
|
||||||
namespace image
|
namespace image
|
||||||
{
|
{
|
||||||
std::unique_ptr<AssetCreator<AssetImage>> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath)
|
#set LOADER_METHOD "CreateLoaderEmbedded" + GAME
|
||||||
|
std::unique_ptr<AssetCreator<AssetImage>> LOADER_METHOD(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
return std::make_unique<ImageLoader>(memory, searchPath);
|
return std::make_unique<LOADER_CLASS>(memory, searchPath);
|
||||||
}
|
}
|
||||||
} // namespace image
|
} // namespace image
|
||||||
23
src/ObjLoading/Image/ImageLoaderEmbedded.h.template
Normal file
23
src/ObjLoading/Image/ImageLoaderEmbedded.h.template
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#options GAME (IW3, IW4, IW5, T5, T6)
|
||||||
|
|
||||||
|
#filename "Game/" + GAME + "/Image/ImageLoaderEmbedded" + GAME + ".h"
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See ImageLoaderEmbedded.h.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IAssetCreator.h"
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
#include GAME_HEADER
|
||||||
|
#include "SearchPath/ISearchPath.h"
|
||||||
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace image
|
||||||
|
{
|
||||||
|
#set LOADER_METHOD "CreateLoaderEmbedded" + GAME
|
||||||
|
std::unique_ptr<AssetCreator<GAME::AssetImage>> LOADER_METHOD(MemoryManager& memory, ISearchPath& searchPath);
|
||||||
|
} // namespace image
|
||||||
Reference in New Issue
Block a user