From 7ea2ea96b63dac0cced680bfb992c7870b9c9bf7 Mon Sep 17 00:00:00 2001 From: alekulyn Date: Mon, 10 Jul 2023 17:27:05 -0500 Subject: [PATCH 1/5] Read new nodes pt1 --- components/nif/niffile.cpp | 6 ++++++ components/nif/nifstream.hpp | 1 + components/nif/node.cpp | 14 ++++++++++++++ components/nif/node.hpp | 15 +++++++++++++++ components/nif/physics.cpp | 8 ++++++++ components/nif/physics.hpp | 5 +++++ components/nif/record.hpp | 1 + 7 files changed, 50 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index ce5a42f5db..ef87d75db9 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -139,6 +140,8 @@ namespace Nif { "BSFadeNode", &construct }, { "BSLeafAnimNode", &construct }, { "BSTreeNode", &construct }, + { "BSValueNode", &construct }, + { "BSOrderedNode", &construct }, { "BSMultiBoundNode", &construct }, { "bhkBlendController", &construct }, { "NiFloatInterpolator", &construct }, @@ -158,6 +161,7 @@ namespace Nif { "BSFurnitureMarkerNode", &construct }, { "NiCollisionObject", &construct }, { "bhkCollisionObject", &construct }, + { "bhkSPCollisionObject", &construct }, { "BSDismemberSkinInstance", &construct }, { "NiControllerManager", &construct }, { "bhkMoppBvTreeShape", &construct }, @@ -166,6 +170,8 @@ namespace Nif { "hkPackedNiTriStripsData", &construct }, { "bhkConvexVerticesShape", &construct }, { "bhkConvexTransformShape", &construct }, + { "bhkTransformShape", &construct }, + { "bhkSimpleShapePhantom", &construct }, { "bhkBoxShape", &construct }, { "bhkCapsuleShape", &construct }, { "bhkSphereShape", &construct }, diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index e4ad8727c3..500bb532da 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -89,6 +89,7 @@ namespace Nif } void read(osg::Vec3f& data) { readLittleEndianBufferOfType<3, float>(inp, data._v); } + void read(osg::Vec4f& data) { readLittleEndianBufferOfType<4, float>(inp, data._v); } template T get() diff --git a/components/nif/node.cpp b/components/nif/node.cpp index 09e1e1589d..91922c4e43 100644 --- a/components/nif/node.cpp +++ b/components/nif/node.cpp @@ -483,4 +483,18 @@ namespace Nif nif->read(mEyeData); } } + + void BSValueNode::read(NIFStream* nif) + { + NiNode::read(nif); + nif->read(mValue); + nif->read(mValueFlags); + } + + void BSOrderedNode::read(NIFStream* nif) + { + NiNode::read(nif); + nif->read(mAlphaSortBound); + nif->read(mStaticBound); + } } diff --git a/components/nif/node.hpp b/components/nif/node.hpp index c3e0172896..801728c201 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -377,5 +377,20 @@ namespace Nif void post(Reader& nif) override; }; + struct BSValueNode : NiNode + { + unsigned int mValue; + char mValueFlags; + + void read(NIFStream* nif) override; + }; + + struct BSOrderedNode : NiNode + { + osg::Vec4f mAlphaSortBound; + char mStaticBound; + + void read(NIFStream* nif) override; + }; } // Namespace #endif diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index d6d063e8a9..58e07fcf71 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -440,4 +440,12 @@ namespace Nif mBodyFlags = nif->getUShort(); } + void bhkSimpleShapePhantom::read(NIFStream* nif) + { + bhkWorldObject::read(nif); + nif->skip(8); // Unused + std::vector mat; + nif->readVector(mat, 16); + mTransform.set(mat.data()); + } } // Namespace diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index cdabcd8bd1..3124e05692 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -426,5 +426,10 @@ namespace Nif void read(NIFStream* nif) override; }; + struct bhkSimpleShapePhantom : public bhkWorldObject + { + osg::Matrixf mTransform; + void read(NIFStream* nif) override; + }; } // Namespace #endif diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 88de60ed00..1185008ce2 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -138,6 +138,7 @@ namespace Nif RC_hkPackedNiTriStripsData, RC_bhkConvexVerticesShape, RC_bhkConvexTransformShape, + RC_bhkSimpleShapePhantom, RC_bhkBoxShape, RC_bhkCapsuleShape, RC_bhkSphereShape, From ed532b5aca6d0a9fb9294122ae36af96b2e5bafa Mon Sep 17 00:00:00 2001 From: alekulyn Date: Mon, 10 Jul 2023 17:58:32 -0500 Subject: [PATCH 2/5] Add BSEffectShaderPropertyFloatController record reading --- components/nif/controller.cpp | 6 ++++++ components/nif/controller.hpp | 6 ++++++ components/nif/niffile.cpp | 4 +++- components/nif/physics.cpp | 8 ++++---- components/nif/record.hpp | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/components/nif/controller.cpp b/components/nif/controller.cpp index 32291b8c12..8dfdebb923 100644 --- a/components/nif/controller.cpp +++ b/components/nif/controller.cpp @@ -637,4 +637,10 @@ namespace Nif mScaleValue = 1.f; } } + + void BSEffectShaderPropertyFloatController::read(NIFStream* nif) + { + NiFloatInterpController::read(nif); + nif->read(mControlledVariable); + } } diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 3f9c054906..40f0d9a949 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -406,5 +406,11 @@ namespace Nif void read(NIFStream* nif) override; }; + struct BSEffectShaderPropertyFloatController : public NiFloatInterpController + { + unsigned int mControlledVariable; + + void read(NIFStream* nif) override; + }; } // Namespace #endif diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index ef87d75db9..3034df7aab 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -17,6 +16,7 @@ #include "effect.hpp" #include "exception.hpp" #include "extra.hpp" +#include "node.hpp" #include "physics.hpp" #include "property.hpp" @@ -198,6 +198,8 @@ namespace Nif { "BSMultiBoundSphere", &construct }, { "BSInvMarker", &construct }, { "BSTriShape", &construct }, + { "BSEffectShaderPropertyFloatController", + &construct }, }; } diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index 58e07fcf71..9636ec22da 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -327,8 +327,8 @@ namespace Nif mHavokMaterial.read(nif); mRadius = nif->getFloat(); nif->skip(8); // Unused - std::vector mat; - nif->getFloats(mat, 16); + std::array mat; + nif->readArray(mat); mTransform.set(mat.data()); } @@ -444,8 +444,8 @@ namespace Nif { bhkWorldObject::read(nif); nif->skip(8); // Unused - std::vector mat; - nif->readVector(mat, 16); + std::array mat; + nif->readArray(mat); mTransform.set(mat.data()); } } // Namespace diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 1185008ce2..4a57070924 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -165,6 +165,7 @@ namespace Nif RC_BSMultiBoundSphere, RC_BSInvMarker, RC_BSTriShape, + RC_BSEffectShaderPropertyFloatController, }; /// Base class for all records From 589726d4f8ec1489731cb5c95a8ee8f6a929594b Mon Sep 17 00:00:00 2001 From: alekulyn Date: Mon, 10 Jul 2023 18:12:00 -0500 Subject: [PATCH 3/5] Enchanting table fully ready --- components/nif/controller.cpp | 6 ++++++ components/nif/controller.hpp | 7 +++++++ components/nif/niffile.cpp | 4 ++++ components/nif/record.hpp | 1 + 4 files changed, 18 insertions(+) diff --git a/components/nif/controller.cpp b/components/nif/controller.cpp index 8dfdebb923..45b734c189 100644 --- a/components/nif/controller.cpp +++ b/components/nif/controller.cpp @@ -643,4 +643,10 @@ namespace Nif NiFloatInterpController::read(nif); nif->read(mControlledVariable); } + + void BSEffectShaderPropertyColorController::read(NIFStream* nif) + { + NiPoint3InterpController::read(nif); + nif->read(mControlledColor); + } } diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 40f0d9a949..2ec4dcb439 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -412,5 +412,12 @@ namespace Nif void read(NIFStream* nif) override; }; + + struct BSEffectShaderPropertyColorController : public NiPoint3InterpController + { + unsigned int mControlledColor; + + void read(NIFStream* nif) override; + }; } // Namespace #endif diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 3034df7aab..1dbd14daeb 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -200,6 +200,10 @@ namespace Nif { "BSTriShape", &construct }, { "BSEffectShaderPropertyFloatController", &construct }, + { "BSLightingShaderPropertyFloatController", + &construct }, + { "BSEffectShaderPropertyColorController", + &construct }, }; } diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 4a57070924..a27c309f11 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -166,6 +166,7 @@ namespace Nif RC_BSInvMarker, RC_BSTriShape, RC_BSEffectShaderPropertyFloatController, + RC_BSEffectShaderPropertyColorController, }; /// Base class for all records From 4b90352c2f8f9d7dbea693b27a6bcfad937b0289 Mon Sep 17 00:00:00 2001 From: alekulyn Date: Mon, 10 Jul 2023 19:11:28 -0500 Subject: [PATCH 4/5] Add RC value to BSLightingShaderPropertyFloatController and change the revelant RC value in niffile --- components/nif/niffile.cpp | 2 +- components/nif/record.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 1dbd14daeb..3e34e64a5e 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -201,7 +201,7 @@ namespace Nif { "BSEffectShaderPropertyFloatController", &construct }, { "BSLightingShaderPropertyFloatController", - &construct }, + &construct }, { "BSEffectShaderPropertyColorController", &construct }, }; diff --git a/components/nif/record.hpp b/components/nif/record.hpp index a27c309f11..b5319d2b2f 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -167,6 +167,7 @@ namespace Nif RC_BSTriShape, RC_BSEffectShaderPropertyFloatController, RC_BSEffectShaderPropertyColorController, + RC_BSLightingShaderPropertyFloatController, }; /// Base class for all records From b085a5268124bc51c93aaeb6614a040ca73663b4 Mon Sep 17 00:00:00 2001 From: alekulyn Date: Mon, 10 Jul 2023 19:25:52 -0500 Subject: [PATCH 5/5] Add template Nif record --- components/nif/niffile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 3e34e64a5e..4fc624d609 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -162,6 +162,7 @@ namespace Nif { "NiCollisionObject", &construct }, { "bhkCollisionObject", &construct }, { "bhkSPCollisionObject", &construct }, + { "bhkPCollisionObject", &construct }, { "BSDismemberSkinInstance", &construct }, { "NiControllerManager", &construct }, { "bhkMoppBvTreeShape", &construct },