Sign in to follow this  
Vorda

[MDX] Skinned Mesh Loading

Recommended Posts

Vorda    122
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
Quaid Tseng    123
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[i].Stream == 0xff)
break;
if( elems[i].Type == D3DDECLTYPE_FLOAT3 && elems[i].Usage == D3DDECLUSAGE_POSITION && elems[i].UsageIndex == 0 )bFVF_POSITION = TRUE;
if( elems[i].Type == D3DDECLTYPE_FLOAT4 && elems[i].Usage == D3DDECLUSAGE_POSITIONT && elems[i].UsageIndex == 0 )bFVF_POSITIONT = TRUE;
if( elems[i].Usage == D3DDECLUSAGE_BLENDWEIGHT)bFVF_BLENDWEIGHT = TRUE;
if( elems[i].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
Vorda    122
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this