diff --git a/src/Common/Game/IW3/IW3_Assets.h b/src/Common/Game/IW3/IW3_Assets.h index eb25545d..596ed16c 100644 --- a/src/Common/Game/IW3/IW3_Assets.h +++ b/src/Common/Game/IW3/IW3_Assets.h @@ -1515,7 +1515,8 @@ namespace IW3 MAPTYPE_2D = 0x3, MAPTYPE_3D = 0x4, MAPTYPE_CUBE = 0x5, - MAPTYPE_COUNT = 0x6, + + MAPTYPE_COUNT }; enum TextureSemantic diff --git a/src/Common/Game/IW4/IW4_Assets.h b/src/Common/Game/IW4/IW4_Assets.h index 398f0f77..c06c59f7 100644 --- a/src/Common/Game/IW4/IW4_Assets.h +++ b/src/Common/Game/IW4/IW4_Assets.h @@ -1181,6 +1181,18 @@ namespace IW4 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, @@ -1197,6 +1209,19 @@ namespace IW4 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 { GfxTexture texture; diff --git a/src/Common/Game/IW5/IW5_Assets.h b/src/Common/Game/IW5/IW5_Assets.h index cab9ab4f..befefc05 100644 --- a/src/Common/Game/IW5/IW5_Assets.h +++ b/src/Common/Game/IW5/IW5_Assets.h @@ -732,23 +732,6 @@ namespace IW5 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 { GfxImage* image; @@ -1157,6 +1140,48 @@ namespace IW5 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 { GfxTexture texture; diff --git a/src/Common/Game/T5/T5_Assets.h b/src/Common/Game/T5/T5_Assets.h index d06015db..d6c01e01 100644 --- a/src/Common/Game/T5/T5_Assets.h +++ b/src/Common/Game/T5/T5_Assets.h @@ -1242,6 +1242,18 @@ namespace T5 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 { TS_2D = 0x0, diff --git a/src/Common/Game/T6/T6_Assets.h b/src/Common/Game/T6/T6_Assets.h index 6368cf98..9b0a102d 100644 --- a/src/Common/Game/T6/T6_Assets.h +++ b/src/Common/Game/T6/T6_Assets.h @@ -879,6 +879,18 @@ namespace T6 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 { TS_2D = 0x0, diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h deleted file mode 100644 index b8d60124..00000000 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Asset/IAssetCreator.h" -#include "Game/IW3/IW3.h" -#include "SearchPath/ISearchPath.h" -#include "Utils/MemoryManager.h" - -#include - -namespace image -{ - std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath); -} // namespace image diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp index 913d7d3b..3d77d604 100644 --- a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -4,6 +4,7 @@ #include "Game/IW3/AssetMarkerIW3.h" #include "Game/IW3/GameIW3.h" #include "Game/IW3/IW3.h" +#include "Game/IW3/Image/ImageLoaderEmbeddedIW3.h" #include "Game/IW3/Image/ImageLoaderExternalIW3.h" #include "Game/IW3/XModel/LoaderXModelIW3.h" #include "Localize/AssetLoaderLocalizeIW3.h" @@ -95,6 +96,7 @@ namespace collection.AddAssetCreator(xmodel::CreateLoaderIW3(memory, searchPath, zone)); collection.AddAssetCreator(material::CreateLoaderIW3(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); + collection.AddAssetCreator(image::CreateLoaderEmbeddedIW3(memory, searchPath)); collection.AddAssetCreator(image::CreateLoaderExternalIW3(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index c4b6e94b..8d5899a2 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -4,6 +4,7 @@ #include "Game/IW4/AssetMarkerIW4.h" #include "Game/IW4/GameIW4.h" #include "Game/IW4/IW4.h" +#include "Game/IW4/Image/ImageLoaderEmbeddedIW4.h" #include "Game/IW4/Image/ImageLoaderExternalIW4.h" #include "Game/IW4/XModel/LoaderXModelIW4.h" #include "Leaderboard/LoaderLeaderboardIW4.h" @@ -131,6 +132,7 @@ namespace collection.AddAssetCreator(shader::CreatePixelShaderLoaderIW4(memory, searchPath)); collection.AddAssetCreator(shader::CreateVertexShaderLoaderIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); + collection.AddAssetCreator(image::CreateLoaderEmbeddedIW4(memory, searchPath)); collection.AddAssetCreator(image::CreateLoaderExternalIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(sound_curve::CreateLoaderIW4(memory, searchPath)); diff --git a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp index 55b1f684..439d1b0c 100644 --- a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp +++ b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp @@ -4,6 +4,7 @@ #include "Game/IW5/AssetMarkerIW5.h" #include "Game/IW5/GameIW5.h" #include "Game/IW5/IW5.h" +#include "Game/IW5/Image/ImageLoaderEmbeddedIW5.h" #include "Game/IW5/Image/ImageLoaderExternalIW5.h" #include "Game/IW5/XModel/LoaderXModelIW5.h" #include "Leaderboard/LoaderLeaderboardIW5.h" @@ -132,6 +133,7 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); + collection.AddAssetCreator(image::CreateLoaderEmbeddedIW5(memory, searchPath)); collection.AddAssetCreator(image::CreateLoaderExternalIW5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp index b897b567..01d22d5f 100644 --- a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp +++ b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp @@ -3,6 +3,7 @@ #include "Asset/GlobalAssetPoolsLoader.h" #include "Game/T5/AssetMarkerT5.h" #include "Game/T5/GameT5.h" +#include "Game/T5/Image/ImageLoaderEmbeddedT5.h" #include "Game/T5/Image/ImageLoaderExternalT5.h" #include "Game/T5/T5.h" #include "Game/T5/XModel/LoaderXModelT5.h" @@ -109,6 +110,7 @@ namespace collection.AddAssetCreator(xmodel::CreateLoaderT5(memory, searchPath, zone)); collection.AddAssetCreator(material::CreateLoaderT5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); + collection.AddAssetCreator(image::CreateLoaderEmbeddedT5(memory, searchPath)); collection.AddAssetCreator(image::CreateLoaderExternalT5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 716f5406..b9747017 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -7,6 +7,7 @@ #include "Game/T6/CommonT6.h" #include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/GameT6.h" +#include "Game/T6/Image/ImageLoaderEmbeddedT6.h" #include "Game/T6/Image/ImageLoaderExternalT6.h" #include "Game/T6/T6.h" #include "Game/T6/XModel/LoaderXModelT6.h" @@ -394,6 +395,7 @@ namespace T6 collection.AddAssetCreator(xmodel::CreateLoaderT6(memory, searchPath, zone)); collection.AddAssetCreator(material::CreateLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); + collection.AddAssetCreator(image::CreateLoaderEmbeddedT6(memory, searchPath)); collection.AddAssetCreator(image::CreateLoaderExternalT6(memory, searchPath)); collection.AddAssetCreator(sound::CreateSoundBankLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp b/src/ObjLoading/Image/ImageLoaderEmbedded.cpp.template similarity index 66% rename from src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp rename to src/ObjLoading/Image/ImageLoaderEmbedded.cpp.template index d8ceb88f..9541e0fc 100644 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp +++ b/src/ObjLoading/Image/ImageLoaderEmbedded.cpp.template @@ -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/ImageCommon.h" #include "Image/IwiTypes.h" -#include "Pool/GlobalAssetPool.h" #include "Utils/Logging/Log.h" -#include #include -#include -#include -using namespace IW3; +using namespace GAME; using namespace image; namespace { - class ImageLoader final : public AssetCreator +#set LOADER_CLASS "ImageLoader" + GAME + class LOADER_CLASS final : public AssetCreator { public: - ImageLoader(MemoryManager& memory, ISearchPath& searchPath) + LOADER_CLASS(MemoryManager& memory, ISearchPath& searchPath) : m_memory(memory), m_search_path(searchPath) { @@ -32,10 +71,7 @@ namespace if (assetName.empty() || assetName[0] != '*') return AssetCreationResult::NoAction(); - std::string safeAssetName = assetName; - std::ranges::replace(safeAssetName, '*', '_'); - - const auto file = m_search_path.Open(std::format("images/{}.dds", safeAssetName)); + const auto file = m_search_path.Open(image::GetFileNameForAsset(assetName, ".dds")); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -59,7 +95,9 @@ namespace image->height = static_cast(texture->GetHeight()); image->depth = static_cast(texture->GetDepth()); image->category = IMG_CATEGORY_AUTO_GENERATED; +#ifndef FEATURE_IW5 image->delayLoadPixels = false; +#endif switch (texture->GetTextureType()) { @@ -92,15 +130,23 @@ namespace loadDef->levelCount = static_cast(mipCount); loadDef->flags = 0; if (!texture->HasMipMaps()) - loadDef->flags |= image::iwi6::IMG_FLAG_NOMIPMAPS; + loadDef->flags |= IWI_NS::IMG_FLAG_NOMIPMAPS; 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) - loadDef->flags |= image::iwi6::IMG_FLAG_VOLMAP; + loadDef->flags |= IWI_NS::FLAG_3D; + +#if defined(FEATURE_IW3) loadDef->dimensions[0] = image->width; loadDef->dimensions[1] = image->height; loadDef->dimensions[2] = image->depth; +#endif + +#if defined(FEATURE_T6) + loadDef->format = static_cast(texture->GetFormat()->GetDxgiFormat()); +#else loadDef->format = static_cast(texture->GetFormat()->GetD3DFormat()); +#endif loadDef->resourceSize = static_cast(dataSize); char* currentDataBuffer = loadDef->data; @@ -118,7 +164,6 @@ namespace return AssetCreationResult::Success(context.AddAsset(assetName, image)); } - private: MemoryManager& m_memory; ISearchPath& m_search_path; }; @@ -126,8 +171,9 @@ namespace namespace image { - std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath) +#set LOADER_METHOD "CreateLoaderEmbedded" + GAME + std::unique_ptr> LOADER_METHOD(MemoryManager& memory, ISearchPath& searchPath) { - return std::make_unique(memory, searchPath); + return std::make_unique(memory, searchPath); } } // namespace image diff --git a/src/ObjLoading/Image/ImageLoaderEmbedded.h.template b/src/ObjLoading/Image/ImageLoaderEmbedded.h.template new file mode 100644 index 00000000..627d9ccd --- /dev/null +++ b/src/ObjLoading/Image/ImageLoaderEmbedded.h.template @@ -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 + +namespace image +{ +#set LOADER_METHOD "CreateLoaderEmbedded" + GAME + std::unique_ptr> LOADER_METHOD(MemoryManager& memory, ISearchPath& searchPath); +} // namespace image