Read FO4 skinning data

macos_ci_fix
Alexei Kotov 1 year ago
parent d9f8757f33
commit 6c2a79184d

@ -302,6 +302,33 @@ namespace Nif
} }
} }
void BSSkinInstance::read(NIFStream* nif)
{
mRoot.read(nif);
mData.read(nif);
readRecordList(nif, mBones);
nif->readVector(mScales, nif->get<uint32_t>());
}
void BSSkinInstance::post(Reader& nif)
{
mRoot.post(nif);
mData.post(nif);
postRecordList(nif, mBones);
if (mData.empty() || mRoot.empty())
throw Nif::Exception("BSSkin::Instance missing root or data", nif.getFilename());
if (mBones.size() != mData->mBones.size())
throw Nif::Exception("Mismatch in BSSkin::BoneData bone count", nif.getFilename());
for (auto& bone : mBones)
{
if (bone.empty())
throw Nif::Exception("Oops: Missing bone! Don't know how to handle this.", nif.getFilename());
bone->setBone();
}
}
void NiSkinData::read(NIFStream* nif) void NiSkinData::read(NIFStream* nif)
{ {
nif->read(mTransform); nif->read(mTransform);
@ -344,6 +371,16 @@ namespace Nif
mPartitions.post(nif); mPartitions.post(nif);
} }
void BSSkinBoneData::read(NIFStream* nif)
{
mBones.resize(nif->get<uint32_t>());
for (BoneInfo& bone : mBones)
{
nif->read(bone.mBoundSphere);
nif->read(bone.mTransform);
}
}
void NiSkinPartition::read(NIFStream* nif) void NiSkinPartition::read(NIFStream* nif)
{ {
mPartitions.resize(nif->get<uint32_t>()); mPartitions.resize(nif->get<uint32_t>());

@ -223,6 +223,17 @@ namespace Nif
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };
struct BSSkinInstance : Record
{
NiAVObjectPtr mRoot;
BSSkinBoneDataPtr mData;
NiAVObjectList mBones;
std::vector<osg::Vec3f> mScales;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
struct NiSkinData : public Record struct NiSkinData : public Record
{ {
using VertWeight = std::pair<unsigned short, float>; using VertWeight = std::pair<unsigned short, float>;
@ -242,6 +253,19 @@ namespace Nif
void post(Reader& nif) override; void post(Reader& nif) override;
}; };
struct BSSkinBoneData : Record
{
struct BoneInfo
{
osg::BoundingSpheref mBoundSphere;
NiTransform mTransform;
};
std::vector<BoneInfo> mBones;
void read(NIFStream* nif) override;
};
struct NiSkinPartition : public Record struct NiSkinPartition : public Record
{ {
struct Partition struct Partition

@ -268,6 +268,8 @@ namespace Nif
// Bethesda // Bethesda
{ "BSDismemberSkinInstance", &construct<BSDismemberSkinInstance, RC_BSDismemberSkinInstance> }, { "BSDismemberSkinInstance", &construct<BSDismemberSkinInstance, RC_BSDismemberSkinInstance> },
{ "BSSkin::Instance", &construct<BSSkinInstance, RC_BSSkinInstance> },
{ "BSSkin::BoneData", &construct<BSSkinBoneData, RC_BSSkinBoneData> },
{ "BSTriShape", &construct<BSTriShape, RC_BSTriShape> }, { "BSTriShape", &construct<BSTriShape, RC_BSTriShape> },
{ "BSDynamicTriShape", &construct<BSDynamicTriShape, RC_BSDynamicTriShape> }, { "BSDynamicTriShape", &construct<BSDynamicTriShape, RC_BSDynamicTriShape> },
{ "BSLODTriShape", &construct<BSLODTriShape, RC_BSLODTriShape> }, { "BSLODTriShape", &construct<BSLODTriShape, RC_BSLODTriShape> },

@ -125,6 +125,8 @@ namespace Nif
RC_BSShaderPPLightingProperty, RC_BSShaderPPLightingProperty,
RC_BSShaderProperty, RC_BSShaderProperty,
RC_BSShaderTextureSet, RC_BSShaderTextureSet,
RC_BSSkinBoneData,
RC_BSSkinInstance,
RC_BSSkyShaderProperty, RC_BSSkyShaderProperty,
RC_BSTriShape, RC_BSTriShape,
RC_BSWArray, RC_BSWArray,

@ -162,6 +162,7 @@ namespace Nif
struct bhkCompressedMeshShapeData; struct bhkCompressedMeshShapeData;
struct BSMultiBound; struct BSMultiBound;
struct BSMultiBoundData; struct BSMultiBoundData;
struct BSSkinBoneData;
using NiAVObjectPtr = RecordPtrT<NiAVObject>; using NiAVObjectPtr = RecordPtrT<NiAVObject>;
using ExtraPtr = RecordPtrT<Extra>; using ExtraPtr = RecordPtrT<Extra>;
@ -211,6 +212,7 @@ namespace Nif
using bhkCompressedMeshShapeDataPtr = RecordPtrT<bhkCompressedMeshShapeData>; using bhkCompressedMeshShapeDataPtr = RecordPtrT<bhkCompressedMeshShapeData>;
using BSMultiBoundPtr = RecordPtrT<BSMultiBound>; using BSMultiBoundPtr = RecordPtrT<BSMultiBound>;
using BSMultiBoundDataPtr = RecordPtrT<BSMultiBoundData>; using BSMultiBoundDataPtr = RecordPtrT<BSMultiBoundData>;
using BSSkinBoneDataPtr = RecordPtrT<BSSkinBoneData>;
using NiAVObjectList = RecordListT<NiAVObject>; using NiAVObjectList = RecordListT<NiAVObject>;
using NiPropertyList = RecordListT<NiProperty>; using NiPropertyList = RecordListT<NiProperty>;

Loading…
Cancel
Save