mirror of https://github.com/OpenMW/openmw.git
Move particle modifiers into a dedicated file
parent
1d05aa2e37
commit
4a88726aba
@ -0,0 +1,95 @@
|
||||
#include "particle.hpp"
|
||||
|
||||
#include "data.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
void NiParticleModifier::read(NIFStream* nif)
|
||||
{
|
||||
mNext.read(nif);
|
||||
if (nif->getVersion() >= NIFStream::generateVersion(3, 3, 0, 13))
|
||||
mController.read(nif);
|
||||
}
|
||||
|
||||
void NiParticleModifier::post(Reader& nif)
|
||||
{
|
||||
mNext.post(nif);
|
||||
mController.post(nif);
|
||||
}
|
||||
|
||||
void NiParticleGrowFade::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleModifier::read(nif);
|
||||
nif->read(mGrowTime);
|
||||
nif->read(mFadeTime);
|
||||
}
|
||||
|
||||
void NiParticleColorModifier::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleModifier::read(nif);
|
||||
|
||||
mData.read(nif);
|
||||
}
|
||||
|
||||
void NiParticleColorModifier::post(Reader& nif)
|
||||
{
|
||||
NiParticleModifier::post(nif);
|
||||
|
||||
mData.post(nif);
|
||||
}
|
||||
|
||||
void NiGravity::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleModifier::read(nif);
|
||||
|
||||
if (nif->getVersion() >= NIFStream::generateVersion(3, 3, 0, 13))
|
||||
nif->read(mDecay);
|
||||
nif->read(mForce);
|
||||
mType = static_cast<ForceType>(nif->get<uint32_t>());
|
||||
nif->read(mPosition);
|
||||
nif->read(mDirection);
|
||||
}
|
||||
|
||||
void NiParticleCollider::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleModifier::read(nif);
|
||||
|
||||
nif->read(mBounceFactor);
|
||||
if (nif->getVersion() >= NIFStream::generateVersion(4, 2, 0, 2))
|
||||
{
|
||||
nif->read(mSpawnOnCollision);
|
||||
nif->read(mDieOnCollision);
|
||||
}
|
||||
}
|
||||
|
||||
void NiPlanarCollider::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleCollider::read(nif);
|
||||
|
||||
nif->read(mExtents);
|
||||
nif->read(mPosition);
|
||||
nif->read(mXVector);
|
||||
nif->read(mYVector);
|
||||
nif->read(mPlaneNormal);
|
||||
nif->read(mPlaneDistance);
|
||||
}
|
||||
|
||||
void NiSphericalCollider::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleCollider::read(nif);
|
||||
|
||||
nif->read(mRadius);
|
||||
nif->read(mCenter);
|
||||
}
|
||||
|
||||
void NiParticleRotation::read(NIFStream* nif)
|
||||
{
|
||||
NiParticleModifier::read(nif);
|
||||
|
||||
nif->read(mRandomInitialAxis);
|
||||
nif->read(mInitialAxis);
|
||||
nif->read(mRotationSpeed);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
#ifndef OPENMW_COMPONENTS_NIF_PARTICLE_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_PARTICLE_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
struct NiParticleModifier : public Record
|
||||
{
|
||||
NiParticleModifierPtr mNext;
|
||||
ControllerPtr mController;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
void post(Reader& nif) override;
|
||||
};
|
||||
|
||||
struct NiParticleGrowFade : public NiParticleModifier
|
||||
{
|
||||
float mGrowTime;
|
||||
float mFadeTime;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
||||
struct NiParticleColorModifier : public NiParticleModifier
|
||||
{
|
||||
NiColorDataPtr mData;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
void post(Reader& nif) override;
|
||||
};
|
||||
|
||||
struct NiGravity : public NiParticleModifier
|
||||
{
|
||||
enum class ForceType : uint32_t
|
||||
{
|
||||
Wind = 0, // Fixed direction
|
||||
Point = 1, // Fixed origin
|
||||
};
|
||||
|
||||
float mDecay{ 0.f };
|
||||
float mForce;
|
||||
ForceType mType;
|
||||
osg::Vec3f mPosition;
|
||||
osg::Vec3f mDirection;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
||||
struct NiParticleCollider : public NiParticleModifier
|
||||
{
|
||||
float mBounceFactor;
|
||||
bool mSpawnOnCollision{ false };
|
||||
bool mDieOnCollision{ false };
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
||||
// NiPinaColada
|
||||
struct NiPlanarCollider : public NiParticleCollider
|
||||
{
|
||||
osg::Vec2f mExtents;
|
||||
osg::Vec3f mPosition;
|
||||
osg::Vec3f mXVector, mYVector;
|
||||
osg::Vec3f mPlaneNormal;
|
||||
float mPlaneDistance;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
||||
struct NiSphericalCollider : public NiParticleCollider
|
||||
{
|
||||
float mRadius;
|
||||
osg::Vec3f mCenter;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
||||
struct NiParticleRotation : public NiParticleModifier
|
||||
{
|
||||
uint8_t mRandomInitialAxis;
|
||||
osg::Vec3f mInitialAxis;
|
||||
float mRotationSpeed;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue