Turn all NIF records into structs

pull/593/head
Alexei Dobrohotov 4 years ago
parent 4490f89a3d
commit 1e6156e04a

@ -11,9 +11,8 @@
namespace Nif namespace Nif
{ {
// An extra data record. All the extra data connected to an object form a linked list. // An extra data record. All the extra data connected to an object form a linked list.
class Extra : public Record struct Extra : public Record
{ {
public:
std::string name; std::string name;
ExtraPtr next; // Next extra data record in the list ExtraPtr next; // Next extra data record in the list
@ -31,9 +30,8 @@ public:
void post(NIFFile *nif) override { next.post(nif); } void post(NIFFile *nif) override { next.post(nif); }
}; };
class Controller : public Record struct Controller : public Record
{ {
public:
ControllerPtr next; ControllerPtr next;
int flags; int flags;
float frequency, phase; float frequency, phase;
@ -45,9 +43,8 @@ public:
}; };
/// Has name, extra-data and controller /// Has name, extra-data and controller
class Named : public Record struct Named : public Record
{ {
public:
std::string name; std::string name;
ExtraPtr extra; ExtraPtr extra;
ExtraList extralist; ExtraList extralist;

@ -29,9 +29,8 @@
namespace Nif namespace Nif
{ {
class NiSourceTexture : public Named struct NiSourceTexture : public Named
{ {
public:
// Is this an external (references a separate texture file) or // Is this an external (references a separate texture file) or
// internal (data is inside the nif itself) texture? // internal (data is inside the nif itself) texture?
bool external; bool external;
@ -93,27 +92,24 @@ struct NiParticleModifier : public Record
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiParticleGrowFade : public NiParticleModifier struct NiParticleGrowFade : public NiParticleModifier
{ {
public:
float growTime; float growTime;
float fadeTime; float fadeTime;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiParticleColorModifier : public NiParticleModifier struct NiParticleColorModifier : public NiParticleModifier
{ {
public:
NiColorDataPtr data; NiColorDataPtr data;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiGravity : public NiParticleModifier struct NiGravity : public NiParticleModifier
{ {
public:
float mForce; float mForce;
/* 0 - Wind (fixed direction) /* 0 - Wind (fixed direction)
* 1 - Point (fixed origin) * 1 - Point (fixed origin)
@ -133,27 +129,24 @@ struct NiParticleCollider : public NiParticleModifier
}; };
// NiPinaColada // NiPinaColada
class NiPlanarCollider : public NiParticleCollider struct NiPlanarCollider : public NiParticleCollider
{ {
public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
osg::Vec3f mPlaneNormal; osg::Vec3f mPlaneNormal;
float mPlaneDistance; float mPlaneDistance;
}; };
class NiSphericalCollider : public NiParticleCollider struct NiSphericalCollider : public NiParticleCollider
{ {
public:
float mRadius; float mRadius;
osg::Vec3f mCenter; osg::Vec3f mCenter;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiParticleRotation : public NiParticleModifier struct NiParticleRotation : public NiParticleModifier
{ {
public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };

@ -29,9 +29,8 @@
namespace Nif namespace Nif
{ {
class NiParticleSystemController : public Controller struct NiParticleSystemController : public Controller
{ {
public:
struct Particle { struct Particle {
osg::Vec3f velocity; osg::Vec3f velocity;
float lifetime; float lifetime;
@ -80,9 +79,8 @@ public:
}; };
using NiBSPArrayController = NiParticleSystemController; using NiBSPArrayController = NiParticleSystemController;
class NiMaterialColorController : public Controller struct NiMaterialColorController : public Controller
{ {
public:
NiPoint3InterpolatorPtr interpolator; NiPoint3InterpolatorPtr interpolator;
NiPosDataPtr data; NiPosDataPtr data;
unsigned int targetColor; unsigned int targetColor;
@ -91,9 +89,8 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiPathController : public Controller struct NiPathController : public Controller
{ {
public:
NiPosDataPtr posData; NiPosDataPtr posData;
NiFloatDataPtr floatData; NiFloatDataPtr floatData;
@ -115,9 +112,8 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiLookAtController : public Controller struct NiLookAtController : public Controller
{ {
public:
NodePtr target; NodePtr target;
unsigned short lookAtFlags{0}; unsigned short lookAtFlags{0};
@ -125,9 +121,8 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiUVController : public Controller struct NiUVController : public Controller
{ {
public:
NiUVDataPtr data; NiUVDataPtr data;
unsigned int uvSet; unsigned int uvSet;
@ -135,9 +130,8 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiKeyframeController : public Controller struct NiKeyframeController : public Controller
{ {
public:
NiKeyframeDataPtr data; NiKeyframeDataPtr data;
NiTransformInterpolatorPtr interpolator; NiTransformInterpolatorPtr interpolator;
@ -154,12 +148,11 @@ struct NiFloatInterpController : public Controller
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiAlphaController : public NiFloatInterpController { }; struct NiAlphaController : public NiFloatInterpController { };
class NiRollController : public NiFloatInterpController { }; struct NiRollController : public NiFloatInterpController { };
class NiGeomMorpherController : public Controller struct NiGeomMorpherController : public Controller
{ {
public:
NiMorphDataPtr data; NiMorphDataPtr data;
NiFloatInterpolatorList interpolators; NiFloatInterpolatorList interpolators;
@ -167,18 +160,16 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiVisController : public Controller struct NiVisController : public Controller
{ {
public:
NiVisDataPtr data; NiVisDataPtr data;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiFlipController : public Controller struct NiFlipController : public Controller
{ {
public:
NiFloatInterpolatorPtr mInterpolator; NiFloatInterpolatorPtr mInterpolator;
int mTexSlot; // NiTexturingProperty::TextureType int mTexSlot; // NiTexturingProperty::TextureType
float mDelta; // Time between two flips. delta = (start_time - stop_time) / num_sources float mDelta; // Time between two flips. delta = (start_time - stop_time) / num_sources

@ -32,9 +32,8 @@ namespace Nif
{ {
// Common ancestor for several data classes // Common ancestor for several data classes
class NiGeometryData : public Record struct NiGeometryData : public Record
{ {
public:
std::vector<osg::Vec3f> vertices, normals, tangents, bitangents; std::vector<osg::Vec3f> vertices, normals, tangents, bitangents;
std::vector<osg::Vec4f> colors; std::vector<osg::Vec4f> colors;
std::vector< std::vector<osg::Vec2f> > uvlist; std::vector< std::vector<osg::Vec2f> > uvlist;
@ -44,18 +43,16 @@ public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiTriShapeData : public NiGeometryData struct NiTriShapeData : public NiGeometryData
{ {
public:
// Triangles, three vertex indices per triangle // Triangles, three vertex indices per triangle
std::vector<unsigned short> triangles; std::vector<unsigned short> triangles;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiTriStripsData : public NiGeometryData struct NiTriStripsData : public NiGeometryData
{ {
public:
// Triangle strips, series of vertex indices. // Triangle strips, series of vertex indices.
std::vector<std::vector<unsigned short>> strips; std::vector<std::vector<unsigned short>> strips;
@ -70,9 +67,8 @@ struct NiLinesData : public NiGeometryData
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiParticlesData : public NiGeometryData struct NiParticlesData : public NiGeometryData
{ {
public:
int numParticles{0}; int numParticles{0};
int activeCount; int activeCount;
@ -84,39 +80,34 @@ public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiRotatingParticlesData : public NiParticlesData struct NiRotatingParticlesData : public NiParticlesData
{ {
public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiPosData : public Record struct NiPosData : public Record
{ {
public:
Vector3KeyMapPtr mKeyList; Vector3KeyMapPtr mKeyList;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiUVData : public Record struct NiUVData : public Record
{ {
public:
FloatKeyMapPtr mKeyList[4]; FloatKeyMapPtr mKeyList[4];
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiFloatData : public Record struct NiFloatData : public Record
{ {
public:
FloatKeyMapPtr mKeyList; FloatKeyMapPtr mKeyList;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiPixelData : public Record struct NiPixelData : public Record
{ {
public:
enum Format enum Format
{ {
NIPXFMT_RGB8, NIPXFMT_RGB8,
@ -150,17 +141,15 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiColorData : public Record struct NiColorData : public Record
{ {
public:
Vector4KeyMapPtr mKeyMap; Vector4KeyMapPtr mKeyMap;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiVisData : public Record struct NiVisData : public Record
{ {
public:
struct VisData { struct VisData {
float time; float time;
bool isSet; bool isSet;
@ -170,9 +159,8 @@ public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiSkinInstance : public Record struct NiSkinInstance : public Record
{ {
public:
NiSkinDataPtr data; NiSkinDataPtr data;
NiSkinPartitionPtr partitions; NiSkinPartitionPtr partitions;
NodePtr root; NodePtr root;
@ -182,9 +170,8 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiSkinData : public Record struct NiSkinData : public Record
{ {
public:
struct VertWeight struct VertWeight
{ {
unsigned short vertex; unsigned short vertex;
@ -251,9 +238,8 @@ struct NiKeyframeData : public Record
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiPalette : public Record struct NiPalette : public Record
{ {
public:
// 32-bit RGBA colors that correspond to 8-bit indices // 32-bit RGBA colors that correspond to 8-bit indices
std::vector<unsigned int> colors; std::vector<unsigned int> colors;

@ -29,15 +29,13 @@
namespace Nif namespace Nif
{ {
class NiVertWeightsExtraData : public Extra struct NiVertWeightsExtraData : public Extra
{ {
public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiTextKeyExtraData : public Extra struct NiTextKeyExtraData : public Extra
{ {
public:
struct TextKey struct TextKey
{ {
float time; float time;
@ -48,9 +46,8 @@ public:
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
}; };
class NiStringExtraData : public Extra struct NiStringExtraData : public Extra
{ {
public:
/* Two known meanings: /* Two known meanings:
"MRK" - marker, only visible in the editor, not rendered in-game "MRK" - marker, only visible in the editor, not rendered in-game
"NCO" - no collision "NCO" - no collision

@ -131,9 +131,8 @@ struct NiBoundingVolume
parent node (unless it's the root), and transformation (location parent node (unless it's the root), and transformation (location
and rotation) relative to it's parent. and rotation) relative to it's parent.
*/ */
class Node : public Named struct Node : public Named
{ {
public:
// Node flags. Interpretation depends somewhat on the type of node. // Node flags. Interpretation depends somewhat on the type of node.
unsigned int flags; unsigned int flags;
Transformation trafo; Transformation trafo;

@ -29,11 +29,10 @@
namespace Nif namespace Nif
{ {
class Property : public Named { }; struct Property : public Named { };
class NiTexturingProperty : public Property struct NiTexturingProperty : public Property
{ {
public:
unsigned short flags{0u}; unsigned short flags{0u};
// A sub-texture // A sub-texture
@ -96,9 +95,8 @@ public:
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
class NiFogProperty : public Property struct NiFogProperty : public Property
{ {
public:
unsigned short mFlags; unsigned short mFlags;
float mFogDepth; float mFogDepth;
osg::Vec3f mColour; osg::Vec3f mColour;
@ -307,8 +305,8 @@ struct S_StencilProperty
void read(NIFStream *nif); void read(NIFStream *nif);
}; };
class NiAlphaProperty : public StructPropT<S_AlphaProperty> { }; struct NiAlphaProperty : public StructPropT<S_AlphaProperty> { };
class NiVertexColorProperty : public StructPropT<S_VertexColorProperty> { }; struct NiVertexColorProperty : public StructPropT<S_VertexColorProperty> { };
struct NiStencilProperty : public Property struct NiStencilProperty : public Property
{ {
S_StencilProperty data; S_StencilProperty data;

@ -120,24 +120,24 @@ public:
}; };
class Node; struct Node;
class Extra; struct Extra;
class Property; struct Property;
class NiUVData; struct NiUVData;
class NiPosData; struct NiPosData;
class NiVisData; struct NiVisData;
class Controller; struct Controller;
class Named; struct Named;
class NiSkinData; struct NiSkinData;
class NiFloatData; struct NiFloatData;
struct NiMorphData; struct NiMorphData;
class NiPixelData; struct NiPixelData;
class NiColorData; struct NiColorData;
struct NiKeyframeData; struct NiKeyframeData;
class NiTriStripsData; struct NiTriStripsData;
class NiSkinInstance; struct NiSkinInstance;
class NiSourceTexture; struct NiSourceTexture;
class NiPalette; struct NiPalette;
struct NiParticleModifier; struct NiParticleModifier;
struct NiBoolData; struct NiBoolData;
struct NiSkinPartition; struct NiSkinPartition;
@ -147,7 +147,7 @@ struct NiTransformInterpolator;
struct BSShaderTextureSet; struct BSShaderTextureSet;
struct NiGeometryData; struct NiGeometryData;
struct BSShaderProperty; struct BSShaderProperty;
class NiAlphaProperty; struct NiAlphaProperty;
using NodePtr = RecordPtrT<Node>; using NodePtr = RecordPtrT<Node>;
using ExtraPtr = RecordPtrT<Extra>; using ExtraPtr = RecordPtrT<Extra>;

@ -14,10 +14,10 @@
namespace Nif namespace Nif
{ {
class NiGravity; struct NiGravity;
class NiPlanarCollider; struct NiPlanarCollider;
class NiSphericalCollider; struct NiSphericalCollider;
class NiColorData; struct NiColorData;
} }
namespace NifOsg namespace NifOsg

Loading…
Cancel
Save