From 8594875ccb85c309750d45c96877fec13649c33d Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 22 Sep 2023 04:11:32 +0300 Subject: [PATCH] Read a few more Gamebryo/Bethesda modifiers --- components/nif/niffile.cpp | 5 ++++ components/nif/particle.cpp | 46 +++++++++++++++++++++++++++++++++++++ components/nif/particle.hpp | 38 ++++++++++++++++++++++++++++++ components/nif/record.hpp | 4 ++++ 4 files changed, 93 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 4f0ce46865..b60bb74594 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -294,11 +294,16 @@ namespace Nif // Modifiers, Gamebryo { "NiPSysAgeDeathModifier", &construct }, + { "NiPSysBoundUpdateModifier", &construct }, { "NiPSysPositionModifier", &construct }, { "NiPSysSpawnModifier", &construct }, // Modifiers, Bethesda + { "BSPSysInheritVelocityModifier", + &construct }, { "BSPSysLODModifier", &construct }, + { "BSPSysScaleModifier", &construct }, + { "BSPSysSimpleColorModifier", &construct }, // Emitters { "NiPSysBoxEmitter", &construct }, diff --git a/components/nif/particle.cpp b/components/nif/particle.cpp index fa386e2b73..f6e4ae9bc8 100644 --- a/components/nif/particle.cpp +++ b/components/nif/particle.cpp @@ -253,6 +253,13 @@ namespace Nif mSpawnModifier.post(nif); } + void NiPSysBoundUpdateModifier::read(NIFStream* nif) + { + NiPSysModifier::read(nif); + + nif->read(mUpdateSkip); + } + void NiPSysSpawnModifier::read(NIFStream* nif) { NiPSysModifier::read(nif); @@ -267,6 +274,23 @@ namespace Nif nif->read(mLifespanVariation); } + void BSPSysInheritVelocityModifier::read(NIFStream* nif) + { + NiPSysModifier::read(nif); + + mInheritObject.read(nif); + nif->read(mInheritChance); + nif->read(mVelocityMult); + nif->read(mVelcoityVariation); + } + + void BSPSysInheritVelocityModifier::post(Reader& nif) + { + NiPSysModifier::post(nif); + + mInheritObject.post(nif); + } + void BSPSysLODModifier::read(NIFStream* nif) { NiPSysModifier::read(nif); @@ -277,6 +301,28 @@ namespace Nif nif->read(mEndSize); } + void BSPSysScaleModifier::read(NIFStream* nif) + { + NiPSysModifier::read(nif); + + nif->readVector(mScales, nif->get()); + } + + void BSPSysSimpleColorModifier::read(NIFStream* nif) + { + NiPSysModifier::read(nif); + + nif->read(mFadeInPercent); + nif->read(mFadeOutPercent); + nif->read(mColor1EndPercent); + nif->read(mColor1StartPercent); + nif->read(mColor2EndPercent); + nif->read(mColor2StartPercent); + nif->readVector(mColors, 3); + if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76) + nif->skip(52); // Unknown + } + void NiPSysEmitter::read(NIFStream* nif) { NiPSysModifier::read(nif); diff --git a/components/nif/particle.hpp b/components/nif/particle.hpp index 55ed84b5ae..e887009a13 100644 --- a/components/nif/particle.hpp +++ b/components/nif/particle.hpp @@ -186,6 +186,13 @@ namespace Nif void post(Reader& nif) override; }; + struct NiPSysBoundUpdateModifier : public NiPSysModifier + { + uint16_t mUpdateSkip; + + void read(NIFStream* nif) override; + }; + struct NiPSysSpawnModifier : NiPSysModifier { uint16_t mNumSpawnGenerations; @@ -200,6 +207,17 @@ namespace Nif void read(NIFStream* nif) override; }; + struct BSPSysInheritVelocityModifier : public NiPSysModifier + { + NiObjectNETPtr mInheritObject; + float mInheritChance; + float mVelocityMult; + float mVelcoityVariation; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + struct BSPSysLODModifier : NiPSysModifier { float mLODStartDistance; @@ -210,6 +228,26 @@ namespace Nif void read(NIFStream* nif) override; }; + struct BSPSysScaleModifier : public NiPSysModifier + { + std::vector mScales; + + void read(NIFStream* nif) override; + }; + + struct BSPSysSimpleColorModifier : NiPSysModifier + { + float mFadeInPercent; + float mFadeOutPercent; + float mColor1EndPercent; + float mColor1StartPercent; + float mColor2EndPercent; + float mColor2StartPercent; + std::vector mColors; + + void read(NIFStream* nif) override; + }; + // Abstract struct NiPSysEmitter : public NiPSysModifier { diff --git a/components/nif/record.hpp b/components/nif/record.hpp index e519a0bcc3..770246aa08 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -94,7 +94,10 @@ namespace Nif RC_BSMultiBoundSphere, RC_BSNiAlphaPropertyTestRefController, RC_BSPackedAdditionalGeometryData, + RC_BSPSysInheritVelocityModifier, RC_BSPSysLODModifier, + RC_BSPSysScaleModifier, + RC_BSPSysSimpleColorModifier, RC_BSStripParticleSystem, RC_BSStripPSysData, RC_BSRefractionFirePeriodController, @@ -188,6 +191,7 @@ namespace Nif RC_NiPSysAirFieldInheritVelocityCtlr, RC_NiPSysAirFieldSpreadCtlr, RC_NiPSysBoxEmitter, + RC_NiPSysBoundUpdateModifier, RC_NiPSysCylinderEmitter, RC_NiPSysData, RC_NiPSysEmitterCtlr,