mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Move iwi writer for version 27 in its iwi27 namespace
This commit is contained in:
parent
395c139681
commit
641ee15775
@ -16,7 +16,7 @@ AssetDumperGfxImage::AssetDumperGfxImage()
|
||||
m_writer = new DdsWriter();
|
||||
break;
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
|
||||
m_writer = new IwiWriter27();
|
||||
m_writer = new iwi27::IwiWriter();
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
@ -1,56 +1,58 @@
|
||||
#include "IwiWriter27.h"
|
||||
#include <cassert>
|
||||
|
||||
IwiWriter27::IwiWriter27()
|
||||
using namespace iwi27;
|
||||
|
||||
IwiWriter::IwiWriter()
|
||||
= default;
|
||||
|
||||
IwiWriter27::~IwiWriter27()
|
||||
IwiWriter::~IwiWriter()
|
||||
= default;
|
||||
|
||||
iwi27::IwiFormat IwiWriter27::GetIwiFormatForImageFormat(const ImageFormat* imageFormat)
|
||||
IwiFormat IwiWriter::GetIwiFormatForImageFormat(const ImageFormat* imageFormat)
|
||||
{
|
||||
switch (imageFormat->GetId())
|
||||
{
|
||||
case ImageFormatId::R8_G8_B8:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_BITMAP_RGB;
|
||||
return IwiFormat::IMG_FORMAT_BITMAP_RGB;
|
||||
|
||||
case ImageFormatId::R8_G8_B8_A8:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_BITMAP_RGBA;
|
||||
return IwiFormat::IMG_FORMAT_BITMAP_RGBA;
|
||||
|
||||
case ImageFormatId::A8:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_BITMAP_ALPHA;
|
||||
return IwiFormat::IMG_FORMAT_BITMAP_ALPHA;
|
||||
|
||||
case ImageFormatId::R16_G16_B16_A16_FLOAT:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_A16B16G16R16F;
|
||||
return IwiFormat::IMG_FORMAT_A16B16G16R16F;
|
||||
|
||||
case ImageFormatId::BC1:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_DXT1;
|
||||
return IwiFormat::IMG_FORMAT_DXT1;
|
||||
|
||||
case ImageFormatId::BC2:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_DXT3;
|
||||
return IwiFormat::IMG_FORMAT_DXT3;
|
||||
|
||||
case ImageFormatId::BC3:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_DXT5;
|
||||
return IwiFormat::IMG_FORMAT_DXT5;
|
||||
|
||||
case ImageFormatId::BC5:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_DXN;
|
||||
return IwiFormat::IMG_FORMAT_DXN;
|
||||
|
||||
default:
|
||||
return iwi27::IwiFormat::IMG_FORMAT_INVALID;
|
||||
return IwiFormat::IMG_FORMAT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
bool IwiWriter27::SupportsImageFormat(const ImageFormat* imageFormat)
|
||||
bool IwiWriter::SupportsImageFormat(const ImageFormat* imageFormat)
|
||||
{
|
||||
return GetIwiFormatForImageFormat(imageFormat) != iwi27::IwiFormat::IMG_FORMAT_INVALID;
|
||||
return GetIwiFormatForImageFormat(imageFormat) != IwiFormat::IMG_FORMAT_INVALID;
|
||||
}
|
||||
|
||||
std::string IwiWriter27::GetFileExtension()
|
||||
std::string IwiWriter::GetFileExtension()
|
||||
{
|
||||
return ".iwi";
|
||||
}
|
||||
|
||||
void IwiWriter27::WriteVersion(FileAPI::IFile* file)
|
||||
void IwiWriter::WriteVersion(FileAPI::IFile* file)
|
||||
{
|
||||
IwiVersion version{};
|
||||
version.tag[0] = 'I';
|
||||
@ -61,49 +63,49 @@ void IwiWriter27::WriteVersion(FileAPI::IFile* file)
|
||||
file->Write(&version, sizeof IwiVersion, 1);
|
||||
}
|
||||
|
||||
void IwiWriter27::FillHeader2D(iwi27::IwiHeader* header, Texture2D* texture)
|
||||
void IwiWriter::FillHeader2D(IwiHeader* header, Texture2D* texture)
|
||||
{
|
||||
header->dimensions[0] = texture->GetWidth();
|
||||
header->dimensions[1] = texture->GetHeight();
|
||||
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
|
||||
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
|
||||
header->dimensions[2] = 1;
|
||||
}
|
||||
|
||||
void IwiWriter27::FillHeaderCube(iwi27::IwiHeader* header, TextureCube* texture)
|
||||
void IwiWriter::FillHeaderCube(IwiHeader* header, TextureCube* texture)
|
||||
{
|
||||
header->dimensions[0] = texture->GetWidth();
|
||||
header->dimensions[1] = texture->GetHeight();
|
||||
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
|
||||
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
|
||||
header->dimensions[2] = 1;
|
||||
header->flags |= iwi27::IwiFlags::IMG_FLAG_CUBEMAP;
|
||||
header->flags |= IMG_FLAG_CUBEMAP;
|
||||
}
|
||||
|
||||
void IwiWriter27::FillHeader3D(iwi27::IwiHeader* header, Texture3D* texture)
|
||||
void IwiWriter::FillHeader3D(IwiHeader* header, Texture3D* texture)
|
||||
{
|
||||
header->dimensions[0] = texture->GetWidth();
|
||||
header->dimensions[1] = texture->GetHeight();
|
||||
header->dimensions[2] = texture->GetDepth();
|
||||
header->flags |= iwi27::IwiFlags::IMG_FLAG_VOLMAP;
|
||||
header->dimensions[0] = static_cast<uint16_t>(texture->GetWidth());
|
||||
header->dimensions[1] = static_cast<uint16_t>(texture->GetHeight());
|
||||
header->dimensions[2] = static_cast<uint16_t>(texture->GetDepth());
|
||||
header->flags |= IMG_FLAG_VOLMAP;
|
||||
}
|
||||
|
||||
void IwiWriter27::DumpImage(FileAPI::IFile* file, Texture* texture)
|
||||
void IwiWriter::DumpImage(FileAPI::IFile* file, Texture* texture)
|
||||
{
|
||||
assert(file != nullptr);
|
||||
assert(texture != nullptr);
|
||||
|
||||
WriteVersion(file);
|
||||
|
||||
iwi27::IwiHeader header{};
|
||||
IwiHeader header{};
|
||||
header.flags = 0;
|
||||
header.gamma = 0.0f;
|
||||
|
||||
header.format = static_cast<int8_t>(GetIwiFormatForImageFormat(texture->GetFormat()));
|
||||
|
||||
if (!texture->HasMipMaps())
|
||||
header.flags |= iwi27::IwiFlags::IMG_FLAG_NOMIPMAPS;
|
||||
header.flags |= IMG_FLAG_NOMIPMAPS;
|
||||
|
||||
for (signed char& i : header.maxGlossForMip)
|
||||
i = 0;
|
||||
|
||||
size_t currentFileSize = sizeof IwiVersion + sizeof iwi27::IwiHeader;
|
||||
size_t currentFileSize = sizeof IwiVersion + sizeof IwiHeader;
|
||||
|
||||
const int textureMipCount = texture->HasMipMaps() ? texture->GetMipMapCount() : 1;
|
||||
for (int currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--)
|
||||
@ -128,7 +130,7 @@ void IwiWriter27::DumpImage(FileAPI::IFile* file, Texture* texture)
|
||||
FillHeader3D(&header, texture3D);
|
||||
}
|
||||
|
||||
file->Write(&header, sizeof iwi27::IwiHeader, 1);
|
||||
file->Write(&header, sizeof IwiHeader, 1);
|
||||
|
||||
for (int currentMipLevel = textureMipCount - 1; currentMipLevel >= 0; currentMipLevel--)
|
||||
{
|
||||
|
@ -3,25 +3,28 @@
|
||||
#include "IImageWriter.h"
|
||||
#include "Image/IwiTypes.h"
|
||||
|
||||
class IwiWriter27 final : public IImageWriter
|
||||
namespace iwi27
|
||||
{
|
||||
static iwi27::IwiFormat GetIwiFormatForImageFormat(const ImageFormat* imageFormat);
|
||||
class IwiWriter final : public IImageWriter
|
||||
{
|
||||
static IwiFormat GetIwiFormatForImageFormat(const ImageFormat* imageFormat);
|
||||
|
||||
static void WriteVersion(FileAPI::IFile* file);
|
||||
static void FillHeader2D(iwi27::IwiHeader* header, Texture2D* texture);
|
||||
static void FillHeaderCube(iwi27::IwiHeader* header, TextureCube* texture);
|
||||
static void FillHeader3D(iwi27::IwiHeader* header, Texture3D* texture);
|
||||
static void WriteVersion(FileAPI::IFile* file);
|
||||
static void FillHeader2D(IwiHeader* header, Texture2D* texture);
|
||||
static void FillHeaderCube(IwiHeader* header, TextureCube* texture);
|
||||
static void FillHeader3D(IwiHeader* header, Texture3D* texture);
|
||||
|
||||
public:
|
||||
IwiWriter27();
|
||||
IwiWriter27(const IwiWriter27& other) = delete;
|
||||
IwiWriter27(IwiWriter27&& other) noexcept = delete;
|
||||
~IwiWriter27() override;
|
||||
public:
|
||||
IwiWriter();
|
||||
IwiWriter(const IwiWriter& other) = delete;
|
||||
IwiWriter(IwiWriter&& other) noexcept = delete;
|
||||
~IwiWriter() override;
|
||||
|
||||
IwiWriter27& operator=(const IwiWriter27& other) = delete;
|
||||
IwiWriter27& operator=(IwiWriter27&& other) noexcept = delete;
|
||||
IwiWriter& operator=(const IwiWriter& other) = delete;
|
||||
IwiWriter& operator=(IwiWriter&& other) noexcept = delete;
|
||||
|
||||
bool SupportsImageFormat(const ImageFormat* imageFormat) override;
|
||||
std::string GetFileExtension() override;
|
||||
void DumpImage(FileAPI::IFile* file, Texture* texture) override;
|
||||
};
|
||||
bool SupportsImageFormat(const ImageFormat* imageFormat) override;
|
||||
std::string GetFileExtension() override;
|
||||
void DumpImage(FileAPI::IFile* file, Texture* texture) override;
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user