diff --git a/components/nif/controller.cpp b/components/nif/controller.cpp index 903cf7710c..930ce4fa0d 100644 --- a/components/nif/controller.cpp +++ b/components/nif/controller.cpp @@ -122,11 +122,13 @@ namespace Nif mStringPalette.read(nif); else if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() >= 24) { - uint16_t numAnimNotes = 1; if (nif->getBethVersion() >= 29) - nif->read(numAnimNotes); + mAnimNotesList.resize(nif->get()); + else + mAnimNotesList.resize(1); - nif->skip(4 * numAnimNotes); // BSAnimNotes links + for (auto& notes : mAnimNotesList) + notes.read(nif); } } @@ -793,4 +795,92 @@ namespace Nif mInterpolator.post(nif); } + void NiBSplineInterpolator::read(NIFStream* nif) + { + nif->read(mStartTime); + nif->read(mStopTime); + mSplineData.read(nif); + mBasisData.read(nif); + } + + void NiBSplineInterpolator::post(Reader& nif) + { + mSplineData.post(nif); + mBasisData.post(nif); + } + + void NiBSplineFloatInterpolator::read(NIFStream* nif) + { + NiBSplineInterpolator::read(nif); + + nif->read(mValue); + nif->read(mHandle); + } + + void NiBSplineCompFloatInterpolator::read(NIFStream* nif) + { + NiBSplineFloatInterpolator::read(nif); + + nif->read(mOffset); + nif->read(mHalfRange); + } + + void NiBSplinePoint3Interpolator::read(NIFStream* nif) + { + NiBSplineInterpolator::read(nif); + + nif->read(mValue); + nif->read(mHandle); + } + + void NiBSplineCompPoint3Interpolator::read(NIFStream* nif) + { + NiBSplinePoint3Interpolator::read(nif); + + nif->read(mOffset); + nif->read(mHalfRange); + } + + void NiBSplineTransformInterpolator::read(NIFStream* nif) + { + NiBSplineInterpolator::read(nif); + + nif->read(mValue); + nif->read(mTranslationHandle); + nif->read(mRotationHandle); + nif->read(mScaleHandle); + } + + void NiBSplineCompTransformInterpolator::read(NIFStream* nif) + { + NiBSplineTransformInterpolator::read(nif); + + nif->read(mTranslationOffset); + nif->read(mTranslationHalfRange); + nif->read(mRotationOffset); + nif->read(mRotationHalfRange); + nif->read(mScaleOffset); + nif->read(mScaleHalfRange); + } + + void BSTreadTransform::read(NIFStream* nif) + { + nif->read(mName); + nif->read(mTransform1); + nif->read(mTransform2); + } + + void BSTreadTransfInterpolator::read(NIFStream* nif) + { + mTransforms.resize(nif->get()); + for (BSTreadTransform& transform : mTransforms) + transform.read(nif); + mData.read(nif); + } + + void BSTreadTransfInterpolator::post(Reader& nif) + { + mData.post(nif); + } + } diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 947fae1ab2..d4aae6ed5d 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -56,6 +56,7 @@ namespace Nif bool mPlayBackwards{ false }; NiControllerManagerPtr mManager; NiStringPalettePtr mStringPalette; + BSAnimNotesList mAnimNotesList; void read(NIFStream* nif) override; void post(Reader& nif) override; @@ -548,5 +549,91 @@ namespace Nif using NiBlendPoint3Interpolator = TypedNiBlendInterpolator; using NiBlendTransformInterpolator = TypedNiBlendInterpolator; + // Abstract + struct NiBSplineInterpolator : public NiInterpolator + { + float mStartTime; + float mStopTime; + NiBSplineDataPtr mSplineData; + NiBSplineBasisDataPtr mBasisData; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + + // Abstract + struct NiBSplineFloatInterpolator : public NiBSplineInterpolator + { + float mValue; + uint32_t mHandle; + + void read(NIFStream* nif) override; + }; + + struct NiBSplineCompFloatInterpolator : public NiBSplineFloatInterpolator + { + float mOffset; + float mHalfRange; + + void read(NIFStream* nif) override; + }; + + // Abstract + struct NiBSplinePoint3Interpolator : public NiBSplineInterpolator + { + osg::Vec3f mValue; + uint32_t mHandle; + + void read(NIFStream* nif) override; + }; + + struct NiBSplineCompPoint3Interpolator : public NiBSplinePoint3Interpolator + { + float mOffset; + float mHalfRange; + + void read(NIFStream* nif) override; + }; + + struct NiBSplineTransformInterpolator : public NiBSplineInterpolator + { + NiQuatTransform mValue; + uint32_t mTranslationHandle; + uint32_t mRotationHandle; + uint32_t mScaleHandle; + + void read(NIFStream* nif) override; + }; + + struct NiBSplineCompTransformInterpolator : public NiBSplineTransformInterpolator + { + float mTranslationOffset; + float mTranslationHalfRange; + float mRotationOffset; + float mRotationHalfRange; + float mScaleOffset; + float mScaleHalfRange; + + void read(NIFStream* nif) override; + }; + + struct BSTreadTransform + { + std::string mName; + NiQuatTransform mTransform1; + NiQuatTransform mTransform2; + + void read(NIFStream* nif); + }; + + struct BSTreadTransfInterpolator : public NiInterpolator + { + std::vector mTransforms; + NiFloatDataPtr mData; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + } #endif diff --git a/components/nif/data.cpp b/components/nif/data.cpp index fa66435aee..29b11bd806 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -537,6 +537,17 @@ namespace Nif mKeyList->read(nif); } + void NiBSplineData::read(NIFStream* nif) + { + nif->readVector(mFloatControlPoints, nif->get()); + nif->readVector(mCompactControlPoints, nif->get()); + } + + void NiBSplineBasisData::read(NIFStream* nif) + { + nif->read(mNumControlPoints); + } + void NiAdditionalGeometryData::read(NIFStream* nif) { nif->read(mNumVertices); @@ -603,4 +614,31 @@ namespace Nif nif->read(mSphere); } + void BSAnimNote::read(NIFStream* nif) + { + mType = static_cast(nif->get()); + nif->read(mTime); + if (mType == Type::GrabIK) + { + nif->read(mArm); + } + else if (mType == Type::LookIK) + { + nif->read(mGain); + nif->read(mState); + } + } + + void BSAnimNotes::read(NIFStream* nif) + { + mList.resize(nif->get()); + for (auto& note : mList) + note.read(nif); + } + + void BSAnimNotes::post(Reader& nif) + { + postRecordList(nif, mList); + } + } // Namespace diff --git a/components/nif/data.hpp b/components/nif/data.hpp index c9daeef4d4..1ccd2919b7 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -362,6 +362,21 @@ namespace Nif void read(NIFStream* nif) override; }; + struct NiBSplineData : public Record + { + std::vector mFloatControlPoints; + std::vector mCompactControlPoints; + + void read(NIFStream* nif) override; + }; + + struct NiBSplineBasisData : public Record + { + uint32_t mNumControlPoints; + + void read(NIFStream* nif) override; + }; + struct NiAdditionalGeometryData : public Record { struct DataStream @@ -434,5 +449,31 @@ namespace Nif void read(NIFStream* nif) override; }; + struct BSAnimNote : public Record + { + enum class Type : uint32_t + { + Invalid = 0, + GrabIK = 1, + LookIK = 2, + }; + + Type mType; + float mTime; + uint32_t mArm; + float mGain; + uint32_t mState; + + void read(NIFStream* nif) override; + }; + + struct BSAnimNotes : public Record + { + BSAnimNoteList mList; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + } #endif diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 8a0b0bf930..d360552f9f 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -164,6 +164,14 @@ namespace Nif { "NiLightRadiusController", &construct }, // Interpolators, Gamebryo + { "NiBSplineCompFloatInterpolator", + &construct }, + { "NiBSplineCompPoint3Interpolator", + &construct }, + { "NiBSplineCompTransformInterpolator", + &construct }, + { "NiBSplineTransformInterpolator", + &construct }, { "NiBlendBoolInterpolator", &construct }, { "NiBlendFloatInterpolator", &construct }, { "NiBlendPoint3Interpolator", &construct }, @@ -178,6 +186,10 @@ namespace Nif { "NiPoint3Interpolator", &construct }, { "NiTransformInterpolator", &construct }, + // Interpolators, Bethesda + { "BSRotAccumTransfInterpolator", &construct }, + { "BSTreadTransfInterpolator", &construct }, + // DATA // 4.0.0.2 @@ -195,10 +207,14 @@ namespace Nif // Gamebryo { "NiAdditionalGeometryData", &construct }, { "NiBoolData", &construct }, + { "NiBSplineData", &construct }, + { "NiBSplineBasisData", &construct }, { "NiDefaultAVObjectPalette", &construct }, { "NiTransformData", &construct }, // Bethesda + { "BSAnimNote", &construct }, + { "BSAnimNotes", &construct }, { "BSPackedAdditionalGeometryData", &construct }, { "BSShaderTextureSet", &construct }, diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 699522d24c..21e0b0d382 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -73,6 +73,8 @@ namespace Nif RC_bhkSimpleShapePhantom, RC_bhkSphereShape, RC_bhkStiffSpringConstraint, + RC_BSAnimNote, + RC_BSAnimNotes, RC_BSBehaviorGraphExtraData, RC_BSBound, RC_BSBoneLODExtraData, @@ -127,6 +129,7 @@ namespace Nif RC_BSStripPSysData, RC_BSRefractionFirePeriodController, RC_BSRefractionStrengthController, + RC_BSRotAccumTransfInterpolator, RC_BSSegmentedTriShape, RC_BSShaderNoLightingProperty, RC_BSShaderPPLightingProperty, @@ -136,6 +139,7 @@ namespace Nif RC_BSSkinInstance, RC_BSSkyShaderProperty, RC_BSSubIndexTriShape, + RC_BSTreadTransfInterpolator, RC_BSTriShape, RC_BSWArray, RC_BSWaterShaderProperty, @@ -162,6 +166,12 @@ namespace Nif RC_NiBSAnimationNode, RC_NiBSPArrayController, RC_NiBSParticleNode, + RC_NiBSplineData, + RC_NiBSplineBasisData, + RC_NiBSplineCompFloatInterpolator, + RC_NiBSplineCompPoint3Interpolator, + RC_NiBSplineCompTransformInterpolator, + RC_NiBSplineTransformInterpolator, RC_NiCamera, RC_NiClusterAccumulator, RC_NiCollisionObject, diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index 7056abe6a3..d6311241d7 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -137,6 +137,8 @@ namespace Nif struct NiPSysModifier; struct NiPSysSpawnModifier; struct NiBoolData; + struct NiBSplineData; + struct NiBSplineBasisData; struct NiSkinPartition; struct BSShaderTextureSet; struct NiTriBasedGeom; @@ -163,6 +165,8 @@ namespace Nif struct BSMultiBound; struct BSMultiBoundData; struct BSSkinBoneData; + struct BSAnimNote; + struct BSAnimNotes; using NiAVObjectPtr = RecordPtrT; using ExtraPtr = RecordPtrT; @@ -189,6 +193,8 @@ namespace Nif using NiPSysModifierPtr = RecordPtrT; using NiPSysSpawnModifierPtr = RecordPtrT; using NiBoolDataPtr = RecordPtrT; + using NiBSplineDataPtr = RecordPtrT; + using NiBSplineBasisDataPtr = RecordPtrT; using NiSkinPartitionPtr = RecordPtrT; using BSShaderTextureSetPtr = RecordPtrT; using NiTriBasedGeomPtr = RecordPtrT; @@ -227,6 +233,8 @@ namespace Nif using NiControllerSequenceList = RecordListT; using NiPSysModifierList = RecordListT; using NiTriBasedGeomList = RecordListT; + using BSAnimNoteList = RecordListT; + using BSAnimNotesList = RecordListT; } // Namespace #endif