diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index e0616a679a..420765262e 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -71,6 +71,8 @@ namespace Nif { "BSBlastNode", &construct }, { "BSDamageStage", &construct }, { "BSDebrisNode", &construct }, + { "BSDistantObjectInstancedNode", + &construct }, { "BSFadeNode", &construct }, { "BSLeafAnimNode", &construct }, { "BSMasterParticleSystem", &construct }, @@ -392,6 +394,7 @@ namespace Nif { "NiPSysInitialRotAngleCtlr", &construct }, { "NiPSysInitialRotAngleVarCtlr", &construct }, { "NiPSysModifierActiveCtlr", &construct }, + { "NiPSysRotDampeningCtlr", &construct }, // Modifier controllers, Bethesda { "BSPSysMultiTargetEmitterCtlr", @@ -481,6 +484,9 @@ namespace Nif { "bhkRagdollTemplate", &construct }, { "bhkRagdollTemplateData", &construct }, + // Other records + { "bhkPoseArray", &construct }, + // PROPERTIES // 4.0.0.2 diff --git a/components/nif/node.cpp b/components/nif/node.cpp index b91f143d00..c2655a3e9c 100644 --- a/components/nif/node.cpp +++ b/components/nif/node.cpp @@ -742,4 +742,43 @@ namespace Nif 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()); // Unknown data + mTransforms.resize(nif->get()); + for (osg::Matrixf& transform : mTransforms) + { + std::array mat; + nif->readArray(mat); + transform.set(mat.data()); + } + } + + void BSShaderTextureArray::read(NIFStream* nif) + { + nif->skip(1); // Unknown + mTextureArrays.resize(nif->get()); + for (std::vector& textureArray : mTextureArrays) + nif->getSizedStrings(textureArray, nif->get()); + } + + void BSDistantObjectInstancedNode::read(NIFStream* nif) + { + BSMultiBoundNode::read(nif); + + mInstances.resize(nif->get()); + for (BSDistantObjectInstance& instance : mInstances) + instance.read(nif); + for (BSShaderTextureArray& textureArray : mShaderTextureArrays) + textureArray.read(nif); + } + } diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 32746f7a9f..e9306fa83f 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -494,5 +494,37 @@ namespace Nif void read(NIFStream* nif) override; }; + struct BSResourceID + { + uint32_t mFileHash; + std::array mExtension; + uint32_t mDirectoryHash; + + void read(NIFStream* nif); + }; + + struct BSDistantObjectInstance + { + BSResourceID mResourceID; + std::vector mTransforms; + + void read(NIFStream* nif); + }; + + struct BSShaderTextureArray + { + std::vector> mTextureArrays; + + void read(NIFStream* nif); + }; + + struct BSDistantObjectInstancedNode : BSMultiBoundNode + { + std::vector mInstances; + std::array mShaderTextureArrays; + + void read(NIFStream* nif) override; + }; + } #endif diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index 762e83515d..6368537e60 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -1013,4 +1013,23 @@ namespace 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()); + mPoses.resize(nif->get()); + for (std::vector& pose : mPoses) + { + pose.resize(nif->get()); + for (BoneTransform& transform : pose) + transform.read(nif); + } + } + } // Namespace diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index ecefd55616..286c8cc353 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -930,5 +930,23 @@ namespace Nif 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 mBones; + std::vector> mPoses; + + void read(NIFStream* nif) override; + }; + } // Namespace #endif diff --git a/components/nif/record.hpp b/components/nif/record.hpp index ebb237edd3..fe38cc4cad 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -65,6 +65,7 @@ namespace Nif RC_bhkPackedNiTriStripsShape, RC_bhkPlaneShape, RC_bhkPhysicsSystem, + RC_bhkPoseArray, RC_bhkPrismaticConstraint, RC_bhkRagdollConstraint, RC_bhkRagdollSystem, @@ -89,6 +90,7 @@ namespace Nif RC_BSDynamicTriShape, RC_BSDismemberSkinInstance, RC_BSDistantObjectExtraData, + RC_BSDistantObjectInstancedNode, RC_BSDistantObjectLargeRefExtraData, RC_BSEffectShaderProperty, RC_BSEffectShaderPropertyColorController, @@ -270,6 +272,7 @@ namespace Nif RC_NiPSysPlanarCollider, RC_NiPSysPositionModifier, RC_NiPSysRotationModifier, + RC_NiPSysRotDampeningCtlr, RC_NiPSysResetOnLoopCtlr, RC_NiPSysSpawnModifier, RC_NiPSysSphericalCollider,