Changed: #964 Skip over deleted bones in skinning when exporting from max.

This commit is contained in:
kaetemi 2010-09-01 15:15:30 +02:00
parent e3ea920741
commit f362c9363b

View file

@ -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)
{
// Insert in the map nlwarning("node == NULL; bone = %i / %i", bone, boneCount);
weightMap.insert (std::map<float, INode*>::value_type (weight, node)); }
else
{
// Get the bone weight
float weight=blendedInterface->GetWeight(bone);
// Insert in the map
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
}
} }
} }
} }