• Advertisement
Sign in to follow this  

Mesh skinning in software

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

hi all , i'm trying to implement skinned mesh with dx9 , i know the background theory and the interfaces of dx9 but i'm facing a problem with the code below (tiny.x display in a fuzzy manner like the vertex data are not well transformed by the transform matrices ?) precision : the flow is Render() wich call Update() wich call ID3DXAnimationController->Advance() , SetupBoneMatrices() and UpdateMatricesBySoftware(). here is the code : void CSkinnedMesh::UpdateMatricesBySoftware(meshContainer *m) { ppTransformMatrices = new D3DXMATRIXA16[m->nBones]; for(UINT i=0;i<m->nBones;i++) { frame *f = reinterpret_cast<frame*>(D3DXFrameFind(root,m->pSkinInfo->GetBoneName(i))); D3DXMatrixMultiply(&ppTransformMatrices,&m->pBoneOffsetMatrices,&f->matCombined); } PBYTE *src; PBYTE *dst; m->origMesh->LockVertexBuffer(D3DLOCK_READONLY,(void**)&src); m->MeshData.pMesh->LockVertexBuffer(0,(void**)&dst); m->pSkinInfo->UpdateSkinnedMesh(ppTransformMatrices,NULL,src,dst); m->origMesh->UnlockVertexBuffer(); m->MeshData.pMesh->UnlockVertexBuffer(); } void CSkinnedMesh::SetupBoneMatrices(frame *f,D3DXMATRIX parentMatrix) { D3DXMatrixMultiply(&f->matCombined,&parentMatrix,&f->TransformationMatrix); if(f->pFrameFirstChild) SetupBoneMatrices(reinterpret_cast<frame*>(f->pFrameFirstChild),f->matCombined); if(f->pFrameSibling) SetupBoneMatrices(reinterpret_cast<frame*>(f->pFrameSibling),parentMatrix); } void CSkinnedMesh::Update(float time,meshContainer *m) { Animation->AdvanceTime(time,0); // Animation is a pointer to ID3DXAnimationController D3DXMATRIX i; D3DXMatrixIdentity(&i); SetupBoneMatrices(root,i); UpdateMatricesBySoftware(m); } D3DXFRAME *frameMesh = FindMesh(root); meshContainer *m = reinterpret_cast<meshContainer *>(frameMesh->pMeshContainer); LPD3DXMESH& mesh = m->MeshData.pMesh; Update(0.001f,m); tss(0,cop,arg1); tss(0,carg1,texture); D3DXMATRIX Identity; D3DXMatrixIdentity(&Identity); dev->SetTransform(D3DTS_WORLD, &Identity); // RENDERING DU PREMIER MESH for(UINT i=0;i<m->NumAttrib;i++) { dev->SetTexture(0,m->materials.tex); dev->SetMaterial(m->materials.mat); mesh->DrawSubset(i); } } Thanks in advance for any help ...

Share this post


Link to post
Share on other sites
Advertisement
Hi, I did a demo on just this - see the sticky topic at the top of the list - should help

Share this post


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

  • Advertisement