Lost
11-27-2006, 01:30 AM
Does anyone understand the math behind the DX9 function UpdateSkinnedMesh() ?
How are these new matrices applied to the vertex buffer, programmically?
Reason I'm asking, is I might try to do it myself if I can't get UpdateSkinnedMesh to work.
for (UINT i = 0; i < Bones; ++i)
D3DXMatrixMultiply(&m_boneMatrices[i],&pMesh->exBoneOffsets[i], pMesh->exFrameCombinedMatrixPointer[i]);
void *srcPtr;
void *destPtr;
pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&srcPtr);
pMesh->exSkinMesh->LockVertexBuffer(0, (void**)&destPtr);
pMesh->pSkinInfo->UpdateSkinnedMesh( m_boneMatrices, NULL, srcPtr, destPtr );
pMesh->exSkinMesh->UnlockVertexBuffer();
pMesh->MeshData.pMesh->UnlockVertexBuffer();
Couple questions on the above code:
1. If I have only one mesh, can the source and dest vertex buffers be the same?
2. If I set all the m_boneMatrices matrices to Identity and call UpdateSkinnedMesh,
will my vertex buffer change? (just as an experiment)
Because I tried both 1&2, and some of my vertices change, like get
zeroed out. Not sure what is happening. Matrices look ok.
How are these new matrices applied to the vertex buffer, programmically?
Reason I'm asking, is I might try to do it myself if I can't get UpdateSkinnedMesh to work.
for (UINT i = 0; i < Bones; ++i)
D3DXMatrixMultiply(&m_boneMatrices[i],&pMesh->exBoneOffsets[i], pMesh->exFrameCombinedMatrixPointer[i]);
void *srcPtr;
void *destPtr;
pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&srcPtr);
pMesh->exSkinMesh->LockVertexBuffer(0, (void**)&destPtr);
pMesh->pSkinInfo->UpdateSkinnedMesh( m_boneMatrices, NULL, srcPtr, destPtr );
pMesh->exSkinMesh->UnlockVertexBuffer();
pMesh->MeshData.pMesh->UnlockVertexBuffer();
Couple questions on the above code:
1. If I have only one mesh, can the source and dest vertex buffers be the same?
2. If I set all the m_boneMatrices matrices to Identity and call UpdateSkinnedMesh,
will my vertex buffer change? (just as an experiment)
Because I tried both 1&2, and some of my vertices change, like get
zeroed out. Not sure what is happening. Matrices look ok.