1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 00:15:35 +00:00

Merge branch 'dealingwithkf' into 'master'

Parse all official Oblivion, Fallout 3 and New Vegas KF files

See merge request OpenMW/openmw!4094
This commit is contained in:
psi29a 2024-05-14 07:43:39 +00:00
commit 811236bfe1
7 changed files with 293 additions and 3 deletions

View file

@ -122,11 +122,13 @@ namespace Nif
mStringPalette.read(nif); mStringPalette.read(nif);
else if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() >= 24) else if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() >= 24)
{ {
uint16_t numAnimNotes = 1;
if (nif->getBethVersion() >= 29) if (nif->getBethVersion() >= 29)
nif->read(numAnimNotes); mAnimNotesList.resize(nif->get<uint16_t>());
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); 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<uint32_t>());
for (BSTreadTransform& transform : mTransforms)
transform.read(nif);
mData.read(nif);
}
void BSTreadTransfInterpolator::post(Reader& nif)
{
mData.post(nif);
}
} }

View file

@ -56,6 +56,7 @@ namespace Nif
bool mPlayBackwards{ false }; bool mPlayBackwards{ false };
NiControllerManagerPtr mManager; NiControllerManagerPtr mManager;
NiStringPalettePtr mStringPalette; NiStringPalettePtr mStringPalette;
BSAnimNotesList mAnimNotesList;
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
void post(Reader& nif) override; void post(Reader& nif) override;
@ -548,5 +549,91 @@ namespace Nif
using NiBlendPoint3Interpolator = TypedNiBlendInterpolator<osg::Vec3f>; using NiBlendPoint3Interpolator = TypedNiBlendInterpolator<osg::Vec3f>;
using NiBlendTransformInterpolator = TypedNiBlendInterpolator<NiQuatTransform>; using NiBlendTransformInterpolator = TypedNiBlendInterpolator<NiQuatTransform>;
// 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<BSTreadTransform> mTransforms;
NiFloatDataPtr mData;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
} }
#endif #endif

View file

@ -537,6 +537,17 @@ namespace Nif
mKeyList->read(nif); mKeyList->read(nif);
} }
void NiBSplineData::read(NIFStream* nif)
{
nif->readVector(mFloatControlPoints, nif->get<uint32_t>());
nif->readVector(mCompactControlPoints, nif->get<uint32_t>());
}
void NiBSplineBasisData::read(NIFStream* nif)
{
nif->read(mNumControlPoints);
}
void NiAdditionalGeometryData::read(NIFStream* nif) void NiAdditionalGeometryData::read(NIFStream* nif)
{ {
nif->read(mNumVertices); nif->read(mNumVertices);
@ -603,4 +614,31 @@ namespace Nif
nif->read(mSphere); nif->read(mSphere);
} }
void BSAnimNote::read(NIFStream* nif)
{
mType = static_cast<Type>(nif->get<uint32_t>());
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<uint16_t>());
for (auto& note : mList)
note.read(nif);
}
void BSAnimNotes::post(Reader& nif)
{
postRecordList(nif, mList);
}
} // Namespace } // Namespace

View file

