mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 09:58:46 +00:00
Changed: #964 Skip over deleted bones in skinning when exporting from max.
This commit is contained in:
parent
7fe2e6f0db
commit
bfc95095af
1 changed files with 61 additions and 41 deletions
|
@ -748,15 +748,20 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt
|
||||||
{
|
{
|
||||||
if (blendedInterface)
|
if (blendedInterface)
|
||||||
{
|
{
|
||||||
// Get the bone weight
|
|
||||||
float weight=blendedInterface->GetWeight(bone);
|
|
||||||
|
|
||||||
// Get node
|
// Get node
|
||||||
INode *node=blendedInterface->GetNode(bone);
|
INode *node=blendedInterface->GetNode(bone);
|
||||||
nlassert (node);
|
if (node == NULL)
|
||||||
|
{
|
||||||
|
nlwarning("node == NULL; bone = %i / %i", bone, boneCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get the bone weight
|
||||||
|
float weight=blendedInterface->GetWeight(bone);
|
||||||
|
|
||||||
// Insert in the map
|
// Insert in the map
|
||||||
weightMap.insert (std::map<float, INode*>::value_type (weight, node));
|
weightMap.insert (std::map<float, INode*>::value_type (weight, node));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1191,49 +1196,64 @@ void CExportNel::addSkeletonBindPos (INode& skinedNode, mapBoneBindPos& boneBind
|
||||||
for (boneIndex=0; boneIndex<count; boneIndex++)
|
for (boneIndex=0; boneIndex<count; boneIndex++)
|
||||||
{
|
{
|
||||||
// Get the bone pointer
|
// Get the bone pointer
|
||||||
INode *bone=blendedInterface->GetNode(boneIndex);
|
INode *bone = blendedInterface->GetNode(boneIndex);
|
||||||
|
|
||||||
// Get the bind matrix of the bone
|
if (bone == NULL)
|
||||||
Matrix3 bindPos;
|
|
||||||
int res=physiqueInterface->GetInitNodeTM (bone, bindPos);
|
|
||||||
nlassert (res==MATRIX_RETURNED);
|
|
||||||
|
|
||||||
// Add an entry inthe map
|
|
||||||
if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second)
|
|
||||||
{
|
{
|
||||||
#ifdef NL_DEBUG
|
nlwarning("bone == NULL; boneIndex = %i / %i", boneIndex, count);
|
||||||
// *** Debug info
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get the bind matrix of the bone
|
||||||
|
Matrix3 bindPos;
|
||||||
|
int res = physiqueInterface->GetInitNodeTM (bone, bindPos);
|
||||||
|
|
||||||
// Bone name
|
if (res != MATRIX_RETURNED)
|
||||||
std::string boneName=getName (*bone);
|
{
|
||||||
|
nlwarning("res != MATRIX_RETURNED; res = %i; boneIndex = %i / %i", res, boneIndex, count);
|
||||||
|
nlwarning("bone = %i", (uint32)(void *)bone);
|
||||||
|
std::string boneName = getName (*bone);
|
||||||
|
nlwarning("boneName = %s", boneName.c_str());
|
||||||
|
nlassert(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Local matrix
|
// Add an entry inthe map
|
||||||
Matrix3 nodeTM;
|
if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second)
|
||||||
nodeTM=bone->GetNodeTM (0);
|
{
|
||||||
|
#ifdef NL_DEBUG
|
||||||
|
// *** Debug info
|
||||||
|
|
||||||
// Offset matrix
|
// Bone name
|
||||||
Matrix3 offsetScaleTM (TRUE);
|
std::string boneName=getName (*bone);
|
||||||
Matrix3 offsetRotTM (TRUE);
|
|
||||||
Matrix3 offsetPosTM (TRUE);
|
|
||||||
ApplyScaling (offsetScaleTM, bone->GetObjOffsetScale ());
|
|
||||||
offsetRotTM.SetRotate (bone->GetObjOffsetRot ());
|
|
||||||
offsetPosTM.SetTrans (bone->GetObjOffsetPos ());
|
|
||||||
Matrix3 offsetTM = offsetScaleTM * offsetRotTM * offsetPosTM;
|
|
||||||
|
|
||||||
// Local + offset matrix
|
// Local matrix
|
||||||
Matrix3 nodeOffsetTM = offsetTM * nodeTM;
|
Matrix3 nodeTM;
|
||||||
|
nodeTM=bone->GetNodeTM (0);
|
||||||
|
|
||||||
// Init TM
|
// Offset matrix
|
||||||
Matrix3 initTM;
|
Matrix3 offsetScaleTM (TRUE);
|
||||||
int res=physiqueInterface->GetInitNodeTM (bone, initTM);
|
Matrix3 offsetRotTM (TRUE);
|
||||||
nlassert (res==MATRIX_RETURNED);
|
Matrix3 offsetPosTM (TRUE);
|
||||||
|
ApplyScaling (offsetScaleTM, bone->GetObjOffsetScale ());
|
||||||
|
offsetRotTM.SetRotate (bone->GetObjOffsetRot ());
|
||||||
|
offsetPosTM.SetTrans (bone->GetObjOffsetPos ());
|
||||||
|
Matrix3 offsetTM = offsetScaleTM * offsetRotTM * offsetPosTM;
|
||||||
|
|
||||||
// invert
|
// Local + offset matrix
|
||||||
initTM.Invert();
|
Matrix3 nodeOffsetTM = offsetTM * nodeTM;
|
||||||
Matrix3 compNode=nodeTM*initTM;
|
|
||||||
Matrix3 compOffsetNode=nodeOffsetTM*initTM;
|
// Init TM
|
||||||
Matrix3 compOffsetNode2=nodeOffsetTM*initTM;
|
Matrix3 initTM;
|
||||||
|
int res=physiqueInterface->GetInitNodeTM (bone, initTM);
|
||||||
|
nlassert (res==MATRIX_RETURNED);
|
||||||
|
|
||||||
|
// invert
|
||||||
|
initTM.Invert();
|
||||||
|
Matrix3 compNode=nodeTM*initTM;
|
||||||
|
Matrix3 compOffsetNode=nodeOffsetTM*initTM;
|
||||||
|
Matrix3 compOffsetNode2=nodeOffsetTM*initTM;
|
||||||
#endif // NL_DEBUG
|
#endif // NL_DEBUG
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue