1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 16:15:31 +00:00

Add more generic extra data NIF types

This commit is contained in:
Alexei Dobrohotov 2020-10-06 20:52:21 +03:00
parent 302d8eed27
commit df1014303d
4 changed files with 116 additions and 1 deletions

View file

@ -29,6 +29,56 @@ void NiVertWeightsExtraData::read(NIFStream *nif)
nif->skip(nif->getUShort() * sizeof(float)); // vertex weights I guess
}
void NiIntegerExtraData::read(NIFStream *nif)
{
Extra::read(nif);
data = nif->getUInt();
}
void NiIntegersExtraData::read(NIFStream *nif)
{
Extra::read(nif);
unsigned int num = nif->getUInt();
if (num)
nif->getUInts(data, num);
}
void NiBinaryExtraData::read(NIFStream *nif)
{
Extra::read(nif);
unsigned int size = nif->getUInt();
if (size)
nif->getChars(data, size);
}
void NiBooleanExtraData::read(NIFStream *nif)
{
Extra::read(nif);
data = nif->getBoolean();
}
void NiVectorExtraData::read(NIFStream *nif)
{
Extra::read(nif);
data = nif->getVector4();
}
void NiFloatExtraData::read(NIFStream *nif)
{
Extra::read(nif);
data = nif->getFloat();
}
void NiFloatsExtraData::read(NIFStream *nif)
{
Extra::read(nif);
unsigned int num = nif->getUInt();
if (num)
nif->getFloats(data, num);
}
}

View file

@ -60,5 +60,54 @@ public:
void read(NIFStream *nif);
};
struct NiIntegerExtraData : public Extra
{
unsigned int data;
void read(NIFStream *nif);
};
struct NiIntegersExtraData : public Extra
{
std::vector<unsigned int> data;
void read(NIFStream *nif);
};
struct NiBinaryExtraData : public Extra
{
std::vector<char> data;
void read(NIFStream *nif);
};
struct NiBooleanExtraData : public Extra
{
bool data;
void read(NIFStream *nif);
};
struct NiVectorExtraData : public Extra
{
osg::Vec4f data;
void read(NIFStream *nif);
};
struct NiFloatExtraData : public Extra
{
float data;
void read(NIFStream *nif);
};
struct NiFloatsExtraData : public Extra
{
std::vector<float> data;
void read(NIFStream *nif);
};
} // Namespace
#endif

View file

@ -105,6 +105,14 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
factory["NiSkinInstance"] = {&construct <NiSkinInstance> , RC_NiSkinInstance };
factory["NiLookAtController"] = {&construct <NiLookAtController> , RC_NiLookAtController };
factory["NiPalette"] = {&construct <NiPalette> , RC_NiPalette };
factory["NiIntegerExtraData"] = {&construct <NiIntegerExtraData> , RC_NiIntegerExtraData };
factory["NiIntegersExtraData"] = {&construct <NiIntegersExtraData> , RC_NiIntegersExtraData };
factory["NiBinaryExtraData"] = {&construct <NiBinaryExtraData> , RC_NiBinaryExtraData };
factory["NiBooleanExtraData"] = {&construct <NiBooleanExtraData> , RC_NiBooleanExtraData };
factory["NiVectorExtraData"] = {&construct <NiVectorExtraData> , RC_NiVectorExtraData };
factory["NiColorExtraData"] = {&construct <NiVectorExtraData> , RC_NiColorExtraData };
factory["NiFloatExtraData"] = {&construct <NiFloatExtraData> , RC_NiFloatExtraData };
factory["NiFloatsExtraData"] = {&construct <NiFloatsExtraData> , RC_NiFloatsExtraData };
return factory;
}

View file

@ -101,7 +101,15 @@ enum RecordType
RC_RootCollisionNode,
RC_NiSphericalCollider,
RC_NiLookAtController,
RC_NiPalette
RC_NiPalette,
RC_NiIntegerExtraData,
RC_NiIntegersExtraData,
RC_NiBinaryExtraData,
RC_NiBooleanExtraData,
RC_NiVectorExtraData,
RC_NiColorExtraData,
RC_NiFloatExtraData,
RC_NiFloatsExtraData
};
/// Base class for all records