2010-01-06 16:22:34 +01:00
|
|
|
/*
|
|
|
|
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
|
|
Copyright (C) 2008-2010 Nicolay Korslund
|
|
|
|
Email: < korslund@gmail.com >
|
2018-03-08 21:23:24 +01:00
|
|
|
WWW: https://openmw.org/
|
2010-01-06 16:22:34 +01:00
|
|
|
|
|
|
|
This file (data.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
|
2018-03-08 21:23:24 +01:00
|
|
|
https://www.gnu.org/licenses/ .
|
2010-01-06 16:22:34 +01:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-02-24 13:51:56 -08:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIF_DATA_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIF_DATA_HPP
|
2010-01-06 16:22:34 +01:00
|
|
|
|
2022-07-21 15:51:34 +04:00
|
|
|
#include "nifkey.hpp"
|
2015-02-20 17:56:49 +01:00
|
|
|
#include "niftypes.hpp" // Transformation
|
2022-08-15 23:04:54 +02:00
|
|
|
#include "recordptr.hpp"
|
2015-02-20 17:56:49 +01:00
|
|
|
|
2010-01-06 16:22:34 +01:00
|
|
|
namespace Nif
|
|
|
|
{
|
|
|
|
|
2010-01-06 20:42:32 +01:00
|
|
|
// Common ancestor for several data classes
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiGeometryData : public Record
|
2010-01-06 20:42:32 +01:00
|
|
|
{
|
2020-10-04 01:27:49 +03:00
|
|
|
std::vector<osg::Vec3f> vertices, normals, tangents, bitangents;
|
2017-02-17 07:20:50 +01:00
|
|
|
std::vector<osg::Vec4f> colors;
|
|
|
|
std::vector<std::vector<osg::Vec2f>> uvlist;
|
2015-02-17 17:08:55 +01:00
|
|
|
osg::Vec3f center;
|
2012-07-02 21:41:21 -07:00
|
|
|
float radius;
|
2010-01-06 20:42:32 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-06 20:42:32 +01:00
|
|
|
};
|
|
|
|
|
2023-02-10 23:06:56 +03:00
|
|
|
// Abstract
|
|
|
|
struct NiTriBasedGeomData : public NiGeometryData
|
|
|
|
{
|
|
|
|
size_t mNumTriangles;
|
|
|
|
|
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NiTriShapeData : public NiTriBasedGeomData
|
2010-01-06 20:42:32 +01:00
|
|
|
{
|
2012-07-02 21:41:21 -07:00
|
|
|
// Triangles, three vertex indices per triangle
|
2017-02-17 07:20:50 +01:00
|
|
|
std::vector<unsigned short> triangles;
|
2012-07-02 21:41:21 -07:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-06 20:42:32 +01:00
|
|
|
};
|
|
|
|
|
2023-02-10 23:06:56 +03:00
|
|
|
struct NiTriStripsData : public NiTriBasedGeomData
|
2019-08-08 13:11:24 +03:00
|
|
|
{
|
|
|
|
// Triangle strips, series of vertex indices.
|
|
|
|
std::vector<std::vector<unsigned short>> strips;
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2019-08-08 13:11:24 +03:00
|
|
|
};
|
|
|
|
|
2020-05-30 17:59:36 +03:00
|
|
|
struct NiLinesData : public NiGeometryData
|
|
|
|
{
|
|
|
|
// Lines, series of indices that correspond to connected vertices.
|
|
|
|
std::vector<unsigned short> lines;
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2020-05-30 17:59:36 +03:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiParticlesData : public NiGeometryData
|
2010-01-07 15:51:42 +01:00
|
|
|
{
|
2020-10-04 01:27:49 +03:00
|
|
|
int numParticles{ 0 };
|
2013-04-06 06:44:34 -07:00
|
|
|
|
2021-01-09 13:36:40 +04:00
|
|
|
int activeCount{ 0 };
|
2013-04-03 07:00:24 -07:00
|
|
|
|
2020-10-04 01:27:49 +03:00
|
|
|
std::vector<float> particleRadii, sizes, rotationAngles;
|
|
|
|
std::vector<osg::Quat> rotations;
|
|
|
|
std::vector<osg::Vec3f> rotationAxes;
|
2013-04-03 07:00:24 -07:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-07 15:51:42 +01:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiRotatingParticlesData : public NiParticlesData
|
2010-01-07 15:51:42 +01:00
|
|
|
{
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-07 15:51:42 +01:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiPosData : public Record
|
2010-01-07 15:51:42 +01:00
|
|
|
{
|
2015-03-22 23:47:49 +01:00
|
|
|
Vector3KeyMapPtr mKeyList;
|
2012-07-12 08:00:26 -07:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-07 19:11:03 +01:00
|
|
|
};
|
2010-01-07 15:51:42 +01:00
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiUVData : public Record
|
2010-01-07 15:51:42 +01:00
|
|
|
{
|
2015-03-22 23:47:49 +01:00
|
|
|
FloatKeyMapPtr mKeyList[4];
|
2012-07-12 08:00:26 -07:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-07 15:51:42 +01:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiFloatData : public Record
|
2010-01-07 15:51:42 +01:00
|
|
|
{
|
2015-03-22 23:47:49 +01:00
|
|
|
FloatKeyMapPtr mKeyList;
|
2012-07-12 08:00:26 -07:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-07 15:51:42 +01:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiPixelData : public Record
|
2016-02-15 16:49:58 +01:00
|
|
|
{
|
|
|
|
enum Format
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2016-02-15 16:49:58 +01:00
|
|
|
NIPXFMT_RGB8,
|
|
|
|
NIPXFMT_RGBA8,
|
|
|
|
NIPXFMT_PAL8,
|
2019-08-13 01:20:30 +03:00
|
|
|
NIPXFMT_PALA8,
|
2022-08-17 01:27:41 +03:00
|
|
|
NIPXFMT_BGR8,
|
|
|
|
NIPXFMT_BGRA8,
|
2016-02-15 16:49:58 +01:00
|
|
|
NIPXFMT_DXT1,
|
|
|
|
NIPXFMT_DXT3,
|
2022-08-17 01:27:41 +03:00
|
|
|
NIPXFMT_DXT5
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
2021-01-09 13:36:40 +04:00
|
|
|
Format fmt{ NIPXFMT_RGB8 };
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2021-01-09 13:36:40 +04:00
|
|
|
unsigned int colorMask[4]{ 0 };
|
|
|
|
unsigned int bpp{ 0 }, pixelTiling{ 0 };
|
2020-10-04 01:27:49 +03:00
|
|
|
bool sRGB{ false };
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2019-08-13 01:20:30 +03:00
|
|
|
NiPalettePtr palette;
|
2021-01-09 13:36:40 +04:00
|
|
|
unsigned int numberOfMipmaps{ 0 };
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2016-02-15 16:49:58 +01:00
|
|
|
struct Mipmap
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2016-02-15 16:49:58 +01:00
|
|
|
int width, height;
|
|
|
|
int dataOffset;
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
2016-02-15 16:49:58 +01:00
|
|
|
std::vector<Mipmap> mipmaps;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2016-02-15 16:49:58 +01:00
|
|
|
std::vector<unsigned char> data;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2022-09-17 19:24:42 +02:00
|
|
|
void post(Reader& nif) override;
|
2016-02-15 16:49:58 +01:00
|
|
|
};
|
|
|
|
|
2021-01-09 13:36:40 +04:00
|
|
|
struct NiColorData : public Record
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2021-01-09 13:36:40 +04:00
|
|
|
Vector4KeyMapPtr mKeyMap;
|
2019-08-13 01:20:30 +03:00
|
|
|
|
|
|
|
void read(NIFStream* nif) override;
|
2021-01-09 13:36:40 +04:00
|
|
|
};
|
2010-01-07 15:51:42 +01:00
|
|
|
|
2016-02-15 16:49:58 +01:00
|
|
|
struct NiVisData : public Record
|
|
|
|
{
|
2012-07-10 02:38:35 -07:00
|
|
|
struct VisData
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2016-02-15 16:49:58 +01:00
|
|
|
float time;
|
|
|
|
bool isSet;
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
2016-02-15 16:49:58 +01:00
|
|
|
std::vector<VisData> mVis;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2016-02-15 16:49:58 +01:00
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
2012-07-02 21:41:21 -07:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
struct NiSkinInstance : public Record
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2012-07-02 21:41:21 -07:00
|
|
|
NiSkinDataPtr data;
|
2020-11-07 04:04:46 +03:00
|
|
|
NiSkinPartitionPtr partitions;
|
2020-10-16 22:18:54 +04:00
|
|
|
NodePtr root;
|
2010-01-07 15:51:42 +01:00
|
|
|
NodeList bones;
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
void read(NIFStream* nif) override;
|
2022-09-17 19:24:42 +02:00
|
|
|
void post(Reader& nif) override;
|
2012-07-10 02:38:35 -07:00
|
|
|
};
|
|
|
|
|
2021-11-10 19:40:02 +03:00
|
|
|
struct BSDismemberSkinInstance : public NiSkinInstance
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2010-01-07 15:51:42 +01:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiSkinData : public Record
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2020-12-16 01:06:05 +03:00
|
|
|
struct VertWeight
|
2010-01-24 15:17:50 +01:00
|
|
|
{
|
2015-04-21 20:56:16 +02:00
|
|
|
unsigned short vertex;
|
2012-07-02 21:41:21 -07:00
|
|
|
float weight;
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
struct BoneInfo
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2020-11-07 04:04:46 +03:00
|
|
|
Transformation trafo;
|
2012-07-02 21:41:21 -07:00
|
|
|
osg::Vec3f boundSphereCenter;
|
|
|
|
float boundSphereRadius;
|
|
|
|
std::vector<VertWeight> weights;
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
2010-01-24 15:17:50 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Transformation trafo;
|
|
|
|
std::vector<BoneInfo> bones;
|
|
|
|
NiSkinPartitionPtr partitions;
|
2010-01-24 15:17:50 +01:00
|
|
|
|
2021-11-10 19:40:02 +03:00
|
|
|
void read(NIFStream* nif) override;
|
2022-09-17 19:24:42 +02:00
|
|
|
void post(Reader& nif) override;
|
2021-11-10 19:40:02 +03:00
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiSkinPartition : public Record
|
2012-07-02 21:41:21 -07:00
|
|
|
{
|
2015-04-21 20:56:16 +02:00
|
|
|
struct Partition
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2020-11-07 04:04:46 +03:00
|
|
|
std::vector<unsigned short> bones;
|
2015-04-21 20:56:16 +02:00
|
|
|
std::vector<unsigned short> vertexMap;
|
2012-07-02 21:41:21 -07:00
|
|
|
std::vector<float> weights;
|
2020-11-07 04:04:46 +03:00
|
|
|
std::vector<std::vector<unsigned short>> strips;
|
|
|
|
std::vector<unsigned short> triangles;
|
|
|
|
std::vector<char> boneIndices;
|
|
|
|
void read(NIFStream* nif);
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
2020-11-07 04:04:46 +03:00
|
|
|
std::vector<Partition> data;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void read(NIFStream* nif) override;
|
2012-07-02 21:41:21 -07:00
|
|
|
};
|
2012-07-10 02:38:35 -07:00
|
|
|
|
2012-07-02 21:41:21 -07:00
|
|
|
struct NiMorphData : public Record
|
|
|
|
{
|
2015-02-20 17:56:49 +01:00
|
|
|
struct MorphData
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2015-02-20 17:56:49 +01:00
|
|
|
FloatKeyMapPtr mKeyFrames;
|
2015-03-26 23:15:46 +01:00
|
|
|
std::vector<osg::Vec3f> mVertices;
|
|
|
|
};
|
2012-07-09 20:53:54 -07:00
|
|
|
std::vector<MorphData> mMorphs;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2012-07-09 20:53:54 -07:00
|
|
|
void read(NIFStream* nif) override;
|
2012-07-02 21:41:21 -07:00
|
|
|
};
|
2010-01-24 13:49:38 +01:00
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
struct NiKeyframeData : public Record
|
|
|
|
{
|
2015-03-22 23:47:49 +01:00
|
|
|
QuaternionKeyMapPtr mRotations;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
// may be NULL
|
|
|
|
FloatKeyMapPtr mXRotations;
|
2015-03-22 23:47:49 +01:00
|
|
|
FloatKeyMapPtr mYRotations;
|
|
|
|
FloatKeyMapPtr mZRotations;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
Vector3KeyMapPtr mTranslations;
|
|
|
|
FloatKeyMapPtr mScales;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
enum class AxisOrder
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2022-02-18 20:47:34 +03:00
|
|
|
Order_XYZ = 0,
|
|
|
|
Order_XZY = 1,
|
|
|
|
Order_YZX = 2,
|
|
|
|
Order_YXZ = 3,
|
|
|
|
Order_ZXY = 4,
|
|
|
|
Order_ZYX = 5,
|
|
|
|
Order_XYX = 6,
|
|
|
|
Order_YZY = 7,
|
|
|
|
Order_ZXZ = 8
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
AxisOrder mAxisOrder{ AxisOrder::Order_XYZ };
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-11-07 04:04:46 +03:00
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
2010-01-07 19:11:03 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
struct NiPalette : public Record
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2020-10-16 22:18:54 +04:00
|
|
|
// 32-bit RGBA colors that correspond to 8-bit indices
|
|
|
|
std::vector<unsigned int> colors;
|
2010-01-07 15:51:42 +01:00
|
|
|
|
2012-07-12 20:55:11 -07:00
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
2014-12-05 20:58:03 +01:00
|
|
|
|
2015-03-22 23:47:49 +01:00
|
|
|
struct NiStringPalette : public Record
|
2022-02-18 20:47:34 +03:00
|
|
|
{
|
2020-11-14 01:12:32 +03:00
|
|
|
std::string palette;
|
2022-02-18 20:47:34 +03:00
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
|
|
|
|
2020-12-16 01:06:05 +03:00
|
|
|
struct NiBoolData : public Record
|
2019-08-13 01:20:30 +03:00
|
|
|
{
|
2020-11-07 03:40:21 +03:00
|
|
|
ByteKeyMapPtr mKeyList;
|
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
|
|
|
|
2023-05-22 22:28:05 +03:00
|
|
|
struct BSMultiBound : public Record
|
|
|
|
{
|
|
|
|
BSMultiBoundDataPtr mData;
|
|
|
|
|
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
void post(Reader& nif) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Abstract
|
|
|
|
struct BSMultiBoundData : public Record
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BSMultiBoundOBB : public BSMultiBoundData
|
|
|
|
{
|
|
|
|
osg::Vec3f mCenter;
|
|
|
|
osg::Vec3f mSize;
|
|
|
|
Nif::Matrix3 mRotation;
|
|
|
|
|
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BSMultiBoundSphere : public BSMultiBoundData
|
|
|
|
{
|
|
|
|
osg::Vec3f mCenter;
|
|
|
|
float mRadius;
|
|
|
|
|
|
|
|
void read(NIFStream* nif) override;
|
|
|
|
};
|
|
|
|
|
2010-01-06 16:22:34 +01:00
|
|
|
} // Namespace
|
|
|
|
#endif
|