diff --git a/DataSpec/DNACommon/PART.hpp b/DataSpec/DNACommon/PART.hpp index 0fa298362..62467a0d0 100644 --- a/DataSpec/DNACommon/PART.hpp +++ b/DataSpec/DNACommon/PART.hpp @@ -2,6 +2,7 @@ #define __COMMON_PART_HPP__ #include "ParticleCommon.hpp" +#include "PAK.hpp" namespace Retro { @@ -30,7 +31,7 @@ struct GPSM : BigYAML IntElementFactory x34_LTME; VectorElementFactory x38_ILOC; 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_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; @@ -38,9 +39,9 @@ struct GPSM : BigYAML IntElementFactory x48_MBSP; RealElementFactory x4c_SIZE; RealElementFactory x50_ROTA; - UVElementFactory x54_TEXR; - UVElementFactory x58_TIND; - // x5c_PMDL Model + UVElementFactory x54_TEXR; + UVElementFactory x58_TIND; + ChildResourceFactory x5c_PMDL; VectorElementFactory x6c_PMOP; VectorElementFactory x70_PMRT; VectorElementFactory x74_PMSC; @@ -49,21 +50,21 @@ struct GPSM : BigYAML ModVectorElementFactory x80_VEL2; ModVectorElementFactory x84_VEL3; ModVectorElementFactory x88_VEL4; - ChildGeneratorDesc x8c_ICTS; + ChildResourceFactory x8c_ICTS; IntElementFactory x9c_NCSY; IntElementFactory xb4_NDSY; - ChildGeneratorDesc xb8_IITS; + ChildResourceFactory xb8_IITS; IntElementFactory xa0_CSSD; - ChildGeneratorDesc xa4_IDTS; + ChildResourceFactory xa4_IDTS; IntElementFactory xc8_PISY; IntElementFactory xcc_SISY; - // xd0_KSSM - // xd4_SSWH Swoosh + SpawnSystemKeyframeData xd0_KSSM; + ChildResourceFactory xd4_SSWH; IntElementFactory xe4_SSSD; VectorElementFactory xe8_SSPO; IntElementFactory xf8_SESD; VectorElementFactory xfc_SEPO; - // xec_PMLC Electric Generator + ChildResourceFactory xec_PMLC; IntElementFactory x100_LTYP; ColorElementFactory x104_LCLR; RealElementFactory x108_LINT; @@ -73,355 +74,241 @@ struct GPSM : BigYAML RealElementFactory x118_LFOR; RealElementFactory x11c_LSLA; + /* 0-00 additions */ + bool x30_30_ORNT : 1; + bool xUNK_RSOP : 1; + void read(Athena::io::YAMLDocReader& r) { - if (r.enterSubRecord("PMCL")) - { - x78_PMCL.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LFOR")) - { - x118_LFOR.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("IDTS")) - { - xa4_IDTS.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("EMTR")) - { - //x40_EMTR.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("COLR")) - { - x30_COLR.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("CIND")) - { - x45_7_CIND = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("AAPH")) - { - x44_4_AAPH = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("CSSD")) - { - xa0_CSSD.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("GRTE")) - { - x2c_GRTE.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("FXLL")) - { - x44_6_FXLL = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("ICTS")) - { - x8c_ICTS.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("KSSM")) - { - // xd0_KSSM.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("ILOC")) - { - x38_ILOC.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("IITS")) - { - r.leaveSubRecord(); - } - if (r.enterSubRecord("IVEC")) - { - x3c_IVEC.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LDIR")) - { - x110_LDIR.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LCLR")) - { - x104_LCLR.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LENG")) - { - x20_LENG.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("MAXP")) - { - x28_MAXP.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LOFF")) - { - x10c_LOFF.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LINT")) - { - x108_LINT.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LINE")) - { - x44_2_LINE = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LFOT")) - { - x114_LFOT.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LIT_")) - { - x44_3_LIT_ = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LTME")) - { - x34_LTME.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LSLA")) - { - x11c_LSLA.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("LTYP")) - { - x100_LTYP.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("NDSY")) - { - xb4_NDSY.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("MBSP")) - { - x48_MBSP.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("MBLR")) - { - x44_1_MBLR = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("NCSY")) - { - x9c_NCSY.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PISY")) - { - xc8_PISY.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("OPTS")) - { - x45_4_OPTS = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PMAB")) - { - x44_7_PMAB = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("SESD")) - { - xf8_SESD.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("SEPO")) - { - xfc_SEPO.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PSLT")) - { - xc_PSLT.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PMSC")) - { - x74_PMSC.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PMOP")) - { - x6c_PMOP.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PMDL")) - { - // x5c_PMDL.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PMRT")) - { - x70_PMRT.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("POFS")) - { - x18_POFS.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PMUS")) - { - x45_5_PMUS = r.readBool(nullptr); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PSIV")) - { - x0_PSIV.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("ROTA")) - { - x50_ROTA.read(r); - r.leaveSubRecord(); - } - if (r.enterSubRecord("PSVM")) - { - x4_PSVM.read(r); - r.leaveSubRecord(); - } - 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); + for (const auto& elem : r.getCurNode()->m_mapChildren) + { + if (elem.first.size() < 4) + { + LogModule.report(LogVisor::Warning, "short FourCC in element '%s'", elem.first.c_str()); + continue; + } + + r.enterSubRecord(elem.first.c_str()); + switch (*reinterpret_cast(elem.first.data())) + { + 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'): + x45_7_CIND = r.readBool(nullptr); + break; + case SBIG('AAPH'): + x44_4_AAPH = r.readBool(nullptr); + break; + case SBIG('CSSD'): + xa0_CSSD.read(r); + break; + case SBIG('GRTE'): + x2c_GRTE.read(r); + break; + case SBIG('FXLL'): + x44_6_FXLL = r.readBool(nullptr); + 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'): + x44_2_LINE = r.readBool(nullptr); + break; + case SBIG('LFOT'): + x114_LFOT.read(r); + break; + case SBIG('LIT_'): + x44_3_LIT_ = r.readBool(nullptr); + 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'): + x44_1_MBLR = r.readBool(nullptr); + break; + case SBIG('NCSY'): + x9c_NCSY.read(r); + break; + case SBIG('PISY'): + xc8_PISY.read(r); + break; + case SBIG('OPTS'): + x45_4_OPTS = r.readBool(nullptr); + break; + case SBIG('PMAB'): + x44_7_PMAB = r.readBool(nullptr); + 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'): + x45_5_PMUS = r.readBool(nullptr); + 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'): + x45_6_PMOO = r.readBool(nullptr); + break; + case SBIG('SSSD'): + xe4_SSSD.read(r); + break; + case SBIG('SORT'): + x44_0_SORT = r.readBool(nullptr); + 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'): + x45_0_VMD4 = r.readBool(nullptr); + break; + case SBIG('VMD3'): + x45_1_VMD3 = r.readBool(nullptr); + break; + case SBIG('VMD2'): + x45_2_VMD2 = r.readBool(nullptr); + break; + case SBIG('VMD1'): + x45_3_VMD1 = r.readBool(nullptr); + 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'): + x44_5_ZBUF = r.readBool(nullptr); + break; + case SBIG('WIDT'): + x24_WIDT.read(r); + break; + case SBIG('ORNT'): + x30_30_ORNT = r.readBool(nullptr); + break; + case SBIG('RSOP'): + xUNK_RSOP = r.readBool(nullptr); + break; + default: + break; + } r.leaveSubRecord(); } } @@ -431,11 +318,263 @@ struct GPSM : BigYAML } size_t binarySize(size_t __isz) const { - + /* TODO: Figure out order of emitting */ + return __isz; } 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 { @@ -443,6 +582,21 @@ struct GPSM : BigYAML } }; +template +bool ExtractGPSM(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath) +{ + FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); + if (fp) + { + GPSM gpsm; + gpsm.read(rs); + gpsm.toYAMLFile(fp); + fclose(fp); + return true; + } + return false; +} + } } diff --git a/DataSpec/DNACommon/ParticleCommon.cpp b/DataSpec/DNACommon/ParticleCommon.cpp index e91ed7920..e4f142858 100644 --- a/DataSpec/DNACommon/ParticleCommon.cpp +++ b/DataSpec/DNACommon/ParticleCommon.cpp @@ -4,7 +4,7 @@ namespace Retro { namespace DNAParticle { -static LogVisor::LogModule Log("Retro::ParticleCommon "); +LogVisor::LogModule LogModule("Retro::DNAParticle"); void RealElementFactory::read(Athena::io::YAMLDocReader& r) { @@ -17,7 +17,7 @@ void RealElementFactory::read(Athena::io::YAMLDocReader& r) const auto& elem = mapChildren[0]; 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(elem.first.data())) { @@ -164,7 +164,7 @@ void IntElementFactory::read(Athena::io::YAMLDocReader& r) const auto& elem = mapChildren[0]; 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(elem.first.data())) { @@ -316,7 +316,7 @@ void VectorElementFactory::read(Athena::io::YAMLDocReader& r) const auto& elem = mapChildren[0]; 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(elem.first.data())) { @@ -451,7 +451,7 @@ void ColorElementFactory::read(Athena::io::YAMLDocReader& r) const auto& elem = mapChildren[0]; 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(elem.first.data())) { @@ -556,7 +556,7 @@ void ModVectorElementFactory::read(Athena::io::YAMLDocReader& r) const auto& elem = mapChildren[0]; 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(elem.first.data())) { @@ -683,5 +683,90 @@ void ModVectorElementFactory::write(Athena::io::IStreamWriter& w) const 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(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); +} + } } diff --git a/DataSpec/DNACommon/ParticleCommon.hpp b/DataSpec/DNACommon/ParticleCommon.hpp index ea83718ca..9f46e0060 100644 --- a/DataSpec/DNACommon/ParticleCommon.hpp +++ b/DataSpec/DNACommon/ParticleCommon.hpp @@ -7,6 +7,7 @@ namespace Retro { namespace DNAParticle { +extern LogVisor::LogModule LogModule; struct IElement : BigYAML { @@ -85,6 +86,19 @@ struct ModVectorElementFactory : BigYAML void write(Athena::io::IStreamWriter& w) const; }; +struct IEmitterElement : IElement {Delete _d;}; +struct EmitterElementFactory : BigYAML +{ + Delete _d; + std::unique_ptr 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 RELifetimeTween : IRealElement @@ -601,6 +615,82 @@ struct MVESwirl : IModVectorElement 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 struct UVEConstant : IUVElement { @@ -631,7 +721,7 @@ struct UVEConstant : IUVElement size_t binarySize(size_t __isz) const { if (tex) - return __isz + 8; + return tex.binarySize(__isz + 4); else return __isz + 4; } @@ -653,6 +743,7 @@ struct UVEConstant : IUVElement else w.writeBytes((atInt8*)"NONE", 4); } + const char* ClassID() const {return "CNST";} }; template @@ -742,7 +833,7 @@ struct UVEAnimTexture : IUVElement { __isz += 8; if (tex) - __isz += 4; + __isz = tex.binarySize(__isz); __isz = a.binarySize(__isz); __isz = b.binarySize(__isz); __isz = c.binarySize(__isz); @@ -794,6 +885,7 @@ struct UVEAnimTexture : IUVElement else w.writeBytes((atInt8*)"NONE", 4); } + const char* ClassID() const {return "ATEX";} }; template @@ -870,7 +962,200 @@ struct UVElementFactory : BigYAML }; template -struct ChildGeneratorDesc : BigYAML +struct SpawnSystemKeyframeData : BigYAML +{ + Delete _d; + Value a; + Value b; + Value c; + Value d; + + struct SpawnSystemKeyframeInfo : BigYAML + { + Delete _d; + IDType id; + Value a; + Value b; + Value 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>> 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 +struct ChildResourceFactory : BigYAML { Delete _d; IDType id; @@ -895,7 +1180,7 @@ struct ChildGeneratorDesc : BigYAML size_t binarySize(size_t __isz) const { if (id) - return __isz + 8; + return id.binarySize(__isz + 4); else return __isz + 4; } diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index 90dce3df1..dcc555c3d 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -6,6 +6,7 @@ #include "SCAN.hpp" #include "MLVL.hpp" #include "../DNACommon/TXTR.hpp" +#include "../DNACommon/PART.hpp" #include "CMDL.hpp" #include "ANCS.hpp" #include "MREA.hpp" @@ -281,6 +282,8 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry) return {nullptr, MREA::Extract, {_S(".blend")}, 4, MREA::Name}; case SBIG('MAPA'): return {nullptr, MAPA::Extract, {_S(".blend")}, 4}; + //case SBIG('PART'): + // return {DNAParticle::ExtractGPSM, nullptr, {_S(".yaml")}}; } return {}; }