Load a bunch of triangle strip-based Havok records

This commit is contained in:
Alexei Dobrohotov 2021-11-13 19:38:00 +03:00
parent e7cc76bba2
commit 83aa96e38f
5 changed files with 124 additions and 1 deletions

View file

@ -60,6 +60,15 @@ namespace Nif
mProcessContactDelay = nif->getUShort();
}
void TriangleData::read(NIFStream *nif)
{
for (int i = 0; i < 3; i++)
mTriangle[i] = nif->getUShort();
mWeldingInfo = nif->getUShort();
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
mNormal = nif->getVector3();
}
/// Record types
void bhkCollisionObject::read(NIFStream *nif)
@ -107,4 +116,67 @@ namespace Nif
mMopp.read(nif);
}
void bhkNiTriStripsShape::read(NIFStream *nif)
{
mHavokMaterial.read(nif);
mRadius = nif->getFloat();
nif->skip(20); // Unused
mGrowBy = nif->getUInt();
if (nif->getVersion() >= NIFStream::generateVersion(10,1,0,0))
mScale = nif->getVector4();
mData.read(nif);
unsigned int numFilters = nif->getUInt();
nif->getUInts(mFilters, numFilters);
}
void bhkNiTriStripsShape::post(NIFFile *nif)
{
mData.post(nif);
}
void bhkPackedNiTriStripsShape::read(NIFStream *nif)
{
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
{
mSubshapes.resize(nif->getUShort());
for (hkSubPartData& subshape : mSubshapes)
subshape.read(nif);
}
mUserData = nif->getUInt();
nif->skip(4); // Unused
mRadius = nif->getFloat();
nif->skip(4); // Unused
mScale = nif->getVector4();
nif->skip(20); // Duplicates of the two previous fields
mData.read(nif);
}
void bhkPackedNiTriStripsShape::post(NIFFile *nif)
{
mData.post(nif);
}
void hkPackedNiTriStripsData::read(NIFStream *nif)
{
unsigned int numTriangles = nif->getUInt();
mTriangles.resize(numTriangles);
for (unsigned int i = 0; i < numTriangles; i++)
mTriangles[i].read(nif);
unsigned int numVertices = nif->getUInt();
bool compressed = false;
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS)
compressed = nif->getBoolean();
if (!compressed)
nif->getVector3s(mVertices, numVertices);
else
nif->skip(6 * numVertices); // Half-precision vectors are not currently supported
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS)
{
mSubshapes.resize(nif->getUShort());
for (hkSubPartData& subshape : mSubshapes)
subshape.read(nif);
}
}
} // Namespace