@ -362,6 +362,21 @@ namespace Nif
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };
struct NiBSplineData : public Record
{
std::vector<float> mFloatControlPoints;
std::vector<int16_t> mCompactControlPoints;
void read(NIFStream* nif) override;
};
struct NiBSplineBasisData : public Record
{
uint32_t mNumControlPoints;
void read(NIFStream* nif) override;
};
struct NiAdditionalGeometryData : public Record struct NiAdditionalGeometryData : public Record
{ {
struct DataStream struct DataStream
@ -434,5 +449,31 @@ namespace Nif
void read(NIFStream* nif) override; 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 #endif

View file

@ -164,6 +164,14 @@ namespace Nif
{ "NiLightRadiusController", &construct<NiFloatInterpController, RC_NiLightRadiusController> }, { "NiLightRadiusController", &construct<NiFloatInterpController, RC_NiLightRadiusController> },
// Interpolators, Gamebryo // Interpolators, Gamebryo
{ "NiBSplineCompFloatInterpolator",
&construct<NiBSplineCompFloatInterpolator, RC_NiBSplineCompFloatInterpolator> },
{ "NiBSplineCompPoint3Interpolator",
&construct<NiBSplineCompPoint3Interpolator, RC_NiBSplineCompPoint3Interpolator> },
{ "NiBSplineCompTransformInterpolator",
&construct<NiBSplineCompTransformInterpolator, RC_NiBSplineCompTransformInterpolator> },
{ "NiBSplineTransformInterpolator",
&construct<NiBSplineTransformInterpolator, RC_NiBSplineTransformInterpolator> },
{ "NiBlendBoolInterpolator", &construct<NiBlendBoolInterpolator, RC_NiBlendBoolInterpolator> }, { "NiBlendBoolInterpolator", &construct<NiBlendBoolInterpolator, RC_NiBlendBoolInterpolator> },
{ "NiBlendFloatInterpolator", &construct<NiBlendFloatInterpolator, RC_NiBlendFloatInterpolator> }, { "NiBlendFloatInterpolator", &construct<NiBlendFloatInterpolator, RC_NiBlendFloatInterpolator> },
{ "NiBlendPoint3Interpolator", &construct<NiBlendPoint3Interpolator, RC_NiBlendPoint3Interpolator> }, { "NiBlendPoint3Interpolator", &construct<NiBlendPoint3Interpolator, RC_NiBlendPoint3Interpolator> },
@ -178,6 +186,10 @@ namespace Nif
{ "NiPoint3Interpolator", &construct<NiPoint3Interpolator, RC_NiPoint3Interpolator> }, { "NiPoint3Interpolator", &construct<NiPoint3Interpolator, RC_NiPoint3Interpolator> },
{ "NiTransformInterpolator", &construct<NiTransformInterpolator, RC_NiTransformInterpolator> }, { "NiTransformInterpolator", &construct<NiTransformInterpolator, RC_NiTransformInterpolator> },
// Interpolators, Bethesda
{ "BSRotAccumTransfInterpolator", &construct<NiTransformInterpolator, RC_BSRotAccumTransfInterpolator> },
{ "BSTreadTransfInterpolator", &construct<BSTreadTransfInterpolator, RC_BSTreadTransfInterpolator> },
// DATA // DATA
// 4.0.0.2 // 4.0.0.2
@ -195,10 +207,14 @@ namespace Nif
// Gamebryo // Gamebryo
{ "NiAdditionalGeometryData", &construct<NiAdditionalGeometryData, RC_NiAdditionalGeometryData> }, { "NiAdditionalGeometryData", &construct<NiAdditionalGeometryData, RC_NiAdditionalGeometryData> },
{ "NiBoolData", &construct<NiBoolData, RC_NiBoolData> }, { "NiBoolData", &construct<NiBoolData, RC_NiBoolData> },
{ "NiBSplineData", &construct<NiBSplineData, RC_NiBSplineData> },
{ "NiBSplineBasisData", &construct<NiBSplineBasisData, RC_NiBSplineBasisData> },
{ "NiDefaultAVObjectPalette", &construct<NiDefaultAVObjectPalette, RC_NiDefaultAVObjectPalette> }, { "NiDefaultAVObjectPalette", &construct<NiDefaultAVObjectPalette, RC_NiDefaultAVObjectPalette> },
{ "NiTransformData", &construct<NiKeyframeData, RC_NiKeyframeData> }, { "NiTransformData", &construct<NiKeyframeData, RC_NiKeyframeData> },
// Bethesda // Bethesda
{ "BSAnimNote", &construct<BSAnimNote, RC_BSAnimNote> },
{ "BSAnimNotes", &construct<BSAnimNotes, RC_BSAnimNotes> },
{ "BSPackedAdditionalGeometryData", { "BSPackedAdditionalGeometryData",
&construct<NiAdditionalGeometryData, RC_BSPackedAdditionalGeometryData> }, &construct<NiAdditionalGeometryData, RC_BSPackedAdditionalGeometryData> },
{ "BSShaderTextureSet", &construct<BSShaderTextureSet, RC_BSShaderTextureSet> }, { "BSShaderTextureSet", &construct<BSShaderTextureSet, RC_BSShaderTextureSet> },

View file

@ -73,6 +73,8 @@ namespace Nif
RC_bhkSimpleShapePhantom, RC_bhkSimpleShapePhantom,
RC_bhkSphereShape, RC_bhkSphereShape,
RC_bhkStiffSpringConstraint, RC_bhkStiffSpringConstraint,
RC_BSAnimNote,
RC_BSAnimNotes,
RC_BSBehaviorGraphExtraData, RC_BSBehaviorGraphExtraData,
RC_BSBound, RC_BSBound,
RC_BSBoneLODExtraData, RC_BSBoneLODExtraData,
@ -127,6 +129,7 @@ namespace Nif
RC_BSStripPSysData, RC_BSStripPSysData,
RC_BSRefractionFirePeriodController, RC_BSRefractionFirePeriodController,
RC_BSRefractionStrengthController, RC_BSRefractionStrengthController,
RC_BSRotAccumTransfInterpolator,
RC_BSSegmentedTriShape, RC_BSSegmentedTriShape,
RC_BSShaderNoLightingProperty, RC_BSShaderNoLightingProperty,
RC_BSShaderPPLightingProperty, RC_BSShaderPPLightingProperty,
@ -136,6 +139,7 @@ namespace Nif
RC_BSSkinInstance, RC_BSSkinInstance,
RC_BSSkyShaderProperty, RC_BSSkyShaderProperty,
RC_BSSubIndexTriShape, RC_BSSubIndexTriShape,
RC_BSTreadTransfInterpolator,
RC_BSTriShape, RC_BSTriShape,
RC_BSWArray, RC_BSWArray,
RC_BSWaterShaderProperty, RC_BSWaterShaderProperty,
@ -162,6 +166,12 @@ namespace Nif
RC_NiBSAnimationNode, RC_NiBSAnimationNode,
RC_NiBSPArrayController, RC_NiBSPArrayController,
RC_NiBSParticleNode, RC_NiBSParticleNode,
RC_NiBSplineData,
RC_NiBSplineBasisData,
RC_NiBSplineCompFloatInterpolator,
RC_NiBSplineCompPoint3Interpolator,
RC_NiBSplineCompTransformInterpolator,
RC_NiBSplineTransformInterpolator,
RC_NiCamera, RC_NiCamera,
RC_NiClusterAccumulator, RC_NiClusterAccumulator,
RC_NiCollisionObject, RC_NiCollisionObject,

View file

@ -137,6 +137,8 @@ namespace Nif
struct NiPSysModifier; struct NiPSysModifier;
struct NiPSysSpawnModifier; struct NiPSysSpawnModifier;
struct NiBoolData; struct NiBoolData;
struct NiBSplineData;
struct NiBSplineBasisData;
struct NiSkinPartition; struct NiSkinPartition;
struct BSShaderTextureSet; struct BSShaderTextureSet;
struct NiTriBasedGeom; struct NiTriBasedGeom;
@ -163,6 +165,8 @@ namespace Nif
struct BSMultiBound; struct BSMultiBound;
struct BSMultiBoundData; struct BSMultiBoundData;
struct BSSkinBoneData; struct BSSkinBoneData;
struct BSAnimNote;
struct BSAnimNotes;
using NiAVObjectPtr = RecordPtrT<NiAVObject>; using NiAVObjectPtr = RecordPtrT<NiAVObject>;
using ExtraPtr = RecordPtrT<Extra>; using ExtraPtr = RecordPtrT<Extra>;
@ -189,6 +193,8 @@ namespace Nif
using NiPSysModifierPtr = RecordPtrT<NiPSysModifier>; using NiPSysModifierPtr = RecordPtrT<NiPSysModifier>;
using NiPSysSpawnModifierPtr = RecordPtrT<NiPSysSpawnModifier>; using NiPSysSpawnModifierPtr = RecordPtrT<NiPSysSpawnModifier>;
using NiBoolDataPtr = RecordPtrT<NiBoolData>; using NiBoolDataPtr = RecordPtrT<NiBoolData>;
using NiBSplineDataPtr = RecordPtrT<NiBSplineData>;
using NiBSplineBasisDataPtr = RecordPtrT<NiBSplineBasisData>;
using NiSkinPartitionPtr = RecordPtrT<NiSkinPartition>; using NiSkinPartitionPtr = RecordPtrT<NiSkinPartition>;
using BSShaderTextureSetPtr = RecordPtrT<BSShaderTextureSet>; using BSShaderTextureSetPtr = RecordPtrT<BSShaderTextureSet>;
using NiTriBasedGeomPtr = RecordPtrT<NiTriBasedGeom>; using NiTriBasedGeomPtr = RecordPtrT<NiTriBasedGeom>;
@ -227,6 +233,8 @@ namespace Nif
using NiControllerSequenceList = RecordListT<NiControllerSequence>; using NiControllerSequenceList = RecordListT<NiControllerSequence>;
using NiPSysModifierList = RecordListT<NiPSysModifier>; using NiPSysModifierList = RecordListT<NiPSysModifier>;
using NiTriBasedGeomList = RecordListT<NiTriBasedGeom>; using NiTriBasedGeomList = RecordListT<NiTriBasedGeom>;
using BSAnimNoteList = RecordListT<BSAnimNote>;
using BSAnimNotesList = RecordListT<BSAnimNotes>;
} // Namespace } // Namespace
#endif #endif