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 d0388890e9
commit 773d034a30

View file

@ -748,15 +748,20 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt
{
if (blendedInterface)
{
// Get the bone weight
float weight=blendedInterface->GetWeight(bone);
// Get node
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
weightMap.insert (std::map<float, INode*>::value_type (weight, node));
// Insert in the map
weightMap.insert (std::map<float, INode*>::value_type (weight, node));
}
}
else
{
@ -1191,49 +1196,64 @@ void CExportNel::addSkeletonBindPos (INode& skinedNode, mapBoneBindPos& boneBind
for (boneIndex=0; boneIndex<count; boneIndex++)
{
// Get the bone pointer
INode *bone=blendedInterface->GetNode(boneIndex);
INode *bone = blendedInterface->GetNode(boneIndex);
// Get the bind matrix of the bone
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)
if (bone == NULL)
{
#ifdef NL_DEBUG
// *** Debug info
nlwarning("bone == NULL; boneIndex = %i / %i", boneIndex, count);
}
else
{
// Get the bind matrix of the bone
Matrix3 bindPos;
int res = physiqueInterface->GetInitNodeTM (bone, bindPos);
// Bone name
std::string boneName=getName (*bone);
if (res != MATRIX_RETURNED)
{
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
Matrix3 nodeTM;
nodeTM=bone->GetNodeTM (0);
// Add an entry inthe map
if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second)
{
#ifdef NL_DEBUG
// *** Debug info
// Offset matrix
Matrix3 offsetScaleTM (TRUE);
Matrix3 offsetRotTM (TRUE);
Matrix3 offsetPosTM (TRUE);
ApplyScaling (offsetScaleTM, bone->GetObjOffsetScale ());
offsetRotTM.SetRotate (bone->GetObjOffsetRot ());
offsetPosTM.SetTrans (bone->GetObjOffsetPos ());
Matrix3 offsetTM = offsetScaleTM * offsetRotTM * offsetPosTM;
// Bone name
std::string boneName=getName (*bone);
// Local + offset matrix
Matrix3 nodeOffsetTM = offsetTM * nodeTM;
// Local matrix
Matrix3 nodeTM;
nodeTM=bone->GetNodeTM (0);
// Init TM
Matrix3 initTM;
int res=physiqueInterface->GetInitNodeTM (bone, initTM);
nlassert (res==MATRIX_RETURNED);
// Offset matrix
Matrix3 offsetScaleTM (TRUE);
Matrix3 offsetRotTM (TRUE);
Matrix3 offsetPosTM (TRUE);
ApplyScaling (offsetScaleTM, bone->GetObjOffsetScale ());
offsetRotTM.SetRotate (bone->GetObjOffsetRot ());
offsetPosTM.SetTrans (bone->GetObjOffsetPos ());
Matrix3 offsetTM = offsetScaleTM * offsetRotTM * offsetPosTM;
// invert
initTM.Invert();
Matrix3 compNode=nodeTM*initTM;
Matrix3 compOffsetNode=nodeOffsetTM*initTM;
Matrix3 compOffsetNode2=nodeOffsetTM*initTM;
// Local + offset matrix
Matrix3 nodeOffsetTM = offsetTM * nodeTM;
// Init TM
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
}
}
}
}