1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/components/nif/extra.cpp

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

142 lines
3.2 KiB
C++
Raw Normal View History

#include "extra.hpp"
namespace Nif
{
2021-07-27 04:58:57 +00:00
void NiExtraData::read(NIFStream* nif)
{
Extra::read(nif);
if (recordSize)
nif->getChars(data, recordSize);
}
void NiStringExtraData::read(NIFStream* nif)
{
Extra::read(nif);
string = nif->getString();
}
void NiTextKeyExtraData::read(NIFStream* nif)
{
Extra::read(nif);
2022-09-22 18:26:05 +00:00
int keynum = nif->getInt();
list.resize(keynum);
for (int i = 0; i < keynum; i++)
2022-09-22 18:26:05 +00:00
{
list[i].time = nif->getFloat();
list[i].text = nif->getString();
2022-09-22 18:26:05 +00:00
}
}
void NiVertWeightsExtraData::read(NIFStream* nif)
2022-09-22 18:26:05 +00:00
{
Extra::read(nif);
2020-10-06 17:52:21 +00:00
nif->skip(nif->getUShort() * sizeof(float)); // vertex weights I guess
2022-09-22 18:26:05 +00:00
}
2020-10-06 17:52:21 +00:00
void NiIntegerExtraData::read(NIFStream* nif)
2022-09-22 18:26:05 +00:00
{
2020-10-06 17:52:21 +00:00
Extra::read(nif);
data = nif->getUInt();
2022-09-22 18:26:05 +00:00
}
2020-10-06 17:52:21 +00:00
void NiIntegersExtraData::read(NIFStream* nif)
2022-09-22 18:26:05 +00:00
{
2020-10-06 17:52:21 +00:00
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();
2022-09-22 18:26:05 +00:00
if (size)
2020-10-06 17:52:21 +00:00
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();
2022-09-22 18:26:05 +00:00
}
2020-10-06 17:52:21 +00:00
void NiFloatExtraData::read(NIFStream* nif)
2022-09-22 18:26:05 +00:00
{
2020-10-06 17:52:21 +00:00
Extra::read(nif);
data = nif->getFloat();
}
void NiFloatsExtraData::read(NIFStream* nif)
{
Extra::read(nif);
unsigned int num = nif->getUInt();
2022-09-22 18:26:05 +00:00
if (num)
nif->getFloats(data, num);
}
2021-11-10 16:21:07 +00:00
void BSBound::read(NIFStream* nif)
2022-09-22 18:26:05 +00:00
{
2021-11-10 16:21:07 +00:00
Extra::read(nif);
center = nif->getVector3();
halfExtents = nif->getVector3();
2021-11-10 16:21:07 +00:00
}
void BSFurnitureMarker::LegacyFurniturePosition::read(NIFStream* nif)
{
mOffset = nif->getVector3();
mOrientation = nif->getUShort();
mPositionRef = nif->getChar();
nif->skip(1); // Position ref 2
2021-11-10 16:21:07 +00:00
}
void BSFurnitureMarker::FurniturePosition::read(NIFStream* nif)
{
mOffset = nif->getVector3();
2021-11-10 16:21:07 +00:00
mHeading = nif->getFloat();
mType = nif->getUShort();
mEntryPoint = nif->getUShort();
2021-11-10 16:21:07 +00:00
}
2022-09-22 18:26:05 +00:00
void BSFurnitureMarker::read(NIFStream* nif)
2021-11-10 16:21:07 +00:00
{
Extra::read(nif);
unsigned int num = nif->getUInt();
if (nif->getBethVersion() <= NIFFile::BethVersion::BETHVER_FO3)
2022-09-22 18:26:05 +00:00
{
mLegacyMarkers.resize(num);
for (auto& marker : mLegacyMarkers)
2021-11-10 16:21:07 +00:00
marker.read(nif);
2022-09-22 18:26:05 +00:00
}
else
{
mMarkers.resize(num);
for (auto& marker : mMarkers)
2021-11-10 16:21:07 +00:00
marker.read(nif);
2022-09-22 18:26:05 +00:00
}
2021-11-10 16:21:07 +00:00
}
2023-06-01 20:27:42 +00:00
void BSInvMarker::read(NIFStream* nif)
{
Extra::read(nif);
float rotX = nif->getUShort() / 1000.0;
float rotY = nif->getUShort() / 1000.0;
float rotZ = nif->getUShort() / 1000.0;
mScale = nif->getFloat();
mRotation = osg::Quat(rotX, osg::X_AXIS, rotY, osg::Y_AXIS, rotZ, osg::Z_AXIS);
}
}