1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 18:45:38 +00:00

Read particle system modifier controllers

This commit is contained in:
Alexei Kotov 2023-09-21 13:09:33 +03:00
parent dddfbf806b
commit c8307ad397
5 changed files with 117 additions and 2 deletions

View file

@ -276,7 +276,33 @@ namespace Nif
{ "NiParticleGrowFade", &construct<NiParticleGrowFade, RC_NiParticleGrowFade> },
{ "NiParticleRotation", &construct<NiParticleRotation, RC_NiParticleRotation> },
// Modifier data, Gamebryo
// Modifier controllers, Gamebryo
{ "NiPSysAirFieldAirFrictionCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysAirFieldAirFrictionCtlr> },
{ "NiPSysAirFieldInheritVelocityCtlr",
&construct<NiPSysModifierFloatCtlr, RC_NiPSysAirFieldInheritVelocityCtlr> },
{ "NiPSysAirFieldSpreadCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysAirFieldSpreadCtlr> },
{ "NiPSysEmitterCtlr", &construct<NiPSysEmitterCtlr, RC_NiPSysEmitterCtlr> },
{ "NiPSysEmitterDeclinationCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterDeclinationCtlr> },
{ "NiPSysEmitterDeclinationVarCtlr",
&construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterDeclinationVarCtlr> },
{ "NiPSysEmitterInitialRadiusCtlr",
&construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterInitialRadiusCtlr> },
{ "NiPSysEmitterLifeSpanCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterLifeSpanCtlr> },
{ "NiPSysEmitterPlanarAngleCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterPlanarAngleCtlr> },
{ "NiPSysEmitterPlanarAngleVarCtlr",
&construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterPlanarAngleVarCtlr> },
{ "NiPSysEmitterSpeedCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysEmitterSpeedCtlr> },
{ "NiPSysFieldAttenuationCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysFieldAttenuationCtlr> },
{ "NiPSysFieldMagnitudeCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysFieldMagnitudeCtlr> },
{ "NiPSysFieldMaxDistanceCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysFieldMaxDistanceCtlr> },
{ "NiPSysGravityStrengthCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysGravityStrengthCtlr> },
{ "NiPSysInitialRotSpeedCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotSpeedCtlr> },
{ "NiPSysInitialRotSpeedVarCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotSpeedVarCtlr> },
{ "NiPSysInitialRotAngleCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotAngleCtlr> },
{ "NiPSysInitialRotAngleVarCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotAngleVarCtlr> },
{ "NiPSysModifierActiveCtlr", &construct<NiPSysModifierBoolCtlr, RC_NiPSysModifierActiveCtlr> },
// Modifier controller data, Gamebryo
{ "NiPSysEmitterCtlrData", &construct<NiPSysEmitterCtlrData, RC_NiPSysEmitterCtlrData> },
// Colliders, 4.0.0.2

View file

@ -175,6 +175,31 @@ namespace Nif
}
}
void NiPSysModifierCtlr::read(NIFStream* nif)
{
NiSingleInterpController::read(nif);
nif->read(mModifierName);
}
void NiPSysEmitterCtlr::read(NIFStream* nif)
{
NiPSysModifierCtlr::read(nif);
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 103))
mData.read(nif);
else
mVisInterpolator.read(nif);
}
void NiPSysEmitterCtlr::post(Reader& nif)
{
NiPSysModifierCtlr::post(nif);
mData.post(nif);
mVisInterpolator.post(nif);
}
void NiPSysEmitterCtlrData::read(NIFStream* nif)
{
mFloatKeyList = std::make_shared<FloatKeyMap>();

View file

@ -2,6 +2,7 @@
#define OPENMW_COMPONENTS_NIF_PARTICLE_HPP
#include "base.hpp"
#include "controller.hpp"
#include "data.hpp"
namespace Nif
@ -123,6 +124,47 @@ namespace Nif
void read(NIFStream* nif) override;
};
// Abstract
struct NiPSysModifierCtlr : NiSingleInterpController
{
std::string mModifierName;
void read(NIFStream* nif) override;
};
template <class DataPtr>
struct TypedNiPSysModifierCtlr : NiPSysModifierCtlr
{
DataPtr mData;
void read(NIFStream* nif) override
{
NiPSysModifierCtlr::read(nif);
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 103))
mData.read(nif);
}
void post(Reader& nif) override
{
NiPSysModifierCtlr::post(nif);
mData.post(nif);
}
};
using NiPSysModifierBoolCtlr = TypedNiPSysModifierCtlr<NiVisDataPtr>;
using NiPSysModifierFloatCtlr = TypedNiPSysModifierCtlr<NiFloatDataPtr>;
struct NiPSysEmitterCtlr : NiPSysModifierCtlr
{
NiPSysEmitterCtlrDataPtr mData;
NiInterpolatorPtr mVisInterpolator;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
struct NiPSysEmitterCtlrData : Record
{
FloatKeyMapPtr mFloatKeyList;

View file

@ -169,8 +169,28 @@ namespace Nif
RC_NiPlanarCollider,
RC_NiPoint3Interpolator,
RC_NiPosData,
RC_NiPSysEmitterCtlrData,
RC_NiPSysAirFieldAirFrictionCtlr,
RC_NiPSysAirFieldInheritVelocityCtlr,
RC_NiPSysAirFieldSpreadCtlr,
RC_NiPSysData,
RC_NiPSysEmitterCtlr,
RC_NiPSysEmitterCtlrData,
RC_NiPSysEmitterDeclinationCtlr,
RC_NiPSysEmitterDeclinationVarCtlr,
RC_NiPSysEmitterInitialRadiusCtlr,
RC_NiPSysEmitterLifeSpanCtlr,
RC_NiPSysEmitterPlanarAngleCtlr,
RC_NiPSysEmitterPlanarAngleVarCtlr,
RC_NiPSysEmitterSpeedCtlr,
RC_NiPSysFieldAttenuationCtlr,
RC_NiPSysFieldMagnitudeCtlr,
RC_NiPSysFieldMaxDistanceCtlr,
RC_NiPSysGravityStrengthCtlr,
RC_NiPSysInitialRotSpeedCtlr,
RC_NiPSysInitialRotSpeedVarCtlr,
RC_NiPSysInitialRotAngleCtlr,
RC_NiPSysInitialRotAngleVarCtlr,
RC_NiPSysModifierActiveCtlr,
RC_NiRollController,
RC_NiSequence,
RC_NiSequenceStreamHelper,

View file

@ -129,6 +129,7 @@ namespace Nif
struct NiSourceTexture;
struct NiPalette;
struct NiParticleModifier;
struct NiPSysEmitterCtlrData;
struct NiBoolData;
struct NiSkinPartition;
struct BSShaderTextureSet;
@ -170,6 +171,7 @@ namespace Nif
using NiSourceTexturePtr = RecordPtrT<NiSourceTexture>;
using NiPalettePtr = RecordPtrT<NiPalette>;
using NiParticleModifierPtr = RecordPtrT<NiParticleModifier>;
using NiPSysEmitterCtlrDataPtr = RecordPtrT<NiPSysEmitterCtlrData>;
using NiBoolDataPtr = RecordPtrT<NiBoolData>;
using NiSkinPartitionPtr = RecordPtrT<NiSkinPartition>;
using BSShaderTextureSetPtr = RecordPtrT<BSShaderTextureSet>;