Further element implementation; GPSM factory refactor

This commit is contained in:
Jack Andersen 2016-02-02 17:58:33 -10:00
parent 80b226fbfe
commit 0f2b9ce962
4 changed files with 896 additions and 369 deletions

View File

@ -2,6 +2,7 @@
#define __COMMON_PART_HPP__ #define __COMMON_PART_HPP__
#include "ParticleCommon.hpp" #include "ParticleCommon.hpp"
#include "PAK.hpp"
namespace Retro namespace Retro
{ {
@ -30,7 +31,7 @@ struct GPSM : BigYAML
IntElementFactory x34_LTME; IntElementFactory x34_LTME;
VectorElementFactory x38_ILOC; VectorElementFactory x38_ILOC;
VectorElementFactory x3c_IVEC; VectorElementFactory x3c_IVEC;
//EmitterElementFactory x40_EMTR; EmitterElementFactory x40_EMTR;
bool x44_0_SORT : 1; bool x44_1_MBLR : 1; bool x44_2_LINE : 1; bool x44_3_LIT_ : 1; bool x44_0_SORT : 1; bool x44_1_MBLR : 1; bool x44_2_LINE : 1; bool x44_3_LIT_ : 1;
bool x44_4_AAPH : 1; bool x44_5_ZBUF : 1; bool x44_6_FXLL : 1; bool x44_7_PMAB : 1; bool x44_4_AAPH : 1; bool x44_5_ZBUF : 1; bool x44_6_FXLL : 1; bool x44_7_PMAB : 1;
bool x45_0_VMD4 : 1; bool x45_1_VMD3 : 1; bool x45_2_VMD2 : 1; bool x45_3_VMD1 : 1; bool x45_0_VMD4 : 1; bool x45_1_VMD3 : 1; bool x45_2_VMD2 : 1; bool x45_3_VMD1 : 1;
@ -38,9 +39,9 @@ struct GPSM : BigYAML
IntElementFactory x48_MBSP; IntElementFactory x48_MBSP;
RealElementFactory x4c_SIZE; RealElementFactory x4c_SIZE;
RealElementFactory x50_ROTA; RealElementFactory x50_ROTA;
UVElementFactory x54_TEXR; UVElementFactory<IDType> x54_TEXR;
UVElementFactory x58_TIND; UVElementFactory<IDType> x58_TIND;
// x5c_PMDL Model ChildResourceFactory<IDType> x5c_PMDL;
VectorElementFactory x6c_PMOP; VectorElementFactory x6c_PMOP;
VectorElementFactory x70_PMRT; VectorElementFactory x70_PMRT;
VectorElementFactory x74_PMSC; VectorElementFactory x74_PMSC;
@ -49,21 +50,21 @@ struct GPSM : BigYAML
ModVectorElementFactory x80_VEL2; ModVectorElementFactory x80_VEL2;
ModVectorElementFactory x84_VEL3; ModVectorElementFactory x84_VEL3;
ModVectorElementFactory x88_VEL4; ModVectorElementFactory x88_VEL4;
ChildGeneratorDesc<IDType> x8c_ICTS; ChildResourceFactory<IDType> x8c_ICTS;
IntElementFactory x9c_NCSY; IntElementFactory x9c_NCSY;
IntElementFactory xb4_NDSY; IntElementFactory xb4_NDSY;
ChildGeneratorDesc<IDType> xb8_IITS; ChildResourceFactory<IDType> xb8_IITS;
IntElementFactory xa0_CSSD; IntElementFactory xa0_CSSD;
ChildGeneratorDesc<IDType> xa4_IDTS; ChildResourceFactory<IDType> xa4_IDTS;
IntElementFactory xc8_PISY; IntElementFactory xc8_PISY;
IntElementFactory xcc_SISY; IntElementFactory xcc_SISY;
// xd0_KSSM SpawnSystemKeyframeData<IDType> xd0_KSSM;
// xd4_SSWH Swoosh ChildResourceFactory<IDType> xd4_SSWH;
IntElementFactory xe4_SSSD; IntElementFactory xe4_SSSD;
VectorElementFactory xe8_SSPO; VectorElementFactory xe8_SSPO;
IntElementFactory xf8_SESD; IntElementFactory xf8_SESD;
VectorElementFactory xfc_SEPO; VectorElementFactory xfc_SEPO;
// xec_PMLC Electric Generator ChildResourceFactory<IDType> xec_PMLC;
IntElementFactory x100_LTYP; IntElementFactory x100_LTYP;
ColorElementFactory x104_LCLR; ColorElementFactory x104_LCLR;
RealElementFactory x108_LINT; RealElementFactory x108_LINT;
@ -73,355 +74,241 @@ struct GPSM : BigYAML
RealElementFactory x118_LFOR; RealElementFactory x118_LFOR;
RealElementFactory x11c_LSLA; RealElementFactory x11c_LSLA;
/* 0-00 additions */
bool x30_30_ORNT : 1;
bool xUNK_RSOP : 1;
void read(Athena::io::YAMLDocReader& r) void read(Athena::io::YAMLDocReader& r)
{ {
if (r.enterSubRecord("PMCL")) for (const auto& elem : r.getCurNode()->m_mapChildren)
{ {
x78_PMCL.read(r); if (elem.first.size() < 4)
r.leaveSubRecord(); {
} LogModule.report(LogVisor::Warning, "short FourCC in element '%s'", elem.first.c_str());
if (r.enterSubRecord("LFOR")) continue;
{ }
x118_LFOR.read(r);
r.leaveSubRecord(); r.enterSubRecord(elem.first.c_str());
} switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
if (r.enterSubRecord("IDTS")) {
{ case SBIG('PMCL'):
xa4_IDTS.read(r); x78_PMCL.read(r);
r.leaveSubRecord(); break;
} case SBIG('LFOR'):
if (r.enterSubRecord("EMTR")) x118_LFOR.read(r);
{ break;
//x40_EMTR.read(r); case SBIG('IDTS'):
r.leaveSubRecord(); xa4_IDTS.read(r);
} break;
if (r.enterSubRecord("COLR")) case SBIG('EMTR'):
{ x40_EMTR.read(r);
x30_COLR.read(r); break;
r.leaveSubRecord(); case SBIG('COLR'):
} x30_COLR.read(r);
if (r.enterSubRecord("CIND")) break;
{ case SBIG('CIND'):
x45_7_CIND = r.readBool(nullptr); x45_7_CIND = r.readBool(nullptr);
r.leaveSubRecord(); break;
} case SBIG('AAPH'):
if (r.enterSubRecord("AAPH")) x44_4_AAPH = r.readBool(nullptr);
{ break;
x44_4_AAPH = r.readBool(nullptr); case SBIG('CSSD'):
r.leaveSubRecord(); xa0_CSSD.read(r);
} break;
if (r.enterSubRecord("CSSD")) case SBIG('GRTE'):
{ x2c_GRTE.read(r);
xa0_CSSD.read(r); break;
r.leaveSubRecord(); case SBIG('FXLL'):
} x44_6_FXLL = r.readBool(nullptr);
if (r.enterSubRecord("GRTE")) break;
{ case SBIG('ICTS'):
x2c_GRTE.read(r); x8c_ICTS.read(r);
r.leaveSubRecord(); break;
} case SBIG('KSSM'):
if (r.enterSubRecord("FXLL")) xd0_KSSM.read(r);
{ break;
x44_6_FXLL = r.readBool(nullptr); case SBIG('ILOC'):
r.leaveSubRecord(); x38_ILOC.read(r);
} break;
if (r.enterSubRecord("ICTS")) case SBIG('IITS'):
{ break;
x8c_ICTS.read(r); case SBIG('IVEC'):
r.leaveSubRecord(); x3c_IVEC.read(r);
} break;
if (r.enterSubRecord("KSSM")) case SBIG('LDIR'):
{ x110_LDIR.read(r);
// xd0_KSSM.read(r); break;
r.leaveSubRecord(); case SBIG('LCLR'):
} x104_LCLR.read(r);
if (r.enterSubRecord("ILOC")) break;
{ case SBIG('LENG'):
x38_ILOC.read(r); x20_LENG.read(r);
r.leaveSubRecord(); break;
} case SBIG('MAXP'):
if (r.enterSubRecord("IITS")) x28_MAXP.read(r);
{ break;
r.leaveSubRecord(); case SBIG('LOFF'):
} x10c_LOFF.read(r);
if (r.enterSubRecord("IVEC")) break;
{ case SBIG('LINT'):
x3c_IVEC.read(r); x108_LINT.read(r);
r.leaveSubRecord(); break;
} case SBIG('LINE'):
if (r.enterSubRecord("LDIR")) x44_2_LINE = r.readBool(nullptr);
{ break;
x110_LDIR.read(r); case SBIG('LFOT'):
r.leaveSubRecord(); x114_LFOT.read(r);
} break;
if (r.enterSubRecord("LCLR")) case SBIG('LIT_'):
{ x44_3_LIT_ = r.readBool(nullptr);
x104_LCLR.read(r); break;
r.leaveSubRecord(); case SBIG('LTME'):
} x34_LTME.read(r);
if (r.enterSubRecord("LENG")) break;
{ case SBIG('LSLA'):
x20_LENG.read(r); x11c_LSLA.read(r);
r.leaveSubRecord(); break;
} case SBIG('LTYP'):
if (r.enterSubRecord("MAXP")) x100_LTYP.read(r);
{ break;
x28_MAXP.read(r); case SBIG('NDSY'):
r.leaveSubRecord(); xb4_NDSY.read(r);
} break;
if (r.enterSubRecord("LOFF")) case SBIG('MBSP'):
{ x48_MBSP.read(r);
x10c_LOFF.read(r); break;
r.leaveSubRecord(); case SBIG('MBLR'):
} x44_1_MBLR = r.readBool(nullptr);
if (r.enterSubRecord("LINT")) break;
{ case SBIG('NCSY'):
x108_LINT.read(r); x9c_NCSY.read(r);
r.leaveSubRecord(); break;
} case SBIG('PISY'):
if (r.enterSubRecord("LINE")) xc8_PISY.read(r);
{ break;
x44_2_LINE = r.readBool(nullptr); case SBIG('OPTS'):
r.leaveSubRecord(); x45_4_OPTS = r.readBool(nullptr);
} break;
if (r.enterSubRecord("LFOT")) case SBIG('PMAB'):
{ x44_7_PMAB = r.readBool(nullptr);
x114_LFOT.read(r); break;
r.leaveSubRecord(); case SBIG('SESD'):
} xf8_SESD.read(r);
if (r.enterSubRecord("LIT_")) break;
{ case SBIG('SEPO'):
x44_3_LIT_ = r.readBool(nullptr); xfc_SEPO.read(r);
r.leaveSubRecord(); break;
} case SBIG('PSLT'):
if (r.enterSubRecord("LTME")) xc_PSLT.read(r);
{ break;
x34_LTME.read(r); case SBIG('PMSC'):
r.leaveSubRecord(); x74_PMSC.read(r);
} break;
if (r.enterSubRecord("LSLA")) case SBIG('PMOP'):
{ x6c_PMOP.read(r);
x11c_LSLA.read(r); break;
r.leaveSubRecord(); case SBIG('PMDL'):
} x5c_PMDL.read(r);
if (r.enterSubRecord("LTYP")) break;
{ case SBIG('PMRT'):
x100_LTYP.read(r); x70_PMRT.read(r);
r.leaveSubRecord(); break;
} case SBIG('POFS'):
if (r.enterSubRecord("NDSY")) x18_POFS.read(r);
{ break;
xb4_NDSY.read(r); case SBIG('PMUS'):
r.leaveSubRecord(); x45_5_PMUS = r.readBool(nullptr);
} break;
if (r.enterSubRecord("MBSP")) case SBIG('PSIV'):
{ x0_PSIV.read(r);
x48_MBSP.read(r); break;
r.leaveSubRecord(); case SBIG('ROTA'):
} x50_ROTA.read(r);
if (r.enterSubRecord("MBLR")) break;
{ case SBIG('PSVM'):
x44_1_MBLR = r.readBool(nullptr); x4_PSVM.read(r);
r.leaveSubRecord(); break;
} case SBIG('PSTS'):
if (r.enterSubRecord("NCSY")) x14_PSTS.read(r);
{ break;
x9c_NCSY.read(r); case SBIG('PSOV'):
r.leaveSubRecord(); x8_PSOV.read(r);
} break;
if (r.enterSubRecord("PISY")) case SBIG('PSWT'):
{ x10_PSWT.read(r);
xc8_PISY.read(r); break;
r.leaveSubRecord(); case SBIG('PMLC'):
} xec_PMLC.read(r);
if (r.enterSubRecord("OPTS")) break;
{ case SBIG('PMED'):
x45_4_OPTS = r.readBool(nullptr); x1c_PMED.read(r);
r.leaveSubRecord(); break;
} case SBIG('PMOO'):
if (r.enterSubRecord("PMAB")) x45_6_PMOO = r.readBool(nullptr);
{ break;
x44_7_PMAB = r.readBool(nullptr); case SBIG('SSSD'):
r.leaveSubRecord(); xe4_SSSD.read(r);
} break;
if (r.enterSubRecord("SESD")) case SBIG('SORT'):
{ x44_0_SORT = r.readBool(nullptr);
xf8_SESD.read(r); break;
r.leaveSubRecord(); case SBIG('SIZE'):
} x4c_SIZE.read(r);
if (r.enterSubRecord("SEPO")) break;
{ case SBIG('SISY'):
xfc_SEPO.read(r); xcc_SISY.read(r);
r.leaveSubRecord(); break;
} case SBIG('SSPO'):
if (r.enterSubRecord("PSLT")) xe8_SSPO.read(r);
{ break;
xc_PSLT.read(r); case SBIG('TEXR'):
r.leaveSubRecord(); x54_TEXR.read(r);
} break;
if (r.enterSubRecord("PMSC")) case SBIG('SSWH'):
{ xd4_SSWH.read(r);
x74_PMSC.read(r); break;
r.leaveSubRecord(); case SBIG('TIND'):
} x58_TIND.read(r);
if (r.enterSubRecord("PMOP")) break;
{ case SBIG('VMD4'):
x6c_PMOP.read(r); x45_0_VMD4 = r.readBool(nullptr);
r.leaveSubRecord(); break;
} case SBIG('VMD3'):
if (r.enterSubRecord("PMDL")) x45_1_VMD3 = r.readBool(nullptr);
{ break;
// x5c_PMDL.read(r); case SBIG('VMD2'):
r.leaveSubRecord(); x45_2_VMD2 = r.readBool(nullptr);
} break;
if (r.enterSubRecord("PMRT")) case SBIG('VMD1'):
{ x45_3_VMD1 = r.readBool(nullptr);
x70_PMRT.read(r); break;
r.leaveSubRecord(); case SBIG('VEL4'):
} x88_VEL4.read(r);
if (r.enterSubRecord("POFS")) break;
{ case SBIG('VEL3'):
x18_POFS.read(r); x84_VEL3.read(r);
r.leaveSubRecord(); break;
} case SBIG('VEL2'):
if (r.enterSubRecord("PMUS")) x80_VEL2.read(r);
{ break;
x45_5_PMUS = r.readBool(nullptr); case SBIG('VEL1'):
r.leaveSubRecord(); x7c_VEL1.read(r);
} break;
if (r.enterSubRecord("PSIV")) case SBIG('ZBUF'):
{ x44_5_ZBUF = r.readBool(nullptr);
x0_PSIV.read(r); break;
r.leaveSubRecord(); case SBIG('WIDT'):
} x24_WIDT.read(r);
if (r.enterSubRecord("ROTA")) break;
{ case SBIG('ORNT'):
x50_ROTA.read(r); x30_30_ORNT = r.readBool(nullptr);
r.leaveSubRecord(); break;
} case SBIG('RSOP'):
if (r.enterSubRecord("PSVM")) xUNK_RSOP = r.readBool(nullptr);
{ break;
x4_PSVM.read(r); default:
r.leaveSubRecord(); break;
} }
if (r.enterSubRecord("PSTS"))
{
x14_PSTS.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("PSOV"))
{
x8_PSOV.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("PSWT"))
{
x10_PSWT.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("PMLC"))
{
// xec_PMLC.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("PMED"))
{
x1c_PMED.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("PMOO"))
{
x45_6_PMOO = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("SSSD"))
{
xe4_SSSD.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("SORT"))
{
x44_0_SORT = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("SIZE"))
{
x4c_SIZE.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("SISY"))
{
xcc_SISY.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("SSPO"))
{
xe8_SSPO.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("TEXR"))
{
x54_TEXR.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("SSWH"))
{
// xd4_SSWH.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("TIND"))
{
x58_TIND.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("VMD4"))
{
x45_0_VMD4 = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("VMD3"))
{
x45_1_VMD3 = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("VMD2"))
{
x45_2_VMD2 = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("VMD1"))
{
x45_3_VMD1 = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("VEL4"))
{
x88_VEL4.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("VEL3"))
{
x84_VEL3.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("VEL2"))
{
x80_VEL2.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("VEL1"))
{
x7c_VEL1.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("ZBUF"))
{
x44_5_ZBUF = r.readBool(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("WIDT"))
{
x24_WIDT.read(r);
r.leaveSubRecord(); r.leaveSubRecord();
} }
} }
@ -431,11 +318,263 @@ struct GPSM : BigYAML
} }
size_t binarySize(size_t __isz) const size_t binarySize(size_t __isz) const
{ {
/* TODO: Figure out order of emitting */
return __isz;
} }
void read(Athena::io::IStreamReader& r) void read(Athena::io::IStreamReader& r)
{ {
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId != SBIG('GPSM'))
{
LogModule.report(LogVisor::Warning, "non GPSM provided to GPSM parser");
return;
}
r.readBytesToBuf(&clsId, 4);
while (clsId != SBIG('_END'))
{
switch (clsId)
{
case SBIG('PMCL'):
x78_PMCL.read(r);
break;
case SBIG('LFOR'):
x118_LFOR.read(r);
break;
case SBIG('IDTS'):
xa4_IDTS.read(r);
break;
case SBIG('EMTR'):
x40_EMTR.read(r);
break;
case SBIG('COLR'):
x30_COLR.read(r);
break;
case SBIG('CIND'):
r.readUint32Big();
x45_7_CIND = r.readBool();
break;
case SBIG('AAPH'):
r.readUint32Big();
x44_4_AAPH = r.readBool();
break;
case SBIG('CSSD'):
xa0_CSSD.read(r);
break;
case SBIG('GRTE'):
x2c_GRTE.read(r);
break;
case SBIG('FXLL'):
r.readUint32Big();
x44_6_FXLL = r.readBool();
break;
case SBIG('ICTS'):
x8c_ICTS.read(r);
break;
case SBIG('KSSM'):
xd0_KSSM.read(r);
break;
case SBIG('ILOC'):
x38_ILOC.read(r);
break;
case SBIG('IITS'):
break;
case SBIG('IVEC'):
x3c_IVEC.read(r);
break;
case SBIG('LDIR'):
x110_LDIR.read(r);
break;
case SBIG('LCLR'):
x104_LCLR.read(r);
break;
case SBIG('LENG'):
x20_LENG.read(r);
break;
case SBIG('MAXP'):
x28_MAXP.read(r);
break;
case SBIG('LOFF'):
x10c_LOFF.read(r);
break;
case SBIG('LINT'):
x108_LINT.read(r);
break;
case SBIG('LINE'):
r.readUint32Big();
x44_2_LINE = r.readBool();
break;
case SBIG('LFOT'):
x114_LFOT.read(r);
break;
case SBIG('LIT_'):
r.readUint32Big();
x44_3_LIT_ = r.readBool();
break;
case SBIG('LTME'):
x34_LTME.read(r);
break;
case SBIG('LSLA'):
x11c_LSLA.read(r);
break;
case SBIG('LTYP'):
x100_LTYP.read(r);
break;
case SBIG('NDSY'):
xb4_NDSY.read(r);
break;
case SBIG('MBSP'):
x48_MBSP.read(r);
break;
case SBIG('MBLR'):
r.readUint32Big();
x44_1_MBLR = r.readBool();
break;
case SBIG('NCSY'):
x9c_NCSY.read(r);
break;
case SBIG('PISY'):
xc8_PISY.read(r);
break;
case SBIG('OPTS'):
r.readUint32Big();
x45_4_OPTS = r.readBool();
break;
case SBIG('PMAB'):
r.readUint32Big();
x44_7_PMAB = r.readBool();
break;
case SBIG('SESD'):
xf8_SESD.read(r);
break;
case SBIG('SEPO'):
xfc_SEPO.read(r);
break;
case SBIG('PSLT'):
xc_PSLT.read(r);
break;
case SBIG('PMSC'):
x74_PMSC.read(r);
break;
case SBIG('PMOP'):
x6c_PMOP.read(r);
break;
case SBIG('PMDL'):
x5c_PMDL.read(r);
break;
case SBIG('PMRT'):
x70_PMRT.read(r);
break;
case SBIG('POFS'):
x18_POFS.read(r);
break;
case SBIG('PMUS'):
r.readUint32Big();
x45_5_PMUS = r.readBool();
break;
case SBIG('PSIV'):
x0_PSIV.read(r);
break;
case SBIG('ROTA'):
x50_ROTA.read(r);
break;
case SBIG('PSVM'):
x4_PSVM.read(r);
break;
case SBIG('PSTS'):
x14_PSTS.read(r);
break;
case SBIG('PSOV'):
x8_PSOV.read(r);
break;
case SBIG('PSWT'):
x10_PSWT.read(r);
break;
case SBIG('PMLC'):
xec_PMLC.read(r);
break;
case SBIG('PMED'):
x1c_PMED.read(r);
break;
case SBIG('PMOO'):
r.readUint32Big();
x45_6_PMOO = r.readBool();
break;
case SBIG('SSSD'):
xe4_SSSD.read(r);
break;
case SBIG('SORT'):
r.readUint32Big();
x44_0_SORT = r.readBool();
break;
case SBIG('SIZE'):
x4c_SIZE.read(r);
break;
case SBIG('SISY'):
xcc_SISY.read(r);
break;
case SBIG('SSPO'):
xe8_SSPO.read(r);
break;
case SBIG('TEXR'):
x54_TEXR.read(r);
break;
case SBIG('SSWH'):
xd4_SSWH.read(r);
break;
case SBIG('TIND'):
x58_TIND.read(r);
break;
case SBIG('VMD4'):
r.readUint32Big();
x45_0_VMD4 = r.readBool();
break;
case SBIG('VMD3'):
r.readUint32Big();
x45_1_VMD3 = r.readBool();
break;
case SBIG('VMD2'):
r.readUint32Big();
x45_2_VMD2 = r.readBool();
break;
case SBIG('VMD1'):
r.readUint32Big();
x45_3_VMD1 = r.readBool();
break;
case SBIG('VEL4'):
x88_VEL4.read(r);
break;
case SBIG('VEL3'):
x84_VEL3.read(r);
break;
case SBIG('VEL2'):
x80_VEL2.read(r);
break;
case SBIG('VEL1'):
x7c_VEL1.read(r);
break;
case SBIG('ZBUF'):
r.readUint32Big();
x44_5_ZBUF = r.readBool();
break;
case SBIG('WIDT'):
x24_WIDT.read(r);
break;
case SBIG('ORNT'):
r.readUint32Big();
x30_30_ORNT = r.readBool();
break;
case SBIG('RSOP'):
r.readUint32Big();
xUNK_RSOP = r.readBool();
break;
default:
LogModule.report(LogVisor::Warning, "Unknown GPSM class %.4s @%" PRIi64, &clsId, r.position());
printf("");
break;
}
r.readBytesToBuf(&clsId, 4);
}
} }
void write(Athena::io::IStreamWriter& w) const void write(Athena::io::IStreamWriter& w) const
{ {
@ -443,6 +582,21 @@ struct GPSM : BigYAML
} }
}; };
template <class IDType>
bool ExtractGPSM(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
{
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
{
GPSM<IDType> gpsm;
gpsm.read(rs);
gpsm.toYAMLFile(fp);
fclose(fp);
return true;
}
return false;
}
} }
} }

