Jump to content
  • Advertisement
Sign in to follow this  
giugio

bone matrix and fbx

This topic is 3040 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.
I'm doing an FBX importer for skinned meshes.
I have a problem in the code section where I'm going to read the weight(posted later).
The problem is that some bones do not appear in the loop, then I can not read their local matrix inverse.

const char *boneName = cluster->GetLink()->GetName();



These bones, however, 'have an animation that I read correctly.
In the skinned animation I multiply the matrix of bone for the final matrix which is calculated by multiplying the bones fathers cyclically.
How to manage these bones which I don't know the local matrix inverse?
I can use the identity matrix???
Thank you.

static void process_clusters(KFbxMesh *mesh)
{
if (!mesh->GetDeformerCount())
return;

KFbxDeformer *def = mesh->GetDeformer(0);

KFbxDeformer::EDeformerType defType = def->GetDeformerType();
assert(defType == KFbxDeformer::eSKIN);

KFbxSkin *skin = KFbxCast<KFbxSkin>(def);
int clusterCount = skin->GetClusterCount();

for (int i = 0 ; i < clusterCount ; i++)
{
KFbxCluster *cluster = skin->GetCluster(i);
KFbxCluster::ELinkMode lClusterMode = cluster->GetLinkMode();
const char *boneName = cluster->GetLink()->GetName();

KFbxXMatrix kLinkMatrix;
cluster->GetTransformLinkMatrix(kLinkMatrix);
KFbxXMatrix kTM;
cluster->GetTransformMatrix(kTM);
KFbxXMatrix kInvLinkMatrix(kLinkMatrix.Inverse());
KFbxXMatrix kM(kInvLinkMatrix * kTM);

invBindPose[boneName] = kM;
bindPose[boneName] = kM.Inverse();

int indexCount = cluster->GetControlPointIndicesCount();
int *indices = cluster->GetControlPointIndices();
double *weights = cluster->GetControlPointWeights();

int bone = boneMap[boneName];

for (int j = 0 ; j < indexCount ; j++)
{
int vertex = indices[j];
float weight = (float)weights[j];

BoneWeightPair pair;
pair.bone = bone;
pair.weight = weight;

boneWeights[vertex].push_back(pair);
}
}
}





ps.
I have rename the bone names in 3ds and reexport all, may be the problem?

[Edited by - giugio on August 23, 2010 6:08:13 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
How to manage these bones which I don't know the local matrix inverse?
I can use the identity matrix???

You can't just use an identity matrix. The inverse of the bone's local matrix is what transforms the rest pose mesh vertices to the origin so animation transformations are correctly applied.

Share this post


Link to post
Share on other sites
therefore may be a problem caused by the renaming of bones?
in fact after being saved and renamed exported fbx, renamed bones lose all matrixes, even if the Conservatives for animation.
If you have a system in 3ds to recalculate the matrices of bones after i renamed they?
thanks

Share this post


Link to post
Share on other sites
I'm afraid I can't help you with the specifics of 3ds or fbx. Just wanted to let you know that you must have each bone's base matrix. [sad]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!