• Advertisement
Sign in to follow this  

[MDX] Skinned Mesh Loading

This topic is 4363 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

Does anyone know how to load a skinned mesh without using the Mesh.LoadHierarchyFromFile? I wrote a managed X File parser, so there is no problem with reading static meshes, frames, etc... My problem is that I don't know how to interpret SkinWeights, and create the SkinInformation object from it. I have seen that the SkinInformation class has a constructor that accepts a BoneCombination array, but I don't know how to fill it, and what is it's purpouse. Please help!

Share this post


Link to post
Share on other sites
Advertisement
Ya, You had completed the Xparser, and you had done a half!

Read mesh object in Xparser, and embedded some code using

D3DXLoadSkinMeshFromXof(pDXData, D3DXMESH_SYSTEMMEM,pD3DDevice,
&AdjacencyBuffer,
&MaterialBuffer, NULL,
&NumMaterials,
&pSkin,
&pLoadMesh)



It loads the SkinInfo for you. And now you should examine
the SkinInfo for details.

To see it's content, use GetDeclaration()like

D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE];
LPD3DVERTEXELEMENT9 pDecl;
pMeshCon->pSkinInfo->GetDeclaration(elems);
for(DWORD i = 0; i < MAX_FVF_DECL_SIZE; ++i)
{
// Did we reach D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED, 0,0,0}?
if(elems.Stream == 0xff)
break;
if( elems.Type == D3DDECLTYPE_FLOAT3 && elems.Usage == D3DDECLUSAGE_POSITION && elems.UsageIndex == 0 )bFVF_POSITION = TRUE;
if( elems.Type == D3DDECLTYPE_FLOAT4 && elems.Usage == D3DDECLUSAGE_POSITIONT && elems.UsageIndex == 0 )bFVF_POSITIONT = TRUE;
if( elems.Usage == D3DDECLUSAGE_BLENDWEIGHT)bFVF_BLENDWEIGHT = TRUE;
if( elems.Usage == D3DDECLUSAGE_BLENDINDICES)bFVF_BLENDINDICES = TRUE;
}




If the format of SkinInfo and mesh doesn't match your requirements, you can clone one just like

if(pMeshCon->pSkinInfo){
D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE];
LPD3DVERTEXELEMENT9 pDecl;
pMeshCon->pSkinInfo->GetDeclaration(elems);
pDecl = elems;
if( FAILED(pMeshCon->MeshData.pMesh->CloneMesh(D3DXMESH_SYSTEMMEM, //D3DXMESH_MANAGED,
pDecl
x_pD3DDevice, &pMeshCon->pSkinMesh)))assert(0);
}




From the above I just show the way to examine the content of skininfo.
To load animation, enumerate the animation data objects in Xparser, and combine those matrix, update bone hierrarchy,
and last updateskinnedmesh, then done! :)

Share this post


Link to post
Share on other sites
Thanx for the info, but my problem is that I'm using Managed DX, and I don't have the D3DXLoadSkinMeshFromXof function that returns the SkinInfo object. In fact, I don't have any function or mesh constructor that returns the SkinInfo object. That's why I wan't to create it manually, and for that i need to know how to fill the BoneCombination array, do you maybe know how to fill it, or what it represents?

Share this post


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

  • Advertisement