Parse BSDistantObjectInstancedNode

pull/3236/head
Alexei Kotov 3 months ago
parent 7149fbb408
commit 695932d2db

@ -71,6 +71,8 @@ namespace Nif
{ "BSBlastNode", &construct<BSRangeNode, RC_NiNode> },
{ "BSDamageStage", &construct<BSRangeNode, RC_NiNode> },
{ "BSDebrisNode", &construct<BSRangeNode, RC_NiNode> },
{ "BSDistantObjectInstancedNode",
&construct<BSDistantObjectInstancedNode, RC_BSDistantObjectInstancedNode> },
{ "BSFadeNode", &construct<NiNode, RC_NiNode> },
{ "BSLeafAnimNode", &construct<NiNode, RC_NiNode> },
{ "BSMasterParticleSystem", &construct<BSMasterParticleSystem, RC_NiNode> },

@ -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<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;
};
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

@ -89,6 +89,7 @@ namespace Nif
RC_BSDynamicTriShape,
RC_BSDismemberSkinInstance,
RC_BSDistantObjectExtraData,
RC_BSDistantObjectInstancedNode,
RC_BSDistantObjectLargeRefExtraData,
RC_BSEffectShaderProperty,
RC_BSEffectShaderPropertyColorController,

Loading…
Cancel
Save