mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
TXD dumping
This commit is contained in:
parent
873421e9b2
commit
519c51f7ce
@ -196,6 +196,39 @@ void dumpModelFile(char* data, size_t& dataI)
|
||||
}
|
||||
}
|
||||
|
||||
void dumpTextureDictionary(char* data, size_t& dataI)
|
||||
{
|
||||
auto header = readHeader(data, dataI);
|
||||
|
||||
std::cout << "ID = " << std::hex << (unsigned long)header.id << " (IsTextureDirectory = " << (header.id == RW::SID_TextureDictionary) << ")" << std::endl;
|
||||
std::cout << "Size = " << std::dec << (unsigned long)header.size << " bytes" << std::endl;
|
||||
std::cout << "Version ID = " << std::hex << (unsigned long)header.versionid << std::endl;
|
||||
|
||||
readHeader(data, dataI);
|
||||
|
||||
auto dir = readStructure<BSTextureDictionary>(data, dataI);
|
||||
std::cout << "Texture Count = " << dir.numtextures << std::endl;
|
||||
|
||||
for(size_t t = 0; t < dir.numtextures; ++t)
|
||||
{
|
||||
auto textureHeader = readHeader(data, dataI);
|
||||
auto basloc = dataI;
|
||||
|
||||
readHeader(data, dataI);
|
||||
|
||||
auto native = readStructure<BSTextureNative>(data, dataI);
|
||||
std::cout << "Texture Info" << std::endl;
|
||||
std::cout << " Width = " << std::dec << native.width << std::endl;
|
||||
std::cout << " Height = " << std::dec << native.height << std::endl;
|
||||
std::cout << " UV Wrap = " << std::hex << (native.wrapU+0) << "/" << (native.wrapV+0) << std::endl;
|
||||
std::cout << " Format = " << std::hex << (native.rasterformat) << std::endl;
|
||||
std::cout << " Name = " << std::string(native.diffuseName, 32) << std::endl;
|
||||
std::cout << " Alpha = " << std::string(native.alphaName, 32) << std::endl;
|
||||
|
||||
dataI = basloc + textureHeader.size;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
for(int i = 1; i < argc; ++i)
|
||||
@ -213,7 +246,23 @@ int main(int argc, char** argv)
|
||||
dfile.read(data, length);
|
||||
size_t dataI = 0;
|
||||
|
||||
std::string fname = argv[i];
|
||||
auto ext = fname.substr(fname.size()-3);
|
||||
|
||||
if(ext == "dff" || ext == "DFF")
|
||||
{
|
||||
std::cout << "Dumping model file" << std::endl;
|
||||
dumpModelFile(data, dataI);
|
||||
}
|
||||
else if(ext == "txd" || ext == "TXD")
|
||||
{
|
||||
std::cout << "Dumping texture archive" << std::endl;
|
||||
dumpTextureDictionary(data, dataI);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "I'm not sure what that is" << std::endl;
|
||||
}
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ namespace RW
|
||||
SID_Geometry = 0x000F,
|
||||
SID_Clump = 0x0010,
|
||||
|
||||
SID_TextureDictionary = 0x0016,
|
||||
|
||||
SID_GeometryList = 0x001A,
|
||||
|
||||
SID_HAnimPLG = 0x011E,
|
||||
@ -159,6 +161,68 @@ namespace RW
|
||||
uint16_t filterflags;
|
||||
uint16_t unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* Texture Dictionary Structures (TXD)
|
||||
*/
|
||||
struct BSTextureDictionary
|
||||
{
|
||||
uint16_t numtextures;
|
||||
uint16_t unknown;
|
||||
};
|
||||
|
||||
struct BSTextureNative
|
||||
{
|
||||
uint32_t platform;
|
||||
uint16_t filterflags;
|
||||
uint8_t wrapV;
|
||||
uint8_t wrapU;
|
||||
char diffuseName[32];
|
||||
char alphaName[32];
|
||||
uint32_t rasterformat;
|
||||
uint32_t alpha;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint8_t bpp;
|
||||
uint8_t nummipmaps;
|
||||
uint8_t rastertype;
|
||||
uint8_t dxttype;
|
||||
uint32_t datasize;
|
||||
|
||||
enum {
|
||||
FILTER_NONE = 0x0,
|
||||
FILTER_NEAREST = 0x01,
|
||||
FILTER_LINEAR = 0x02,
|
||||
FILTER_MIP_NEAREST = 0x03,
|
||||
FILTER_MIP_LINEAR = 0x04,
|
||||
FILTER_LINEAR_MIP_NEAREST = 0x05,
|
||||
FILTER_LINEAR_MIP_LINEAR = 0x06,
|
||||
FILTER_MYSTERY_OPTION = 0x1101
|
||||
};
|
||||
|
||||
enum {
|
||||
WRAP_NONE = 0x00,
|
||||
WRAP_WRAP = 0x01,
|
||||
WRAP_MIRROR = 0x02,
|
||||
WRAP_CLAMP = 0x03
|
||||
};
|
||||
|
||||
enum {
|
||||
FORMAT_DEFAULT = 0x0000, // helpful
|
||||
FORMAT_1555 = 0x0100, // Alpha 1, RGB 5 b
|
||||
FORMAT_565 = 0x0200, // 5r6g5b
|
||||
FORMAT_4444 = 0x0300, // 4 bits each
|
||||
FORMAT_LUM8 = 0x0400, // Greyscale
|
||||
FORMAT_8888 = 0x0500, // 8 bits each
|
||||
FORMAT_888 = 0x0600, // RGB 8 bits each
|
||||
FORMAT_555 = 0x0A00, // do not use
|
||||
|
||||
FORMAT_EXT_AUTO_MIPMAP = 0x1000, // Generate mipmaps
|
||||
FORMAT_EXT_PAL8 = 0x2000, // 256 colour palette
|
||||
FORMAT_EXT_PAL4 = 0x4000, // 16 color palette
|
||||
FORMAT_EXT_MIPMAP = 0x8000 // Mipmaps included
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user