View File

@ -4,7 +4,7 @@ namespace Retro
{ {
namespace DNAParticle namespace DNAParticle
{ {
static LogVisor::LogModule Log("Retro::ParticleCommon "); LogVisor::LogModule LogModule("Retro::DNAParticle");
void RealElementFactory::read(Athena::io::YAMLDocReader& r) void RealElementFactory::read(Athena::io::YAMLDocReader& r)
{ {
@ -17,7 +17,7 @@ void RealElementFactory::read(Athena::io::YAMLDocReader& r)
const auto& elem = mapChildren[0]; const auto& elem = mapChildren[0];
if (elem.first.size() < 4) if (elem.first.size() < 4)
Log.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str()); LogModule.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str());
switch (*reinterpret_cast<const uint32_t*>(elem.first.data())) switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{ {
@ -164,7 +164,7 @@ void IntElementFactory::read(Athena::io::YAMLDocReader& r)
const auto& elem = mapChildren[0]; const auto& elem = mapChildren[0];
if (elem.first.size() < 4) if (elem.first.size() < 4)
Log.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str()); LogModule.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str());
switch (*reinterpret_cast<const uint32_t*>(elem.first.data())) switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{ {
@ -316,7 +316,7 @@ void VectorElementFactory::read(Athena::io::YAMLDocReader& r)
const auto& elem = mapChildren[0]; const auto& elem = mapChildren[0];
if (elem.first.size() < 4) if (elem.first.size() < 4)
Log.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str()); LogModule.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str());
switch (*reinterpret_cast<const uint32_t*>(elem.first.data())) switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{ {
@ -451,7 +451,7 @@ void ColorElementFactory::read(Athena::io::YAMLDocReader& r)
const auto& elem = mapChildren[0]; const auto& elem = mapChildren[0];
if (elem.first.size() < 4) if (elem.first.size() < 4)
Log.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str()); LogModule.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str());
switch (*reinterpret_cast<const uint32_t*>(elem.first.data())) switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{ {
@ -556,7 +556,7 @@ void ModVectorElementFactory::read(Athena::io::YAMLDocReader& r)
const auto& elem = mapChildren[0]; const auto& elem = mapChildren[0];
if (elem.first.size() < 4) if (elem.first.size() < 4)
Log.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str()); LogModule.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str());
switch (*reinterpret_cast<const uint32_t*>(elem.first.data())) switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{ {
@ -683,5 +683,90 @@ void ModVectorElementFactory::write(Athena::io::IStreamWriter& w) const
w.writeBytes((atInt8*)"NONE", 4); w.writeBytes((atInt8*)"NONE", 4);
} }
void EmitterElementFactory::read(Athena::io::YAMLDocReader& r)
{
const auto& mapChildren = r.getCurNode()->m_mapChildren;
if (mapChildren.empty())
{
m_elem.reset();
return;
}
const auto& elem = mapChildren[0];
if (elem.first.size() < 4)
LogModule.report(LogVisor::FatalError, "short FourCC in element '%s'", elem.first.c_str());
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{
case SBIG('SETR'):
m_elem.reset(new struct EESimpleEmitterTR);
break;
case SBIG('SEMR'):
m_elem.reset(new struct EESimpleEmitter);
break;
case SBIG('SPHE'):
m_elem.reset(new struct VESphere);
break;
default:
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
m_elem->read(r);
r.leaveSubRecord();
}
void EmitterElementFactory::write(Athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t EmitterElementFactory::binarySize(size_t __isz) const
{
if (m_elem)
return m_elem->binarySize(__isz + 4);
else
return __isz + 4;
}
void EmitterElementFactory::read(Athena::io::IStreamReader& r)
{
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
switch (clsId)
{
case SBIG('SETR'):
m_elem.reset(new struct EESimpleEmitterTR);
break;
case SBIG('SEMR'):
m_elem.reset(new struct EESimpleEmitter);
break;
case SBIG('SPHE'):
m_elem.reset(new struct VESphere);
break;
default:
m_elem.reset();
return;
}
m_elem->read(r);
}
void EmitterElementFactory::write(Athena::io::IStreamWriter& w) const
{
if (m_elem)
{
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
m_elem->write(w);
}
else
w.writeBytes((atInt8*)"NONE", 4);
}
} }
} }

View File

@ -7,6 +7,7 @@ namespace Retro
{ {
namespace DNAParticle namespace DNAParticle
{ {
extern LogVisor::LogModule LogModule;
struct IElement : BigYAML struct IElement : BigYAML
{ {
@ -85,6 +86,19 @@ struct ModVectorElementFactory : BigYAML
void write(Athena::io::IStreamWriter& w) const; void write(Athena::io::IStreamWriter& w) const;
}; };
struct IEmitterElement : IElement {Delete _d;};
struct EmitterElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IEmitterElement> m_elem;
void read(Athena::io::YAMLDocReader& r);
void write(Athena::io::YAMLDocWriter& w) const;
size_t binarySize(size_t __isz) const;
void read(Athena::io::IStreamReader& r);
void write(Athena::io::IStreamWriter& w) const;
};
struct IUVElement : IElement {Delete _d;}; struct IUVElement : IElement {Delete _d;};
struct RELifetimeTween : IRealElement struct RELifetimeTween : IRealElement
@ -601,6 +615,82 @@ struct MVESwirl : IModVectorElement
const char* ClassID() const {return "SWRL";} const char* ClassID() const {return "SWRL";}
}; };
struct EESimpleEmitter : IEmitterElement
{
DECL_YAML
VectorElementFactory loc;
VectorElementFactory vec;
const char* ClassID() const {return "SEMR";}
};
struct VESphere : IEmitterElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
RealElementFactory c;
const char* ClassID() const {return "SPHE";}
};
struct EESimpleEmitterTR : EESimpleEmitter
{
Delete _d;
void read(Athena::io::YAMLDocReader& r)
{
loc.m_elem.reset();
vec.m_elem.reset();
if (r.enterSubRecord("ILOC"))
{
loc.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("IVEC"))
{
vec.read(r);
r.leaveSubRecord();
}
}
void write(Athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("ILOC");
loc.write(w);
w.leaveSubRecord();
w.enterSubRecord("IVEC");
vec.write(w);
w.leaveSubRecord();
}
size_t binarySize(size_t __isz) const
{
__isz += 8;
__isz = loc.binarySize(__isz);
__isz = vec.binarySize(__isz);
return __isz;
}
void read(Athena::io::IStreamReader& r)
{
loc.m_elem.reset();
vec.m_elem.reset();
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('ILOC'))
{
loc.read(r);
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('IVEC'))
vec.read(r);
}
}
void write(Athena::io::IStreamWriter& w) const
{
w.writeBytes((atInt8*)"ILOC", 4);
loc.write(w);
w.writeBytes((atInt8*)"IVEC", 4);
vec.write(w);
}
const char* ClassID() const {return "SETR";}
};
template <class IDType> template <class IDType>
struct UVEConstant : IUVElement struct UVEConstant : IUVElement
{ {
@ -631,7 +721,7 @@ struct UVEConstant : IUVElement
size_t binarySize(size_t __isz) const size_t binarySize(size_t __isz) const
{ {
if (tex) if (tex)
return __isz + 8; return tex.binarySize(__isz + 4);
else else
return __isz + 4; return __isz + 4;
} }
@ -653,6 +743,7 @@ struct UVEConstant : IUVElement
else else
w.writeBytes((atInt8*)"NONE", 4); w.writeBytes((atInt8*)"NONE", 4);
} }
const char* ClassID() const {return "CNST";}
}; };
template <class IDType> template <class IDType>
@ -742,7 +833,7 @@ struct UVEAnimTexture : IUVElement
{ {
__isz += 8; __isz += 8;
if (tex) if (tex)
__isz += 4; __isz = tex.binarySize(__isz);
__isz = a.binarySize(__isz); __isz = a.binarySize(__isz);
__isz = b.binarySize(__isz); __isz = b.binarySize(__isz);
__isz = c.binarySize(__isz); __isz = c.binarySize(__isz);
@ -794,6 +885,7 @@ struct UVEAnimTexture : IUVElement
else else
w.writeBytes((atInt8*)"NONE", 4); w.writeBytes((atInt8*)"NONE", 4);
} }
const char* ClassID() const {return "ATEX";}
}; };
template <class IDType> template <class IDType>
@ -870,7 +962,200 @@ struct UVElementFactory : BigYAML
}; };
template <class IDType> template <class IDType>
struct ChildGeneratorDesc : BigYAML struct SpawnSystemKeyframeData : BigYAML
{
Delete _d;
Value<atUint32> a;
Value<atUint32> b;
Value<atUint32> c;
Value<atUint32> d;
struct SpawnSystemKeyframeInfo : BigYAML
{
Delete _d;
IDType id;
Value<atUint32> a;
Value<atUint32> b;
Value<atUint32> c;
void read(Athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("id"))
{
id.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("a"))
{
a = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
b = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("c"))
{
c = r.readUint32(nullptr);
r.leaveSubRecord();
}
}
void write(Athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("id");
id.write(w);
w.leaveSubRecord();
w.writeUint32("a", a);
w.writeUint32("b", b);
w.writeUint32("c", c);
}
size_t binarySize(size_t __isz) const
{
return id.binarySize(__isz + 12);
}
void read(Athena::io::IStreamReader& r)
{
id.read(r);
a = r.readUint32Big();
b = r.readUint32Big();
c = r.readUint32Big();
}
void write(Athena::io::IStreamWriter& w) const
{
id.write(w);
w.writeUint32Big(a);
w.writeUint32Big(b);
w.writeUint32Big(c);
}
};
std::vector<std::pair<atUint32, std::vector<SpawnSystemKeyframeInfo>>> spawns;
void read(Athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("a"))
{
a = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
b = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("c"))
{
c = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("d"))
{
d = r.readUint32(nullptr);
r.leaveSubRecord();
}
spawns.clear();
if (r.enterSubVector("spawns"))
{
spawns.reserve(r.getCurNode()->m_seqChildren.size());
for (const auto& child : r.getCurNode()->m_seqChildren)
{
if (r.enterSubRecord(nullptr))
{
spawns.emplace_back();
spawns.back().first = r.readUint32("first");
if (r.enterSubVector("second"))
{
spawns.back().second.reserve(r.getCurNode()->m_seqChildren.size());
for (const auto& in : r.getCurNode()->m_seqChildren)
{
spawns.back().second.emplace_back();
SpawnSystemKeyframeInfo& info = spawns.back().second.back();
r.enterSubRecord(nullptr);
info.read(r);
r.leaveSubRecord();
}
r.leaveSubVector();
}
r.leaveSubRecord();
}
}
r.leaveSubVector();
}
}
void write(Athena::io::YAMLDocWriter& w) const
{
w.writeUint32("a", a);
w.writeUint32("b", b);
w.writeUint32("c", c);
w.writeUint32("d", d);
w.enterSubVector("spawns");
for (const auto& spawn : spawns)
{
w.writeUint32("first", spawn.first);
w.enterSubVector("second");
for (const auto& info : spawn.second)
{
w.enterSubRecord(nullptr);
info.write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
__isz += 20;
for (const auto& spawn : spawns)
{
__isz += 8;
for (const auto& info : spawn.second)
__isz = info.binarySize(__isz);
}
return __isz;
}
void read(Athena::io::IStreamReader& r)
{
a = r.readUint32Big();
b = r.readUint32Big();
c = r.readUint32Big();
d = r.readUint32Big();
uint32_t count = r.readUint32Big();
spawns.clear();
spawns.reserve(count);
for (size_t i=0 ; i<count ; ++i)
{
spawns.emplace_back();
spawns.back().first = r.readUint32Big();
uint32_t infoCount = r.readUint32Big();
spawns.back().second.reserve(infoCount);
for (size_t j=0 ; j<infoCount ; ++j)
{
spawns.back().second.emplace_back();
spawns.back().second.back().read(r);
}
}
}
void write(Athena::io::IStreamWriter& w) const
{
w.writeUint32Big(a);
w.writeUint32Big(b);
w.writeUint32Big(c);
w.writeUint32Big(d);
w.writeUint32Big(spawns.size());
for (const auto& spawn : spawns)
{
w.writeUint32Big(spawn.first);
w.writeUint32Big(spawn.second.size());
for (const auto& info : spawn.second)
info.write(w);
}
}
};
template <class IDType>
struct ChildResourceFactory : BigYAML
{ {
Delete _d; Delete _d;
IDType id; IDType id;
@ -895,7 +1180,7 @@ struct ChildGeneratorDesc : BigYAML
size_t binarySize(size_t __isz) const size_t binarySize(size_t __isz) const
{ {
if (id) if (id)
return __isz + 8; return id.binarySize(__isz + 4);
else else
return __isz + 4; return __isz + 4;
} }

View File

@ -6,6 +6,7 @@
#include "SCAN.hpp" #include "SCAN.hpp"
#include "MLVL.hpp" #include "MLVL.hpp"
#include "../DNACommon/TXTR.hpp" #include "../DNACommon/TXTR.hpp"
#include "../DNACommon/PART.hpp"
#include "CMDL.hpp" #include "CMDL.hpp"
#include "ANCS.hpp" #include "ANCS.hpp"
#include "MREA.hpp" #include "MREA.hpp"
@ -281,6 +282,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
return {nullptr, MREA::Extract, {_S(".blend")}, 4, MREA::Name}; return {nullptr, MREA::Extract, {_S(".blend")}, 4, MREA::Name};
case SBIG('MAPA'): case SBIG('MAPA'):
return {nullptr, MAPA::Extract, {_S(".blend")}, 4}; return {nullptr, MAPA::Extract, {_S(".blend")}, 4};
//case SBIG('PART'):
// return {DNAParticle::ExtractGPSM<UniqueID32>, nullptr, {_S(".yaml")}};
} }
return {}; return {};
} }