1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 21:59:55 +00:00
openmw/components/nif/controller.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

298 lines
7.8 KiB
C++
Raw Normal View History

2010-01-07 18:52:11 +00:00
/*
OpenMW - The completely unofficial reimplementation of Morrowind
Copyright (C) 2008-2010 Nicolay Korslund
Email: < korslund@gmail.com >
WWW: https://openmw.org/
2010-01-07 18:52:11 +00:00
This file (controller.h) is part of the OpenMW package.
OpenMW is distributed as free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
version 3, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
version 3 along with this program. If not, see
https://www.gnu.org/licenses/ .
2010-01-07 18:52:11 +00:00
*/
#ifndef OPENMW_COMPONENTS_NIF_CONTROLLER_HPP
#define OPENMW_COMPONENTS_NIF_CONTROLLER_HPP
2010-01-07 18:52:11 +00:00
#include "base.hpp"
2010-01-07 18:52:11 +00:00
namespace Nif
{
2022-09-14 21:58:10 +00:00
// Base class for controllers that use NiInterpolators to animate objects.
struct NiInterpController : public Controller
{
// Usually one of the flags.
bool mManagerControlled{ false };
void read(NIFStream* nif) override;
};
// Base class for controllers that use one NiInterpolator.
struct NiSingleInterpController : public NiInterpController
{
NiInterpolatorPtr mInterpolator;
2020-12-15 22:06:05 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2022-06-21 21:43:16 +00:00
};
2013-04-04 08:26:57 +00:00
// Base class for controllers that use a NiFloatInterpolator to animate their target.
struct NiFloatInterpController : public NiSingleInterpController
{
};
2013-04-04 03:56:35 +00:00
// Ditto for NiBoolInterpolator.
struct NiBoolInterpController : public NiSingleInterpController
{
};
2013-04-04 03:56:35 +00:00
// Ditto for NiPoint3Interpolator.
struct NiPoint3InterpController : public NiSingleInterpController
2022-09-22 18:26:05 +00:00
{
2013-04-04 03:56:35 +00:00
};
2013-04-04 08:26:57 +00:00
struct NiParticleSystemController : public Controller
2022-09-22 18:26:05 +00:00
{
2022-06-21 21:43:16 +00:00
enum BSPArrayController
2022-09-22 18:26:05 +00:00
{
2022-06-21 21:43:16 +00:00
BSPArrayController_AtNode = 0x8,
BSPArrayController_AtVertex = 0x10
2022-09-22 18:26:05 +00:00
};
2013-04-04 08:26:57 +00:00
struct Particle
2022-09-22 18:26:05 +00:00
{
2015-02-17 16:08:55 +00:00
osg::Vec3f velocity;
2013-04-04 08:26:57 +00:00
float lifetime;
float lifespan;
float timestamp;
2020-12-12 23:46:33 +00:00
unsigned short vertex;
2022-09-22 18:26:05 +00:00
};
2013-04-04 03:56:35 +00:00
float velocity;
float velocityRandom;
2022-09-22 18:26:05 +00:00
2013-04-04 03:56:35 +00:00
float verticalDir; // 0=up, pi/2=horizontal, pi=down
float verticalAngle;
float horizontalDir;
float horizontalAngle;
2022-09-22 18:26:05 +00:00
2013-04-04 08:26:57 +00:00
osg::Vec4f color;
2013-04-04 03:56:35 +00:00
float size;
float startTime;
2013-04-04 08:26:57 +00:00
float stopTime;
2022-09-22 18:26:05 +00:00
2013-04-04 03:56:35 +00:00
float emitRate;
float lifetime;
float lifetimeRandom;
enum EmitFlags
2022-09-22 18:26:05 +00:00
{
EmitFlag_NoAutoAdjust = 0x1 // If this flag is set, we use the emitRate value. Otherwise,
// we calculate an emit rate so that the maximum number of particles
// in the system (numParticles) is never exceeded.
2022-09-22 18:26:05 +00:00
};
int emitFlags;
2013-04-04 03:56:35 +00:00
osg::Vec3f offsetRandom;
2022-06-21 21:43:16 +00:00
NodePtr emitter;
2010-01-07 18:52:11 +00:00
int numParticles;
int activeCount;
std::vector<Particle> particles;
NiParticleModifierPtr affectors;
NiParticleModifierPtr colliders;
2010-01-07 18:52:11 +00:00
2020-12-15 22:06:05 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
bool noAutoAdjust() const { return emitFlags & EmitFlag_NoAutoAdjust; }
bool emitAtVertex() const { return flags & BSPArrayController_AtVertex; }
};
2020-02-02 14:08:17 +00:00
using NiBSPArrayController = NiParticleSystemController;
struct NiMaterialColorController : public NiPoint3InterpController
2022-09-22 18:26:05 +00:00
{
NiPosDataPtr mData;
unsigned int mTargetColor;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2010-01-07 18:52:11 +00:00
};
2020-12-15 22:06:05 +00:00
struct NiPathController : public Controller
{
NiPosDataPtr posData;
NiFloatDataPtr floatData;
2022-09-22 18:26:05 +00:00
enum Flags
2022-09-22 18:26:05 +00:00
{
Flag_OpenCurve = 0x020,
Flag_AllowFlip = 0x040,
Flag_Bank = 0x080,
Flag_ConstVelocity = 0x100,
Flag_Follow = 0x200,
Flag_FlipFollowAxis = 0x400
};
2022-09-22 18:26:05 +00:00
int bankDir;
float maxBankAngle, smoothing;
short followAxis;
2022-09-22 18:26:05 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2022-09-22 18:26:05 +00:00
};
struct NiLookAtController : public Controller
2022-09-22 18:26:05 +00:00
{
NodePtr target;
unsigned short lookAtFlags{ 0 };
2020-12-15 22:06:05 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2019-10-05 12:02:42 +00:00
};
2010-01-07 18:52:11 +00:00
struct NiUVController : public Controller
2022-09-22 18:26:05 +00:00
{
NiUVDataPtr data;
2010-01-07 18:52:11 +00:00
unsigned int uvSet;
2022-09-14 21:58:10 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2022-09-14 21:58:10 +00:00
};
struct NiKeyframeController : public NiSingleInterpController
2022-09-22 18:26:05 +00:00
{
NiKeyframeDataPtr mData;
2010-01-07 18:52:11 +00:00
2022-09-14 21:58:10 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2022-09-02 02:55:07 +00:00
};
struct NiMultiTargetTransformController : public NiInterpController
2022-09-22 18:26:05 +00:00
{
2022-09-02 02:55:07 +00:00
NodeList mExtraTargets;
2022-09-14 21:58:10 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2022-09-14 21:58:10 +00:00
};
struct NiAlphaController : public NiFloatInterpController
2022-09-22 18:26:05 +00:00
{
NiFloatDataPtr mData;
2010-01-07 18:52:11 +00:00
2022-09-14 21:58:10 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2022-09-14 21:58:10 +00:00
};
struct NiRollController : public NiSingleInterpController
2022-09-22 18:26:05 +00:00
{
2022-09-14 21:58:10 +00:00
NiFloatDataPtr mData;
2022-09-14 21:58:10 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
2022-09-14 21:58:10 +00:00
struct NiGeomMorpherController : public NiInterpController
2022-09-22 18:26:05 +00:00
{
bool mUpdateNormals{ false };
bool mAlwaysActive{ false };
NiMorphDataPtr mData;
NiInterpolatorList mInterpolators;
std::vector<float> mWeights;
2022-09-22 18:26:05 +00:00
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2010-01-07 18:52:11 +00:00
};
2022-09-14 21:58:10 +00:00
struct NiVisController : public NiBoolInterpController
2010-01-07 18:52:11 +00:00
{
2022-09-14 21:58:10 +00:00
NiVisDataPtr mData;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2010-01-07 18:52:11 +00:00
};
2022-09-14 21:58:10 +00:00
struct NiFlipController : public NiFloatInterpController
2013-04-19 22:07:08 +00:00
{
2013-12-08 17:51:56 +00:00
int mTexSlot; // NiTexturingProperty::TextureType
2013-04-19 22:07:08 +00:00
float mDelta; // Time between two flips. delta = (start_time - stop_time) / num_sources
NiSourceTextureList mSources;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
2013-04-19 22:07:08 +00:00
};
struct bhkBlendController : public Controller
{
void read(NIFStream* nif) override;
};
2021-11-10 16:42:55 +00:00
struct NiControllerManager : public Controller
{
bool mCumulative;
2021-11-10 16:42:55 +00:00
void read(NIFStream* nif) override;
};
2022-09-14 21:58:10 +00:00
struct NiInterpolator : public Record
{
};
2022-09-14 21:58:10 +00:00
struct NiPoint3Interpolator : public NiInterpolator
{
osg::Vec3f defaultVal;
NiPosDataPtr data;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
2022-09-14 21:58:10 +00:00
struct NiBoolInterpolator : public NiInterpolator
{
2022-09-14 21:58:10 +00:00
char defaultVal;
NiBoolDataPtr data;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
2022-09-14 21:58:10 +00:00
struct NiFloatInterpolator : public NiInterpolator
{
float defaultVal;
NiFloatDataPtr data;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
2022-09-14 21:58:10 +00:00
struct NiTransformInterpolator : public NiInterpolator
{
osg::Vec3f defaultPos;
osg::Quat defaultRot;
float defaultScale;
NiKeyframeDataPtr data;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
2022-09-14 21:58:10 +00:00
struct NiColorInterpolator : public NiInterpolator
{
osg::Vec4f defaultVal;
NiColorDataPtr data;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
2010-01-07 18:52:11 +00:00
} // Namespace
#endif