Jump to content
  • Advertisement
Sign in to follow this  
nini

Mesh skinning in software

This topic is 4761 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!