Skip to main content
GameDev.net gamedev.net
🔒 Locked

fbx importer bone index?

Started by giugio Aug 13, 2010 at 11:44 AM 2 replies 4.1k views
Original Post
giugio
giugio
Hy.
I have created a fbx for skinned mesh importer.
My problem is that i can't find the bones index of any bone in the skeleton , these bone index are for to be clear the values to send as boneindexes in the vertex structure:
Position
Normal
BoneIndexes
Wheights
ecc....
, i try to use an incremental value in the traverse of the skeleton but i see that is not correct.
sebbit
sebbit
Are you using the FBX SDK to import the FBX? If so, you need to loop through every meshes skin deformers and any such deformers clusters. Each cluster is linked to a node and has a list of control points (vertices) it influences and a weight for each control point. So, how to get the bone indices depends on how you store the nodes. If you store the nodes as a list your bone index would be the index of the clusters linked node in that list.
giugio
giugio
thanks sebbit , but i don't know how the 3ds 2011 export the fbx , so i don't know the bone index?
Have you experience?
Thanks.
giugio
giugio
Hy,
Is 3 day that i search for a system for get the bone index in fbx , i use this code for process clusters:
void CFbxLoader::Process_clusters( map<int, std::vector<BoneWeightPair> >*pMapBoneWeight){		if (!m_pCurrentMesh->GetDeformerCount())		return;	KFbxDeformer *pDef = m_pCurrentMesh->GetDeformer(0);	KFbxDeformer::EDeformerType defType = pDef->GetDeformerType();		KFbxSkin *pSkin = dynamic_cast<KFbxSkin*>(pDef);	int clusterCount = pSkin->GetClusterCount();			for (int i = 0 ; i < clusterCount ; i++)	{		KFbxCluster *pCluster = pSkin->GetCluster(i);		KFbxCluster::ELinkMode lClusterMode = pCluster->GetLinkMode();		const char *boneName = pCluster->GetLink()->GetName();					CBone* pBone = CSkeleton::GetInstance()->GetBone(boneName);		pBone->setIndex(i);		KFbxXMatrix kLinkMatrix;		pCluster->GetTransformLinkMatrix(kLinkMatrix);		KFbxXMatrix kTM;		pCluster->GetTransformMatrix(kTM);		KFbxXMatrix kInvLinkMatrix(kLinkMatrix.Inverse());		KFbxXMatrix kM(kInvLinkMatrix * kTM);			KFbxXMatrix kMTrans = kM.Transpose();		Matrix4f* mRes = new Matrix4f();		double* dtest =(double*) kLinkMatrix.mData;		int indexCount = pCluster->GetControlPointIndicesCount();		int *indices = pCluster->GetControlPointIndices();		double *weights = pCluster->GetControlPointWeights();		for (int j = 0 ; j < indexCount ; j++)		{			int vertex = indices[j];			float weight = (float)weights[j];			BoneWeightPair pairBF;							pairBF.nBone = pBone->getIndex();			pairBF.fWeight = weight;			(*pMapBoneWeight)[vertex].push_back(pairBF);		}	}	}I use the name of the bone for get the bone from the skeleton (i use a singleton for share skeleton)map but the map is ordered and i can't find an unordered map (i use vc++ 2008)may be the problem?i post this code:  const char *boneName = pCluster->GetLink()->GetName();			  CBone* pBone = CSkeleton::GetInstance()->GetBone(boneName);  pBone->setIndex(i);

and i set the current index with pBone->setIndex(i);
After i sort the map for the index , but this don't work.
I read 12412423482309578 time your post sebbit , but i'm not understand ,because i have a real bad english , but how i get the index of the bone?

thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.