Merge branch '76supportwhen' into 'master'

Parse pose array files and all remaining unknown Fallout 76 record types

See merge request OpenMW/openmw!4382
pull/3236/head
jvoisin 3 months ago
commit 7d84b85d5c

@ -71,6 +71,8 @@ namespace Nif
{ "BSBlastNode", &construct<BSRangeNode, RC_NiNode> }, { "BSBlastNode", &construct<BSRangeNode, RC_NiNode> },
{ "BSDamageStage", &construct<BSRangeNode, RC_NiNode> }, { "BSDamageStage", &construct<BSRangeNode, RC_NiNode> },
{ "BSDebrisNode", &construct<BSRangeNode, RC_NiNode> }, { "BSDebrisNode", &construct<BSRangeNode, RC_NiNode> },
{ "BSDistantObjectInstancedNode",
&construct<BSDistantObjectInstancedNode, RC_BSDistantObjectInstancedNode> },
{ "BSFadeNode", &construct<NiNode, RC_NiNode> }, { "BSFadeNode", &construct<NiNode, RC_NiNode> },
{ "BSLeafAnimNode", &construct<NiNode, RC_NiNode> }, { "BSLeafAnimNode", &construct<NiNode, RC_NiNode> },
{ "BSMasterParticleSystem", &construct<BSMasterParticleSystem, RC_NiNode> }, { "BSMasterParticleSystem", &construct<BSMasterParticleSystem, RC_NiNode> },
@ -392,6 +394,7 @@ namespace Nif
{ "NiPSysInitialRotAngleCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotAngleCtlr> }, { "NiPSysInitialRotAngleCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotAngleCtlr> },
{ "NiPSysInitialRotAngleVarCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotAngleVarCtlr> }, { "NiPSysInitialRotAngleVarCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysInitialRotAngleVarCtlr> },
{ "NiPSysModifierActiveCtlr", &construct<NiPSysModifierBoolCtlr, RC_NiPSysModifierActiveCtlr> }, { "NiPSysModifierActiveCtlr", &construct<NiPSysModifierBoolCtlr, RC_NiPSysModifierActiveCtlr> },
{ "NiPSysRotDampeningCtlr", &construct<NiPSysModifierFloatCtlr, RC_NiPSysRotDampeningCtlr> },
// Modifier controllers, Bethesda // Modifier controllers, Bethesda
{ "BSPSysMultiTargetEmitterCtlr", { "BSPSysMultiTargetEmitterCtlr",
@ -481,6 +484,9 @@ namespace Nif
{ "bhkRagdollTemplate", &construct<bhkRagdollTemplate, RC_bhkRagdollTemplate> }, { "bhkRagdollTemplate", &construct<bhkRagdollTemplate, RC_bhkRagdollTemplate> },
{ "bhkRagdollTemplateData", &construct<bhkRagdollTemplateData, RC_bhkRagdollTemplateData> }, { "bhkRagdollTemplateData", &construct<bhkRagdollTemplateData, RC_bhkRagdollTemplateData> },
// Other records
{ "bhkPoseArray", &construct<bhkPoseArray, RC_bhkPoseArray> },
// PROPERTIES // PROPERTIES
// 4.0.0.2 // 4.0.0.2

@ -742,4 +742,43 @@ namespace Nif
nif->read(mCurrent); nif->read(mCurrent);
} }
void BSResourceID::read(NIFStream* nif)
{
nif->read(mFileHash);
nif->readArray(mExtension);
nif->read(mDirectoryHash);
}
void BSDistantObjectInstance::read(NIFStream* nif)
{
mResourceID.read(nif);
nif->skip(12 * nif->get<uint32_t>()); // Unknown data
mTransforms.resize(nif->get<uint32_t>());
for (osg::Matrixf& transform : mTransforms)
{
std::array<float, 16> mat;
nif->readArray(mat);
transform.set(mat.data());
}
}
void BSShaderTextureArray::read(NIFStream* nif)
{
nif->skip(1); // Unknown
mTextureArrays.resize(nif->get<uint32_t>());
for (std::vector<std::string>& textureArray : mTextureArrays)
nif->getSizedStrings(textureArray, nif->get<uint32_t>());
}
void BSDistantObjectInstancedNode::read(NIFStream* nif)
{
BSMultiBoundNode::read(nif);
mInstances.resize(nif->get<uint32_t>());
for (BSDistantObjectInstance& instance : mInstances)
instance.read(nif);
for (BSShaderTextureArray& textureArray : mShaderTextureArrays)
textureArray.read(nif);
}
} }

