Original Post
I am using Jim Adams' Advanced Animation. I create 3d model in gameSpace (trueSpace addon) - model and jointed skeleton (skinned model). Then I save this model to X file. When I test my model with ParseFrame.exe and ParseMesh.exe - everything is okay - model is skinned and has skeleton in it. But when I load it to my application everything okay till function UpdateMesh runs. It works for TINY.X but not for my models: Also, please, tell what tool is better to use for creating skinned skeleton model and saving it to right X file. Right now I am using gameSpace - but it is not very convient and I have errors with custom models. [Edited by - Coder on October 27, 2005 10:54:24 AM]
HRESULT UpdateMesh(D3DXMESHCONTAINER_EX *pMesh)
{
// Error checking
if(!pMesh) return E_FAIL;
if(!pMesh->MeshData.pMesh || !pMesh->pSkinMesh || !pMesh->pSkinInfo) return E_FAIL;
if(!pMesh->pBoneMatrices || !pMesh->ppFrameMatrices) return E_FAIL;
// Copy the bone matrices over (must have been combined before call DrawMesh)
for(DWORD i=0;i<pMesh->pSkinInfo->GetNumBones();i++) {
// Start with bone offset matrix
pMesh->pBoneMatrices = (*pMesh->pSkinInfo->GetBoneOffsetMatrix(i));
// Apply frame transformation
if(pMesh->ppFrameMatrices)
pMesh->pBoneMatrices *= (*pMesh->ppFrameMatrices);
}
// Lock the meshes' vertex buffers
void *SrcPtr, *DestPtr;
pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&SrcPtr);
pMesh->pSkinMesh->LockVertexBuffer(0, (void**)&DestPtr);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ERROR IS HERE
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Update the skinned mesh using provided transformations
pMesh->pSkinInfo->UpdateSkinnedMesh(pMesh->pBoneMatrices, NULL, SrcPtr, DestPtr);
// Unlock the meshes vertex buffers
pMesh->pSkinMesh->UnlockVertexBuffer();
pMesh->MeshData.pMesh->UnlockVertexBuffer();
// Return success
return S_OK;
}