mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-27 15:16:13 +00:00
git subrepo pull --force tools/ZAPD (#653)
subrepo: subdir: "tools/ZAPD" merged: "2e1174063" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "2e1174063" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596"
This commit is contained in:
parent
d739765031
commit
588de66d06
32 changed files with 405 additions and 65 deletions
|
@ -6,7 +6,7 @@
|
||||||
[subrepo]
|
[subrepo]
|
||||||
remote = https://github.com/zeldaret/ZAPD.git
|
remote = https://github.com/zeldaret/ZAPD.git
|
||||||
branch = master
|
branch = master
|
||||||
commit = 0305ec2c27412557fe831cc8ce23b7d8649809fa
|
commit = 2e1174063f3ed6bcf929bc7093cd2d1b05f8518b
|
||||||
parent = db66460dbb2522a1a9822582f8b7d5205415af93
|
parent = d73976503126d10a82016f8f72fac4092dff1932
|
||||||
method = merge
|
method = merge
|
||||||
cmdver = 0.4.3
|
cmdver = 0.4.3
|
||||||
|
|
|
@ -50,7 +50,7 @@ string Globals::FindSymbolSegRef(int segNumber, uint32_t symbolAddress)
|
||||||
{
|
{
|
||||||
if (string(child->Name()) == "File")
|
if (string(child->Name()) == "File")
|
||||||
{
|
{
|
||||||
ZFile* file = new ZFile(fileMode, child, "", "", true);
|
ZFile* file = new ZFile(fileMode, child, "", "", "", true);
|
||||||
file->GeneratePlaceholderDeclarations();
|
file->GeneratePlaceholderDeclarations();
|
||||||
segmentRefFiles[segNumber] = file;
|
segmentRefFiles[segNumber] = file;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -180,9 +180,7 @@ int NewMain(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Globals::Instance->verbosity >= VERBOSITY_INFO)
|
if (Globals::Instance->verbosity >= VERBOSITY_INFO)
|
||||||
{
|
|
||||||
printf("ZAPD: Zelda Asset Processor For Decomp\n");
|
printf("ZAPD: Zelda Asset Processor For Decomp\n");
|
||||||
}
|
|
||||||
|
|
||||||
if (fileMode == ZFileMode::Build || fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
|
if (fileMode == ZFileMode::Build || fileMode == ZFileMode::Extract || fileMode == ZFileMode::BuildSourceFile)
|
||||||
{
|
{
|
||||||
|
@ -239,7 +237,7 @@ bool Parse(const std::string& xmlFilePath, const std::string& basePath, const st
|
||||||
{
|
{
|
||||||
if (string(child->Name()) == "File")
|
if (string(child->Name()) == "File")
|
||||||
{
|
{
|
||||||
ZFile* file = new ZFile(fileMode, child, basePath, outPath, false);
|
ZFile* file = new ZFile(fileMode, child, basePath, outPath, "", false);
|
||||||
Globals::Instance->files.push_back(file);
|
Globals::Instance->files.push_back(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,11 @@ string ZOverlay::GetSourceOutputCode(const std::string& prefix)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZResourceType ZOverlay::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::Overlay;
|
||||||
|
}
|
||||||
|
|
||||||
SectionType ZOverlay::GetSectionTypeFromStr(string sectionName)
|
SectionType ZOverlay::GetSectionTypeFromStr(string sectionName)
|
||||||
{
|
{
|
||||||
if (sectionName == ".rel.text" || sectionName == ".text")
|
if (sectionName == ".rel.text" || sectionName == ".text")
|
||||||
|
|
|
@ -55,7 +55,8 @@ public:
|
||||||
ZOverlay(std::string nName);
|
ZOverlay(std::string nName);
|
||||||
~ZOverlay();
|
~ZOverlay();
|
||||||
static ZOverlay* FromBuild(std::string buildPath, std::string cfgFolderPath);
|
static ZOverlay* FromBuild(std::string buildPath, std::string cfgFolderPath);
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<RelocationEntry*> entries;
|
std::vector<RelocationEntry*> entries;
|
||||||
|
|
|
@ -142,6 +142,7 @@
|
||||||
<ClCompile Include="HighLevel\HLTexture.cpp" />
|
<ClCompile Include="HighLevel\HLTexture.cpp" />
|
||||||
<ClCompile Include="Main.cpp" />
|
<ClCompile Include="Main.cpp" />
|
||||||
<ClCompile Include="Overlays\ZOverlay.cpp" />
|
<ClCompile Include="Overlays\ZOverlay.cpp" />
|
||||||
|
<ClCompile Include="ZArray.cpp" />
|
||||||
<ClCompile Include="ZScalar.cpp" />
|
<ClCompile Include="ZScalar.cpp" />
|
||||||
<ClCompile Include="ZAnimation.cpp" />
|
<ClCompile Include="ZAnimation.cpp" />
|
||||||
<ClCompile Include="ZBlob.cpp" />
|
<ClCompile Include="ZBlob.cpp" />
|
||||||
|
@ -181,6 +182,7 @@
|
||||||
<ClCompile Include="ZRoom\ZRoomCommand.cpp" />
|
<ClCompile Include="ZRoom\ZRoomCommand.cpp" />
|
||||||
<ClCompile Include="ZTexture.cpp" />
|
<ClCompile Include="ZTexture.cpp" />
|
||||||
<ClCompile Include="ZVector.cpp" />
|
<ClCompile Include="ZVector.cpp" />
|
||||||
|
<ClCompile Include="ZVtx.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\lib\elfio\elfio\elfio.hpp" />
|
<ClInclude Include="..\lib\elfio\elfio\elfio.hpp" />
|
||||||
|
@ -214,6 +216,7 @@
|
||||||
<ClInclude Include="StringHelper.h" />
|
<ClInclude Include="StringHelper.h" />
|
||||||
<ClInclude Include="Vec3s.h" />
|
<ClInclude Include="Vec3s.h" />
|
||||||
<ClInclude Include="ZAnimation.h" />
|
<ClInclude Include="ZAnimation.h" />
|
||||||
|
<ClInclude Include="ZArray.h" />
|
||||||
<ClInclude Include="ZBlob.h" />
|
<ClInclude Include="ZBlob.h" />
|
||||||
<ClInclude Include="ZCollision.h" />
|
<ClInclude Include="ZCollision.h" />
|
||||||
<ClInclude Include="ZCutscene.h" />
|
<ClInclude Include="ZCutscene.h" />
|
||||||
|
@ -254,6 +257,7 @@
|
||||||
<ClInclude Include="ZRoom\ZRoomCommand.h" />
|
<ClInclude Include="ZRoom\ZRoomCommand.h" />
|
||||||
<ClInclude Include="ZTexture.h" />
|
<ClInclude Include="ZTexture.h" />
|
||||||
<ClInclude Include="ZVector.h" />
|
<ClInclude Include="ZVector.h" />
|
||||||
|
<ClInclude Include="ZVtx.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
||||||
|
|
|
@ -195,6 +195,12 @@
|
||||||
<ClCompile Include="ZVector.cpp">
|
<ClCompile Include="ZVector.cpp">
|
||||||
<Filter>Source Files\Z64</Filter>
|
<Filter>Source Files\Z64</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="ZArray.cpp">
|
||||||
|
<Filter>Source Files\Z64</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ZVtx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Path.h">
|
<ClInclude Include="Path.h">
|
||||||
|
@ -410,6 +416,12 @@
|
||||||
<ClInclude Include="..\lib\stb\tinyxml2.h">
|
<ClInclude Include="..\lib\stb\tinyxml2.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="ZArray.h">
|
||||||
|
<Filter>Header Files\Z64</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ZVtx.h">
|
||||||
|
<Filter>Header Files\Z64</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
<Text Include="..\SymbolMap_OoTMqDbg.txt">
|
||||||
|
|
|
@ -46,6 +46,11 @@ string ZAnimation::GetSourceOutputCode(const std::string& prefix)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZResourceType ZAnimation::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::Animation;
|
||||||
|
}
|
||||||
|
|
||||||
ZNormalAnimation::ZNormalAnimation() : ZAnimation()
|
ZNormalAnimation::ZNormalAnimation() : ZAnimation()
|
||||||
{
|
{
|
||||||
rotationValues = vector<uint16_t>();
|
rotationValues = vector<uint16_t>();
|
||||||
|
|
|
@ -23,7 +23,8 @@ public:
|
||||||
|
|
||||||
ZAnimation();
|
ZAnimation();
|
||||||
|
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void ParseRawData();
|
virtual void ParseRawData();
|
||||||
|
@ -43,7 +44,7 @@ public:
|
||||||
ZNormalAnimation();
|
ZNormalAnimation();
|
||||||
|
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix);
|
||||||
virtual int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
|
|
||||||
static ZNormalAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, const std::string& nRelPath);
|
static ZNormalAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, const std::string& nRelPath);
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ public:
|
||||||
ZLinkAnimation();
|
ZLinkAnimation();
|
||||||
|
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix);
|
||||||
virtual int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
|
|
||||||
static ZLinkAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, const std::string& nRelPath);
|
static ZLinkAnimation* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, const std::string& nRelPath);
|
||||||
|
|
||||||
|
|
73
tools/ZAPD/ZAPD/ZArray.cpp
Normal file
73
tools/ZAPD/ZAPD/ZArray.cpp
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#include "ZArray.h"
|
||||||
|
#include "ZFile.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "StringHelper.h"
|
||||||
|
|
||||||
|
ZArray::ZArray()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZArray::ParseXML(tinyxml2::XMLElement* reader)
|
||||||
|
{
|
||||||
|
ZResource::ParseXML(reader);
|
||||||
|
|
||||||
|
arrayCnt = reader->IntAttribute("Count", 0);
|
||||||
|
testFile = new ZFile(ZFileMode::Extract, reader, Globals::Instance->baseRomPath, "", parent->GetName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This is a bit hacky, but until we refactor how ZFile parses the XML, it'll have to do.
|
||||||
|
std::string ZArray::GetSourceOutputCode(const std::string& prefix)
|
||||||
|
{
|
||||||
|
std::string output = "";
|
||||||
|
|
||||||
|
if (testFile->resources.size() <= 0)
|
||||||
|
{
|
||||||
|
throw StringHelper::Sprintf("Error! Array needs at least one sub-element.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
ZResource* res = testFile->resources[0];
|
||||||
|
int resSize = res->GetRawDataSize();
|
||||||
|
|
||||||
|
if (!res->DoesSupportArray())
|
||||||
|
{
|
||||||
|
throw StringHelper::Sprintf("Error! Resource %s does not support being wrapped in an array!\n", res->GetName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < arrayCnt; i++)
|
||||||
|
{
|
||||||
|
int childIndex = rawDataIndex + (i * resSize);
|
||||||
|
res->SetRawDataIndex(childIndex);
|
||||||
|
res->ParseRawData();
|
||||||
|
std::string test = res->GetSourceOutputCode("");
|
||||||
|
//output += " { " + testFile->declarations[childIndex]->text + " }";
|
||||||
|
output += testFile->declarations[childIndex]->text;
|
||||||
|
|
||||||
|
if (i < arrayCnt - 1)
|
||||||
|
output += ",\n";
|
||||||
|
|
||||||
|
int bp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent != nullptr)
|
||||||
|
parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), res->GetSourceTypeName(), name, arrayCnt, output);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZArray::GetRawDataSize()
|
||||||
|
{
|
||||||
|
return arrayCnt * testFile->resources[0]->GetRawDataSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZArray* ZArray::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath, ZFile* nParent)
|
||||||
|
{
|
||||||
|
ZArray* arr = new ZArray();
|
||||||
|
arr->rawData = nRawData;
|
||||||
|
arr->rawDataIndex = rawDataIndex;
|
||||||
|
arr->parent = nParent;
|
||||||
|
arr->ParseXML(reader);
|
||||||
|
//arr->ParseRawData();
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
25
tools/ZAPD/ZAPD/ZArray.h
Normal file
25
tools/ZAPD/ZAPD/ZArray.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "ZResource.h"
|
||||||
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
class ZArray : public ZResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ZArray();
|
||||||
|
|
||||||
|
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||||
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
|
int GetRawDataSize() override;
|
||||||
|
|
||||||
|
static ZArray* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath, ZFile* nParent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int arrayCnt;
|
||||||
|
ZFile* testFile;
|
||||||
|
|
||||||
|
//void ParseRawData(const std::vector<uint8_t>& data, const int offset);
|
||||||
|
};
|
|
@ -98,6 +98,11 @@ string ZBlob::GetExternalExtension()
|
||||||
return "bin";
|
return "bin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ZBlob::GetSourceTypeName()
|
||||||
|
{
|
||||||
|
return "u8";
|
||||||
|
}
|
||||||
|
|
||||||
ZResourceType ZBlob::GetResourceType()
|
ZResourceType ZBlob::GetResourceType()
|
||||||
{
|
{
|
||||||
return ZResourceType::Blob;
|
return ZResourceType::Blob;
|
||||||
|
|
|
@ -11,12 +11,13 @@ public:
|
||||||
static ZBlob* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, int rawDataIndex, std::string nRelPath);
|
static ZBlob* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, int rawDataIndex, std::string nRelPath);
|
||||||
static ZBlob* BuildFromXML(tinyxml2::XMLElement* reader, const std::string& inFolder, bool readFile);
|
static ZBlob* BuildFromXML(tinyxml2::XMLElement* reader, const std::string& inFolder, bool readFile);
|
||||||
static ZBlob* FromFile(const std::string& filePath);
|
static ZBlob* FromFile(const std::string& filePath);
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
std::string GetSourceOutputHeader(const std::string& prefix);
|
std::string GetSourceOutputHeader(const std::string& prefix) override;
|
||||||
void Save(const std::string& outFolder);
|
void Save(const std::string& outFolder) override;
|
||||||
bool IsExternalResource();
|
bool IsExternalResource() override;
|
||||||
std::string GetExternalExtension();
|
std::string GetExternalExtension() override;
|
||||||
ZResourceType GetResourceType();
|
std::string GetSourceTypeName() override;
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ZBlob();
|
ZBlob();
|
||||||
|
|
|
@ -167,6 +167,11 @@ ZCollisionHeader::~ZCollisionHeader()
|
||||||
delete waterBox;
|
delete waterBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZResourceType ZCollisionHeader::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::CollisionHeader;
|
||||||
|
}
|
||||||
|
|
||||||
ZCollisionHeader* ZCollisionHeader::ExtractFromXML(tinyxml2::XMLElement* reader, vector<uint8_t> nRawData, int rawDataIndex)
|
ZCollisionHeader* ZCollisionHeader::ExtractFromXML(tinyxml2::XMLElement* reader, vector<uint8_t> nRawData, int rawDataIndex)
|
||||||
{
|
{
|
||||||
ZCollisionHeader* col = new ZCollisionHeader();
|
ZCollisionHeader* col = new ZCollisionHeader();
|
||||||
|
|
|
@ -87,5 +87,7 @@ public:
|
||||||
ZCollisionHeader(ZFile* parent, const std::string& prefix, const std::vector<uint8_t>& rawData, int rawDataIndex);
|
ZCollisionHeader(ZFile* parent, const std::string& prefix, const std::vector<uint8_t>& rawData, int rawDataIndex);
|
||||||
~ZCollisionHeader();
|
~ZCollisionHeader();
|
||||||
|
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
|
|
||||||
static ZCollisionHeader* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex);
|
static ZCollisionHeader* ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex);
|
||||||
};
|
};
|
||||||
|
|
|
@ -181,6 +181,11 @@ CutsceneCommands ZCutscene::GetCommandFromID(int id)
|
||||||
return CutsceneCommands::Error;
|
return CutsceneCommands::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZResourceType ZCutscene::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::Cutscene;
|
||||||
|
}
|
||||||
|
|
||||||
CutsceneCommand::CutsceneCommand(const vector<uint8_t>& rawData, int rawDataIndex)
|
CutsceneCommand::CutsceneCommand(const vector<uint8_t>& rawData, int rawDataIndex)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -402,12 +402,14 @@ class ZCutscene : public ZResource
|
||||||
public:
|
public:
|
||||||
uint32_t segmentOffset;
|
uint32_t segmentOffset;
|
||||||
|
|
||||||
CutsceneCommands GetCommandFromID(int id);
|
|
||||||
ZCutscene(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize);
|
ZCutscene(std::vector<uint8_t> nRawData, int rawDataIndex, int rawDataSize);
|
||||||
~ZCutscene();
|
~ZCutscene();
|
||||||
|
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
|
CutsceneCommands GetCommandFromID(int id);
|
||||||
|
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
|
|
||||||
static ZCutscene* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
static ZCutscene* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1367,6 +1367,11 @@ void ZDisplayList::GenerateHLIntermediette(HLFileIntermediette& hlFile)
|
||||||
mdl->blocks.push_back(new HLTerminator());
|
mdl->blocks.push_back(new HLTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZResourceType ZDisplayList::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::DisplayList;
|
||||||
|
}
|
||||||
|
|
||||||
vector<uint8_t> ZDisplayList::GetRawData()
|
vector<uint8_t> ZDisplayList::GetRawData()
|
||||||
{
|
{
|
||||||
return rawData;
|
return rawData;
|
||||||
|
|
|
@ -214,14 +214,12 @@ public:
|
||||||
class ZDisplayList : public ZResource
|
class ZDisplayList : public ZResource
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// Test
|
|
||||||
uint32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg;
|
uint32_t lastTexWidth, lastTexHeight, lastTexAddr, lastTexSeg;
|
||||||
F3DZEXTexFormats lastTexFmt;
|
F3DZEXTexFormats lastTexFmt;
|
||||||
F3DZEXTexSizes lastTexSiz, lastTexSizTest, lastCISiz;
|
F3DZEXTexSizes lastTexSiz, lastTexSizTest, lastCISiz;
|
||||||
bool lastTexLoaded;
|
bool lastTexLoaded;
|
||||||
bool lastTexIsPalette;
|
bool lastTexIsPalette;
|
||||||
|
|
||||||
//void ParseXML(tinyxml2::XMLElement* reader);
|
|
||||||
static TextureType TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz);
|
static TextureType TexFormatToTexType(F3DZEXTexFormats fmt, F3DZEXTexSizes siz);
|
||||||
void ParseRawData();
|
void ParseRawData();
|
||||||
|
|
||||||
|
@ -260,9 +258,11 @@ public:
|
||||||
static int GetDListLength(std::vector<uint8_t> rawData, int rawDataIndex);
|
static int GetDListLength(std::vector<uint8_t> rawData, int rawDataIndex);
|
||||||
|
|
||||||
std::vector<uint8_t> GetRawData();
|
std::vector<uint8_t> GetRawData();
|
||||||
int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
std::string GetSourceOutputHeader(const std::string& prefix);
|
std::string GetSourceOutputHeader(const std::string& prefix) override;
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
void Save(const std::string& outFolder);
|
void Save(const std::string& outFolder) override;
|
||||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile) override;
|
||||||
|
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
#include "ZCollision.h"
|
#include "ZCollision.h"
|
||||||
#include "ZScalar.h"
|
#include "ZScalar.h"
|
||||||
#include "ZVector.h"
|
#include "ZVector.h"
|
||||||
|
#include "ZVtx.h"
|
||||||
#include "ZCutscene.h"
|
#include "ZCutscene.h"
|
||||||
|
#include "ZArray.h"
|
||||||
#include "Path.h"
|
#include "Path.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Directory.h"
|
#include "Directory.h"
|
||||||
|
@ -38,7 +40,7 @@ ZFile::ZFile(string nOutPath, string nName) : ZFile()
|
||||||
name = nName;
|
name = nName;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZFile::ZFile(ZFileMode mode, XMLElement* reader, string nBasePath, string nOutPath, bool placeholderMode) : ZFile()
|
ZFile::ZFile(ZFileMode mode, XMLElement* reader, string nBasePath, string nOutPath, std::string filename, bool placeholderMode) : ZFile()
|
||||||
{
|
{
|
||||||
if (nBasePath == "")
|
if (nBasePath == "")
|
||||||
basePath = Directory::GetCurrentDirectory();
|
basePath = Directory::GetCurrentDirectory();
|
||||||
|
@ -50,7 +52,7 @@ ZFile::ZFile(ZFileMode mode, XMLElement* reader, string nBasePath, string nOutPa
|
||||||
else
|
else
|
||||||
outputPath = nOutPath;
|
outputPath = nOutPath;
|
||||||
|
|
||||||
ParseXML(mode, reader, placeholderMode);
|
ParseXML(mode, reader, filename, placeholderMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZFile::~ZFile()
|
ZFile::~ZFile()
|
||||||
|
@ -59,9 +61,13 @@ ZFile::~ZFile()
|
||||||
delete res;
|
delete res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, bool placeholderMode)
|
void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, std::string filename, bool placeholderMode)
|
||||||
{
|
{
|
||||||
|
if (filename == "")
|
||||||
name = reader->Attribute("Name");
|
name = reader->Attribute("Name");
|
||||||
|
else
|
||||||
|
name = filename;
|
||||||
|
|
||||||
int segment = -1;
|
int segment = -1;
|
||||||
|
|
||||||
if (reader->Attribute("BaseAddress") != NULL)
|
if (reader->Attribute("BaseAddress") != NULL)
|
||||||
|
@ -289,6 +295,26 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, bool placeholderMode)
|
||||||
printf("No ZVector created!!");
|
printf("No ZVector created!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (string(child->Name()) == "Vtx")
|
||||||
|
{
|
||||||
|
ZVtx* vtx = nullptr;
|
||||||
|
|
||||||
|
if (mode == ZFileMode::Extract)
|
||||||
|
vtx = ZVtx::ExtractFromXML(child, rawData, rawDataIndex, folderName);
|
||||||
|
|
||||||
|
if (vtx != nullptr)
|
||||||
|
{
|
||||||
|
vtx->parent = this;
|
||||||
|
resources.push_back(vtx);
|
||||||
|
|
||||||
|
rawDataIndex += vtx->GetRawDataSize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
|
||||||
|
printf("No ZVtx created!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (string(child->Name()) == "Cutscene")
|
else if (string(child->Name()) == "Cutscene")
|
||||||
{
|
{
|
||||||
ZCutscene* cs = nullptr;
|
ZCutscene* cs = nullptr;
|
||||||
|
@ -303,10 +329,24 @@ void ZFile::ParseXML(ZFileMode mode, XMLElement* reader, bool placeholderMode)
|
||||||
rawDataIndex += cs->GetRawDataSize();
|
rawDataIndex += cs->GetRawDataSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (string(child->Name()) == "Array")
|
||||||
|
{
|
||||||
|
ZArray* array = nullptr;
|
||||||
|
|
||||||
|
if (mode == ZFileMode::Extract)
|
||||||
|
array = ZArray::ExtractFromXML(child, rawData, rawDataIndex, folderName, this);
|
||||||
|
|
||||||
|
if (array != nullptr)
|
||||||
|
{
|
||||||
|
resources.push_back(array);
|
||||||
|
rawDataIndex += array->GetRawDataSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
|
std::cerr << "ERROR bad type\n";
|
||||||
printf("Encountered unknown resource type: %s\n", string(child->Name()).c_str());
|
printf("Encountered unknown resource type: %s on line: %d\n", child->Name(), child->GetLineNum());
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,6 +399,11 @@ std::string ZFile::GetVarName(int address)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ZFile::GetName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
void ZFile::ExtractResources(string outputDir)
|
void ZFile::ExtractResources(string outputDir)
|
||||||
{
|
{
|
||||||
string folderName = Path::GetFileNameWithoutExtension(outputPath);
|
string folderName = Path::GetFileNameWithoutExtension(outputPath);
|
||||||
|
|
|
@ -27,10 +27,11 @@ public:
|
||||||
uint32_t baseAddress, rangeStart, rangeEnd;
|
uint32_t baseAddress, rangeStart, rangeEnd;
|
||||||
|
|
||||||
ZFile(std::string nOutPath, std::string nName);
|
ZFile(std::string nOutPath, std::string nName);
|
||||||
ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, std::string nBasePath, std::string nOutPath, bool placeholderMode);
|
ZFile(ZFileMode mode, tinyxml2::XMLElement* reader, std::string nBasePath, std::string nOutPath, std::string filename, bool placeholderMode);
|
||||||
~ZFile();
|
~ZFile();
|
||||||
|
|
||||||
std::string GetVarName(int address);
|
std::string GetVarName(int address);
|
||||||
|
std::string GetName();
|
||||||
void ExtractResources(std::string outputDir);
|
void ExtractResources(std::string outputDir);
|
||||||
void BuildResources();
|
void BuildResources();
|
||||||
void BuildSourceFile(std::string outputDir);
|
void BuildSourceFile(std::string outputDir);
|
||||||
|
@ -61,7 +62,7 @@ protected:
|
||||||
std::string sourceOutput;
|
std::string sourceOutput;
|
||||||
|
|
||||||
ZFile();
|
ZFile();
|
||||||
void ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, bool placeholderMode);
|
void ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, std::string filename, bool placeholderMode);
|
||||||
void GenerateSourceFiles(std::string outputDir);
|
void GenerateSourceFiles(std::string outputDir);
|
||||||
void GenerateHLIntermediette();
|
void GenerateHLIntermediette();
|
||||||
void AddDeclarationDebugChecks(uint32_t address);
|
void AddDeclarationDebugChecks(uint32_t address);
|
||||||
|
|
|
@ -12,7 +12,6 @@ ZResource::ZResource()
|
||||||
rawData = vector<uint8_t>();
|
rawData = vector<uint8_t>();
|
||||||
rawDataIndex = 0;
|
rawDataIndex = 0;
|
||||||
outputDeclaration = true;
|
outputDeclaration = true;
|
||||||
arrayCnt = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZResource::ParseXML(tinyxml2::XMLElement* reader)
|
void ZResource::ParseXML(tinyxml2::XMLElement* reader)
|
||||||
|
@ -54,6 +53,11 @@ bool ZResource::IsExternalResource()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZResource::DoesSupportArray()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string ZResource::GetExternalExtension()
|
std::string ZResource::GetExternalExtension()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
|
@ -94,11 +98,20 @@ string ZResource::GetSourceOutputHeader(const std::string& prefix)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZResource::ParseRawData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ZResource::GenerateHLIntermediette(HLFileIntermediette& hlFile)
|
void ZResource::GenerateHLIntermediette(HLFileIntermediette& hlFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ZResource::GetSourceTypeName()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
ZResourceType ZResource::GetResourceType()
|
ZResourceType ZResource::GetResourceType()
|
||||||
{
|
{
|
||||||
return ZResourceType::Error;
|
return ZResourceType::Error;
|
||||||
|
|
|
@ -37,7 +37,9 @@ enum class ZResourceType
|
||||||
Limb,
|
Limb,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
Scalar,
|
Scalar,
|
||||||
Vector
|
Vector,
|
||||||
|
Vertex,
|
||||||
|
CollisionHeader
|
||||||
};
|
};
|
||||||
|
|
||||||
class ZResource
|
class ZResource
|
||||||
|
@ -45,7 +47,6 @@ class ZResource
|
||||||
public:
|
public:
|
||||||
ZFile* parent;
|
ZFile* parent;
|
||||||
bool outputDeclaration;
|
bool outputDeclaration;
|
||||||
int arrayCnt;
|
|
||||||
|
|
||||||
ZResource();
|
ZResource();
|
||||||
virtual void ParseXML(tinyxml2::XMLElement* reader);
|
virtual void ParseXML(tinyxml2::XMLElement* reader);
|
||||||
|
@ -57,13 +58,16 @@ public:
|
||||||
std::string GetRelativePath();
|
std::string GetRelativePath();
|
||||||
virtual std::vector<uint8_t> GetRawData();
|
virtual std::vector<uint8_t> GetRawData();
|
||||||
virtual bool IsExternalResource();
|
virtual bool IsExternalResource();
|
||||||
|
virtual bool DoesSupportArray(); // Can this type be wrapped in an <Array> node?
|
||||||
virtual std::string GetExternalExtension();
|
virtual std::string GetExternalExtension();
|
||||||
virtual int GetRawDataIndex();
|
virtual int GetRawDataIndex();
|
||||||
virtual int GetRawDataSize();
|
virtual int GetRawDataSize();
|
||||||
virtual void SetRawDataIndex(int value);
|
virtual void SetRawDataIndex(int value);
|
||||||
virtual std::string GetSourceOutputCode(const std::string& prefix);
|
virtual std::string GetSourceOutputCode(const std::string& prefix);
|
||||||
virtual std::string GetSourceOutputHeader(const std::string& prefix);
|
virtual std::string GetSourceOutputHeader(const std::string& prefix);
|
||||||
|
virtual void ParseRawData();
|
||||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
||||||
|
virtual std::string GetSourceTypeName();
|
||||||
virtual ZResourceType GetResourceType();
|
virtual ZResourceType GetResourceType();
|
||||||
virtual void CalcHash();
|
virtual void CalcHash();
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,12 @@ void ZScalar::ParseXML(tinyxml2::XMLElement* reader)
|
||||||
{
|
{
|
||||||
ZResource::ParseXML(reader);
|
ZResource::ParseXML(reader);
|
||||||
|
|
||||||
name = reader->Attribute("Name");
|
|
||||||
|
|
||||||
std::string type = reader->Attribute("Type");
|
std::string type = reader->Attribute("Type");
|
||||||
scalarType = ZScalar::MapOutputTypeToScalarType(type);
|
scalarType = ZScalar::MapOutputTypeToScalarType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type) {
|
ZScalarType ZScalar::MapOutputTypeToScalarType(const std::string& type)
|
||||||
|
{
|
||||||
if (type == "s8")
|
if (type == "s8")
|
||||||
{
|
{
|
||||||
return ZSCALAR_S8;
|
return ZSCALAR_S8;
|
||||||
|
@ -229,3 +228,8 @@ ZResourceType ZScalar::GetResourceType()
|
||||||
{
|
{
|
||||||
return ZResourceType::Scalar;
|
return ZResourceType::Scalar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZScalar::DoesSupportArray()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -43,12 +43,14 @@ public:
|
||||||
ZScalar();
|
ZScalar();
|
||||||
ZScalar(const ZScalarType scalarType);
|
ZScalar(const ZScalarType scalarType);
|
||||||
|
|
||||||
void ParseXML(tinyxml2::XMLElement* reader);
|
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||||
std::string GetSourceTypeName();
|
std::string GetSourceTypeName() override;
|
||||||
std::string GetSourceValue();
|
std::string GetSourceValue();
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
ZResourceType GetResourceType();
|
ZResourceType GetResourceType() override;
|
||||||
|
bool DoesSupportArray() override;
|
||||||
|
void ParseRawData() override;
|
||||||
|
|
||||||
static ZScalar* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
static ZScalar* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
||||||
static int MapTypeToSize(const ZScalarType scalarType);
|
static int MapTypeToSize(const ZScalarType scalarType);
|
||||||
|
@ -56,6 +58,5 @@ public:
|
||||||
static std::string MapScalarTypeToOutputType(const ZScalarType scalarType);
|
static std::string MapScalarTypeToOutputType(const ZScalarType scalarType);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ParseRawData();
|
|
||||||
void ParseRawData(const std::vector<uint8_t>& data, const int offset);
|
void ParseRawData(const std::vector<uint8_t>& data, const int offset);
|
||||||
};
|
};
|
|
@ -264,6 +264,11 @@ void ZSkeleton::Save(const std::string& outFolder)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZResourceType ZSkeleton::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::Skeleton;
|
||||||
|
}
|
||||||
|
|
||||||
ZLimbLOD::ZLimbLOD() : ZLimbStandard()
|
ZLimbLOD::ZLimbLOD() : ZLimbStandard()
|
||||||
{
|
{
|
||||||
farDListPtr = 0;
|
farDListPtr = 0;
|
||||||
|
|
|
@ -25,8 +25,8 @@ struct ZLimbStandard : public ZResource
|
||||||
ZLimbStandard();
|
ZLimbStandard();
|
||||||
static ZLimbStandard* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath, ZFile* parent);
|
static ZLimbStandard* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath, ZFile* parent);
|
||||||
static ZLimbStandard* FromRawData(std::vector<uint8_t> nRawData, int rawDataIndex);
|
static ZLimbStandard* FromRawData(std::vector<uint8_t> nRawData, int rawDataIndex);
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
virtual int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ZLimbLOD : ZLimbStandard
|
struct ZLimbLOD : ZLimbStandard
|
||||||
|
@ -36,8 +36,8 @@ struct ZLimbLOD : ZLimbStandard
|
||||||
ZLimbLOD();
|
ZLimbLOD();
|
||||||
//static ZLimbLOD* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath, ZFile* parent);
|
//static ZLimbLOD* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath, ZFile* parent);
|
||||||
static ZLimbLOD* FromRawData(std::vector<uint8_t> nRawData, int rawDataIndex);
|
static ZLimbLOD* FromRawData(std::vector<uint8_t> nRawData, int rawDataIndex);
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
virtual int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ZSkeletonType
|
enum ZSkeletonType
|
||||||
|
@ -58,7 +58,8 @@ public:
|
||||||
ZSkeleton();
|
ZSkeleton();
|
||||||
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
virtual void GenerateHLIntermediette(HLFileIntermediette& hlFile);
|
||||||
static ZSkeleton* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath, ZFile* nParent);
|
static ZSkeleton* FromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, std::string nRelPath, ZFile* nParent);
|
||||||
void Save(const std::string& outFolder);
|
void Save(const std::string& outFolder) override;
|
||||||
|
ZResourceType GetResourceType() override;
|
||||||
|
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ protected:
|
||||||
uint8_t* bmpRgb;
|
uint8_t* bmpRgb;
|
||||||
uint8_t* bmpRgba;
|
uint8_t* bmpRgba;
|
||||||
|
|
||||||
virtual void ParseXML(tinyxml2::XMLElement* reader);
|
void ParseXML(tinyxml2::XMLElement* reader) override;
|
||||||
void FixRawData();
|
void FixRawData();
|
||||||
void PrepareBitmap();
|
void PrepareBitmap();
|
||||||
void PrepareBitmapRGBA16();
|
void PrepareBitmapRGBA16();
|
||||||
|
@ -52,9 +52,9 @@ protected:
|
||||||
void PrepareRawDataPalette4(std::string palPath);
|
void PrepareRawDataPalette4(std::string palPath);
|
||||||
void PrepareRawDataPalette8(std::string palPath);
|
void PrepareRawDataPalette8(std::string palPath);
|
||||||
float GetPixelMultiplyer();
|
float GetPixelMultiplyer();
|
||||||
bool IsExternalResource();
|
bool IsExternalResource() override;
|
||||||
ZResourceType GetResourceType();
|
ZResourceType GetResourceType() override;
|
||||||
void CalcHash();
|
void CalcHash() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZTexture();
|
ZTexture();
|
||||||
|
@ -72,8 +72,8 @@ public:
|
||||||
std::string GetSourceOutputCode(const std::string& prefix) override;
|
std::string GetSourceOutputCode(const std::string& prefix) override;
|
||||||
std::string GetSourceOutputHeader(const std::string& prefix) override;
|
std::string GetSourceOutputHeader(const std::string& prefix) override;
|
||||||
|
|
||||||
std::vector<uint8_t> GetRawData();
|
std::vector<uint8_t> GetRawData() override;
|
||||||
int GetRawDataSize();
|
int GetRawDataSize() override;
|
||||||
std::string GetIMFmtFromType();
|
std::string GetIMFmtFromType();
|
||||||
std::string GetIMSizFromType();
|
std::string GetIMSizFromType();
|
||||||
int GetWidth();
|
int GetWidth();
|
||||||
|
@ -81,6 +81,6 @@ public:
|
||||||
void SetWidth(int nWidth);
|
void SetWidth(int nWidth);
|
||||||
void SetHeight(int nHeight);
|
void SetHeight(int nHeight);
|
||||||
TextureType GetTextureType();
|
TextureType GetTextureType();
|
||||||
void Save(const std::string& outFolder);
|
void Save(const std::string& outFolder) override;
|
||||||
std::string GetExternalExtension();
|
std::string GetExternalExtension() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,9 @@ void ZVector::ParseRawData()
|
||||||
int currentRawDataIndex = this->rawDataIndex;
|
int currentRawDataIndex = this->rawDataIndex;
|
||||||
|
|
||||||
scalars.clear();
|
scalars.clear();
|
||||||
for (int i = 0; i < this->dimensions; i++) {
|
|
||||||
|
for (int i = 0; i < this->dimensions; i++)
|
||||||
|
{
|
||||||
ZScalar* scalar = new ZScalar(this->scalarType);
|
ZScalar* scalar = new ZScalar(this->scalarType);
|
||||||
scalar->rawDataIndex = currentRawDataIndex;
|
scalar->rawDataIndex = currentRawDataIndex;
|
||||||
scalar->rawData = this->rawData;
|
scalar->rawData = this->rawData;
|
||||||
|
@ -64,6 +66,11 @@ int ZVector::GetRawDataSize()
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZVector::DoesSupportArray()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string ZVector::GetSourceTypeName()
|
std::string ZVector::GetSourceTypeName()
|
||||||
{
|
{
|
||||||
if (dimensions == 3 && scalarType == ZSCALAR_F32)
|
if (dimensions == 3 && scalarType == ZSCALAR_F32)
|
||||||
|
@ -94,7 +101,7 @@ std::string ZVector::GetSourceValue()
|
||||||
std::vector<std::string> strings = std::vector<std::string>();
|
std::vector<std::string> strings = std::vector<std::string>();
|
||||||
for (int i = 0; i < this->scalars.size(); i++)
|
for (int i = 0; i < this->scalars.size(); i++)
|
||||||
strings.push_back(scalars[i]->GetSourceValue());
|
strings.push_back(scalars[i]->GetSourceValue());
|
||||||
return StringHelper::Implode(strings, ", ");
|
return "{ " + StringHelper::Implode(strings, ", ") + " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ZVector::GetSourceOutputCode(const std::string& prefix)
|
std::string ZVector::GetSourceOutputCode(const std::string& prefix)
|
||||||
|
|
|
@ -17,14 +17,15 @@ public:
|
||||||
ZVector();
|
ZVector();
|
||||||
|
|
||||||
void ParseXML(tinyxml2::XMLElement* reader);
|
void ParseXML(tinyxml2::XMLElement* reader);
|
||||||
std::string GetSourceTypeName();
|
std::string GetSourceTypeName() override;
|
||||||
std::string GetSourceValue();
|
std::string GetSourceValue();
|
||||||
std::string GetSourceOutputCode(const std::string& prefix);
|
std::string GetSourceOutputCode(const std::string& prefix);
|
||||||
|
void ParseRawData() override;
|
||||||
int GetRawDataSize();
|
int GetRawDataSize();
|
||||||
|
bool DoesSupportArray() override;
|
||||||
ZResourceType GetResourceType();
|
ZResourceType GetResourceType();
|
||||||
|
|
||||||
static ZVector* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
static ZVector* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ParseRawData();
|
|
||||||
};
|
};
|
78
tools/ZAPD/ZAPD/ZVtx.cpp
Normal file
78
tools/ZAPD/ZAPD/ZVtx.cpp
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#include "ZVtx.h"
|
||||||
|
#include "ZFile.h"
|
||||||
|
#include "StringHelper.h"
|
||||||
|
#include "BitConverter.h"
|
||||||
|
|
||||||
|
ZVtx::ZVtx()
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
flag = 0;
|
||||||
|
s = 0;
|
||||||
|
t = 0;
|
||||||
|
r = 0;
|
||||||
|
g = 0;
|
||||||
|
b = 0;
|
||||||
|
a = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZVtx::ParseXML(tinyxml2::XMLElement* reader)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ZVtx::GetSourceTypeName()
|
||||||
|
{
|
||||||
|
return "Vtx";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ZVtx::GetSourceOutputCode(const std::string& prefix)
|
||||||
|
{
|
||||||
|
std::string output = StringHelper::Sprintf("VTX(%i, %i, %i, %i, %i, %i, %i, %i, %i)", x, y, z, s, t, r, g, b, a);
|
||||||
|
|
||||||
|
if (parent != nullptr)
|
||||||
|
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(), GetSourceTypeName(), name, output);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZVtx::ParseRawData()
|
||||||
|
{
|
||||||
|
const uint8_t* data = rawData.data();
|
||||||
|
|
||||||
|
x = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||||
|
y = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||||
|
z = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||||
|
flag = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||||
|
s = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||||
|
t = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||||
|
r = data[rawDataIndex + 12];
|
||||||
|
g = data[rawDataIndex + 13];
|
||||||
|
b = data[rawDataIndex + 14];
|
||||||
|
a = data[rawDataIndex + 15];
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZVtx::GetRawDataSize()
|
||||||
|
{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZVtx::DoesSupportArray()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZResourceType ZVtx::GetResourceType()
|
||||||
|
{
|
||||||
|
return ZResourceType::Vertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZVtx* ZVtx::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath)
|
||||||
|
{
|
||||||
|
ZVtx* vtx = new ZVtx();
|
||||||
|
vtx->rawData = nRawData;
|
||||||
|
vtx->rawDataIndex = rawDataIndex;
|
||||||
|
vtx->ParseRawData();
|
||||||
|
|
||||||
|
return vtx;
|
||||||
|
}
|
31
tools/ZAPD/ZAPD/ZVtx.h
Normal file
31
tools/ZAPD/ZAPD/ZVtx.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "ZResource.h"
|
||||||
|
#include "ZScalar.h"
|
||||||
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
class ZVtx : public ZResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int16_t x, y, z;
|
||||||
|
uint16_t flag;
|
||||||
|
int16_t s, t;
|
||||||
|
uint8_t r, g, b, a;
|
||||||
|
|
||||||
|
ZVtx();
|
||||||
|
|
||||||
|
void ParseXML(tinyxml2::XMLElement* reader);
|
||||||
|
std::string GetSourceTypeName() override;
|
||||||
|
std::string GetSourceOutputCode(const std::string& prefix);
|
||||||
|
void ParseRawData() override;
|
||||||
|
int GetRawDataSize();
|
||||||
|
bool DoesSupportArray() override;
|
||||||
|
ZResourceType GetResourceType();
|
||||||
|
|
||||||
|
static ZVtx* ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
};
|
Loading…
Reference in a new issue