@ -494,5 +494,37 @@ namespace Nif
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };
struct BSResourceID
{
uint32_t mFileHash;
std::array<char, 4> mExtension;
uint32_t mDirectoryHash;
void read(NIFStream* nif);
};
struct BSDistantObjectInstance
{
BSResourceID mResourceID;
std::vector<osg::Matrixf> mTransforms;
void read(NIFStream* nif);
};
struct BSShaderTextureArray
{
std::vector<std::vector<std::string>> mTextureArrays;
void read(NIFStream* nif);
};
struct BSDistantObjectInstancedNode : BSMultiBoundNode
{
std::vector<BSDistantObjectInstance> mInstances;
std::array<BSShaderTextureArray, 3> mShaderTextureArrays;
void read(NIFStream* nif) override;
};
} }
#endif #endif

@ -1013,4 +1013,23 @@ namespace Nif
constraint.read(nif); constraint.read(nif);
} }
void bhkPoseArray::BoneTransform::read(NIFStream* nif)
{
nif->read(mTranslation);
nif->read(mRotation);
nif->read(mScale);
}
void bhkPoseArray::read(NIFStream* nif)
{
nif->readVector(mBones, nif->get<uint32_t>());
mPoses.resize(nif->get<uint32_t>());
for (std::vector<BoneTransform>& pose : mPoses)
{
pose.resize(nif->get<uint32_t>());
for (BoneTransform& transform : pose)
transform.read(nif);
}
}
} // Namespace } // Namespace

@ -930,5 +930,23 @@ namespace Nif
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };
struct bhkPoseArray : Record
{
struct BoneTransform
{
osg::Vec3f mTranslation;
// FIXME: this and some other quaternions are meant to be read in direct order
osg::Quat mRotation;
osg::Vec3f mScale;
void read(NIFStream* nif);
};
std::vector<std::string> mBones;
std::vector<std::vector<BoneTransform>> mPoses;
void read(NIFStream* nif) override;
};
} // Namespace } // Namespace
#endif #endif

@ -65,6 +65,7 @@ namespace Nif
RC_bhkPackedNiTriStripsShape, RC_bhkPackedNiTriStripsShape,
RC_bhkPlaneShape, RC_bhkPlaneShape,
RC_bhkPhysicsSystem, RC_bhkPhysicsSystem,
RC_bhkPoseArray,
RC_bhkPrismaticConstraint, RC_bhkPrismaticConstraint,
RC_bhkRagdollConstraint, RC_bhkRagdollConstraint,
RC_bhkRagdollSystem, RC_bhkRagdollSystem,
@ -89,6 +90,7 @@ namespace Nif
RC_BSDynamicTriShape, RC_BSDynamicTriShape,
RC_BSDismemberSkinInstance, RC_BSDismemberSkinInstance,
RC_BSDistantObjectExtraData, RC_BSDistantObjectExtraData,
RC_BSDistantObjectInstancedNode,
RC_BSDistantObjectLargeRefExtraData, RC_BSDistantObjectLargeRefExtraData,
RC_BSEffectShaderProperty, RC_BSEffectShaderProperty,
RC_BSEffectShaderPropertyColorController, RC_BSEffectShaderPropertyColorController,
@ -270,6 +272,7 @@ namespace Nif
RC_NiPSysPlanarCollider, RC_NiPSysPlanarCollider,
RC_NiPSysPositionModifier, RC_NiPSysPositionModifier,
RC_NiPSysRotationModifier, RC_NiPSysRotationModifier,
RC_NiPSysRotDampeningCtlr,
RC_NiPSysResetOnLoopCtlr, RC_NiPSysResetOnLoopCtlr,
RC_NiPSysSpawnModifier, RC_NiPSysSpawnModifier,
RC_NiPSysSphericalCollider, RC_NiPSysSphericalCollider,

Loading…
Cancel
Save