1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 10:23:56 +00:00
openmw/components/nif/data.hpp

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

285 lines
6.8 KiB
C++
Raw Normal View History

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