|
|
@ -170,18 +170,26 @@ namespace SceneUtil
|
|
|
|
osg::Vec3Array* normalDst = static_cast<osg::Vec3Array*>(geom.getNormalArray());
|
|
|
|
osg::Vec3Array* normalDst = static_cast<osg::Vec3Array*>(geom.getNormalArray());
|
|
|
|
osg::Vec4Array* tangentDst = static_cast<osg::Vec4Array*>(geom.getTexCoordArray(7));
|
|
|
|
osg::Vec4Array* tangentDst = static_cast<osg::Vec4Array*>(geom.getTexCoordArray(7));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<osg::Matrixf> boneMatrices(mNodes.size());
|
|
|
|
|
|
|
|
std::vector<Bone*>::const_iterator bone = mNodes.begin();
|
|
|
|
|
|
|
|
std::vector<BoneInfo>::const_iterator boneInfo = mData->mBones.begin();
|
|
|
|
|
|
|
|
for (osg::Matrixf& boneMat : boneMatrices)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (*bone != nullptr)
|
|
|
|
|
|
|
|
boneMat = boneInfo->mInvBindMatrix * (*bone)->mMatrixInSkeletonSpace;
|
|
|
|
|
|
|
|
++bone;
|
|
|
|
|
|
|
|
++boneInfo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& [influences, vertices] : mData->mInfluences)
|
|
|
|
for (const auto& [influences, vertices] : mData->mInfluences)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
osg::Matrixf resultMat(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
|
|
|
|
osg::Matrixf resultMat(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& [index, weight] : influences)
|
|
|
|
for (const auto& [index, weight] : influences)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const Bone* bone = mNodes[index];
|
|
|
|
if (mNodes[index] == nullptr)
|
|
|
|
if (bone == nullptr)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const float* boneMatPtr = boneMatrices[index].ptr();
|
|
|
|
osg::Matrixf boneMat = mData->mBones[index].mInvBindMatrix * bone->mMatrixInSkeletonSpace;
|
|
|
|
|
|
|
|
float* boneMatPtr = boneMat.ptr();
|
|
|
|
|
|
|
|
float* resultMatPtr = resultMat.ptr();
|
|
|
|
float* resultMatPtr = resultMat.ptr();
|
|
|
|
for (int i = 0; i < 16; ++i, ++resultMatPtr, ++boneMatPtr)
|
|
|
|
for (int i = 0; i < 16; ++i, ++resultMatPtr, ++boneMatPtr)
|
|
|
|
if (i % 4 != 3)
|
|
|
|
if (i % 4 != 3)
|
|
|
|