# Q: Bones, Skins, D3DXFRAME and D3DXMESHCONTAINER

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

## Recommended Posts

Hi. I've been reading about how DirectX handles model skinning and skeleton-based animation, and I know about the general principles, in the sense that I understand what kind of data needs to be stored in order for it to work. To my understanding, each bone (or null-node/joint) basically defines a local referent coordinate system - a frame of reference, so that the local transformations are easily stored as matrices; this, coupled with the weights assigned to the vertices then enables the model to be animated. I also read that a world-space space snapshot of the bones an the mesh, called Bind Pose Matrix, is taken at the moment of binding, and that this enables each vertex to be transformed in the following way: object-space local vertex ---> world-space vertex ---> bone-space local vertex. This is when the local transforms can be applied.
Is this correct so far?

DirectX calls this the mesh hierarchy. Now, what I don't understand is how exactly is all this data stored...
For example, take the D3DXFRAME structure:

typedef struct D3DXFRAME { LPSTR Name; D3DXMATRIX TransformationMatrix; LPD3DXMESHCONTAINER pMeshContainer; D3DXFRAME *pFrameSibling; D3DXFRAME *pFrameFirstChild; } D3DXFRAME, *LPD3DXFRAME; 

I understand that pFrameFirstChild and pFrameSibiling enable the traversal of the hierarchy, but what exactly is referenced by a pMeshContainer?
typedef struct D3DXMESHCONTAINER { LPSTR Name; D3DXMESHDATA MeshData; // this is what I'm interested in LPD3DXMATERIAL pMaterials; LPD3DXEFFECTINSTANCE pEffects; DWORD NumMaterials; DWORD *pAdjacency; LPD3DXSKININFO pSkinInfo; // this is what I'm interested in D3DXMESHCONTAINER *pNextMeshContainer; } D3DXMESHCONTAINER, *LPD3DXMESHCONTAINER; 
Where is binding data, or vertex weight data stored? (Or how?)
The docs say that MeshData contains the "Type of data in the mesh", but the D3DXMESHDATA struct contains a LPD3DXMESH pointer... Does this point to the entire mesh vertex complex? Or what? Is this shared among all mesh containers? And what exactly is the purpose of a mesh container? Does it "contains" only the vertices affected by a particular frame? How is all this defined, how it all works together?
I hope the question is clear enough, I'm a bit confused by all this.

P.S. If you know of some articles where this is discussed in detail, I would appreciate a link.

##### Share on other sites
Sometimes I use D3DXLoadMeshHierarchyFromX() function. You know, this function calls CreateFrame(), DestroyFrame(), CreateMeshContainer() and DestroyMeshContainer(). I perform some calculations and conversions in these functions. Now I'll reply some of your questions over'em.

Where is binding data, or vertex weight data stored? (Or how?) [/quote]
In CreateMeshContainer(), I check existance of pSkinInfo; if it's not NULL, I call pSkinInfo->ConvertToIndexedBlendedMesh(). This function calculates (or reads) the index and weigh data for each vertex of corresponding mesh container.

The docs say that MeshData contains the "Type of data in the mesh", but the D3DXMESHDATA struct contains a LPD3DXMESH pointer... Does this point to the entire mesh vertex complex? Or what? Is this shared among all mesh containers? [/quote]
D3DXMESHDATA contains type of mesh (classic mesh or patched one) and the mesh object that I described above (skinned or not)

And what exactly is the purpose of a mesh container? Does it "contains" only the vertices affected by a particular frame? How is all this defined, how it all works together?[/quote]
The mesh container holds the affected vertices of a frame while animating. Also you can name it as a "skin" of a bone.

Other experts can correct if I'm wrong.

hth.
-R

##### Share on other sites
If you haven't already , check out these 2 links which have some really good info on this topic ( +source code too)

Clicky 1

clicky 2 ( note that here he has implemented cpu skinning , not gpu)

hope its useful

Manpreet

• 38
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631364
• Total Posts
2999579
×