|
|
|
@ -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);
|
|
|
|
|
|
|
|
|
|
// Insert in the map
|
|
|
|
|
weightMap.insert (std::map<float, INode*>::value_type (weight, 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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Get the bind matrix of the bone
|
|
|
|
|
Matrix3 bindPos;
|
|
|
|
|
int res=physiqueInterface->GetInitNodeTM (bone, bindPos);
|
|
|
|
|
nlassert (res==MATRIX_RETURNED);
|
|
|
|
|
INode *bone = blendedInterface->GetNode(boneIndex);
|
|
|
|
|
|
|
|
|
|
// Add an entry inthe map
|
|
|
|
|
if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second)
|
|
|
|
|
if (bone == NULL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef NL_DEBUG
|
|
|
|
|
// *** Debug info
|
|
|
|
|
|
|
|
|
|
// Bone name
|
|
|
|
|
std::string boneName=getName (*bone);
|
|
|
|
|
|
|
|
|
|
// Local matrix
|
|
|
|
|
Matrix3 nodeTM;
|
|
|
|
|
nodeTM=bone->GetNodeTM (0);
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
nlwarning("bone == NULL; boneIndex = %i / %i", boneIndex, count);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Get the bind matrix of the bone
|
|
|
|
|
Matrix3 bindPos;
|
|
|
|
|
int res = physiqueInterface->GetInitNodeTM (bone, bindPos);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add an entry inthe map
|
|
|
|
|
if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second)
|
|
|
|
|
{
|
|
|
|
|
#ifdef NL_DEBUG
|
|
|
|
|
// *** Debug info
|
|
|
|
|
|
|
|
|
|
// Bone name
|
|
|
|
|
std::string boneName=getName (*bone);
|
|
|
|
|
|
|
|
|
|
// Local matrix
|
|
|
|
|
Matrix3 nodeTM;
|
|
|
|
|
nodeTM=bone->GetNodeTM (0);
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|