My mesh is not animated properly

Started by
10 comments, last by kurlyak 14 years, 5 months ago
I made a walking animation based on Biped in 3ds Max. Program MeshView animate my model properly. But my program is not. In my program mesh of Biped separated. Biped is motion and mesh at a standstill. I am insert my animation in the example of the SDK SkinMesh - everything works. Also in my program put mesh Tiny - everything works too. And mesh motion and Biped but in my program motin only Biped. In what could be the problem? My animation code made on the basis of article http://www.gamedev.net/reference/articles/article2079.asp
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.
Advertisement
Just for clarification, is your "animation" in DirectX x-file format?

Also, when you say the "Biped" moves, but not the mesh - is "Biped" the bone/joint structure of your model?

If the SDK SkinMesh properly displays tiny.x and yourModel.x, then you can compare your program to the SDK example to make sure they handle the loading and animation similarly.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Thank you for your reply. I tried to compare their program with SkinnedMesh from the DirectX SDK but my level of knowledge is not high enough to understand that in this example. It is for me without assistance - very vague. My animation file was indeed converted 3dS Max X file in DirectX.
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.
How about the question:
Quote:when you say the "Biped" moves, but not the mesh - is "Biped" the bone/joint structure of your model?

I emphasize that because, if the joint/bone structure moves and the mesh does not, it implies that you're not properly accessing the skin info data which determines which vertex indices are associated with each bone.

If you don't fully understand how to animate an x-file, then, if the SDK example works for your model, you can use that example as the basis for your program, eliminating code you don't need. There is absolutely nothing wrong with modifying existing code that works!

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

My program same SkinnedMesh program except that I do not use the function ConvertToBlendedMesh () - may be the reason?
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.
My program same SkinnedMesh program except that I do not use the function ConvertToBlendedMesh () - may be the reason?
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.
My program same SkinnedMesh program except that I do not use the function ConvertToBlendedMesh () - may be the reason?
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.
You should use the ConvertToIndexedBlendedMesh method of the skin info pointer.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I added CAllocateHierarchy:: CreateMeshContainer () line

pMeshContainer->MeshData.pMesh->GetAttributeTable(NULL, &pMeshContainer->NumAttributeGroups);

delete[] pMeshContainer->pAttributeTable;
pMeshContainer->pAttributeTable = new D3DXATTRIBUTERANGE[pMeshContainer->NumAttributeGroups];


pMeshContainer->MeshData.pMesh->GetAttributeTable(pMeshContainer->pAttributeTable, NULL);

biped and mesh and steel correctly. But they are motionless, standing still. I draw them a code of CModel:: DrawFrame (LPFRAME pFrame)

for (int iAttrib = 0; iAttrib < pMeshContainer->NumAttributeGroups; iAttrib++)
{
m_pd3dDevice->SetMaterial(&pMeshContainer->pMaterials9[pMeshContainer->pAttributeTable[iAttrib].AttribId]);
m_pd3dDevice->SetTexture(0, pMeshContainer->ppTextures[pMeshContainer->pAttributeTable[iAttrib].AttribId]);
pMeshContainer->MeshData.pMesh->DrawSubset(pMeshContainer->pAttributeTable[iAttrib].AttribId);
}
pMeshContainer = (LPMESHCONTAINER)pMeshContainer->pNextMeshContainer;
}

if(pFrame->pFrameSibling)
DrawFrame((LPFRAME)pFrame->pFrameSibling);

if(pFrame->pFrameFirstChild)
DrawFrame((LPFRAME)pFrame->pFrameFirstChild);
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.
hello Buckeye! you inspired me to look! I have got. I took the code from SkinnedMesh inserted into your project. Short, enjoyed ConvertToBlendedMesh (). But I am have another question. I issued Error on line that I marked, though in a similar line below does not give Error. What is the matter?

typedef struct _D3DXMESHCONTAINER_DERIVED: public D3DXMESHCONTAINER
{

LPDIRECT3DTEXTURE9* ppTextures;
D3DMATERIAL9* pMaterials9;
.......
}

void CModel::DrawMeshContainer(LPD3DXMESHCONTAINER pMeshContainerBase, LPD3DXFRAME pFrameBase)
{
D3DCAPS9 m_d3dCaps;
m_pd3dDevice->GetDeviceCaps( &m_d3dCaps );


//m_pd3dDevice->SetTransform(D3DTS_WORLD, &pFrame->matCombined);
LPMESHCONTAINER pMeshContainer = (LPMESHCONTAINER)pMeshContainerBase;


UINT iMatrixIndex;
D3DXMATRIXA16 matTemp;
DWORD AttribIdPrev;
AttribIdPrev = UNUSED32;
LPD3DXBONECOMBINATION pBoneComb;

if (pMeshContainer->pSkinInfo != NULL)
{
pBoneComb = reinterpret_cast<LPD3DXBONECOMBINATION>(pMeshContainer->pBoneCombinationBuf->GetBufferPointer());


// Draw using default vtx processing of the device (typically HW)
UINT iAttrib;
UINT NumBlend;


for (iAttrib = 0; iAttrib < pMeshContainer->NumAttributeGroups; iAttrib++)
{

NumBlend = 0;
for (DWORD i = 0; i < pMeshContainer->NumInfl; ++i)
{
if (pBoneComb[iAttrib].BoneId != UINT_MAX)
{
NumBlend = i;
}
}


if (m_d3dCaps.MaxVertexBlendMatrices >= NumBlend + 1)
{
// first calculate the world matrices for the current set of blend weights and get the accurate count of the number of blends
for (DWORD i = 0; i < pMeshContainer->NumInfl; ++i)
{
iMatrixIndex = pBoneComb[iAttrib].BoneId;
if (iMatrixIndex != UINT_MAX)
{
D3DXMatrixMultiply( &matTemp, &pMeshContainer->pBoneOffsets[iMatrixIndex], pMeshContainer->ppFrameMatrices[iMatrixIndex] );
m_pd3dDevice->SetTransform( D3DTS_WORLDMATRIX( i ), &matTemp );
}
}

m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, NumBlend);

// lookup the material used for this subset of faces
if ((AttribIdPrev != pBoneComb[iAttrib].AttribId) || (AttribIdPrev == UNUSED32))
{

m_pd3dDevice->SetMaterial( &pMeshContainer->pMaterials[pBoneComb[iAttrib].AttribId].MatD3D );//Here is Error RunTime
//But when I do instead ... .MatD3D my code from structure pMaterials9[pBoneComb[iAttrib].AttribId] All work and below code ... MatD3D too work. What is the matter?
m_pd3dDevice->SetTexture( 0, pMeshContainer->ppTextures[pBoneComb[iAttrib].AttribId] );
AttribIdPrev = pBoneComb[iAttrib].AttribId;
}

// draw the subset now that the correct material and matrices are loaded
pMeshContainer->MeshData.pMesh->DrawSubset(iAttrib);
}
}

// If necessary, draw parts that HW could not handle using SW
if (pMeshContainer->iAttributeSW < pMeshContainer->NumAttributeGroups)
{
AttribIdPrev = UNUSED32;
m_pd3dDevice->SetSoftwareVertexProcessing(TRUE);
for (iAttrib = pMeshContainer->iAttributeSW; iAttrib < pMeshContainer->NumAttributeGroups; iAttrib++)
{
NumBlend = 0;
for (DWORD i = 0; i < pMeshContainer->NumInfl; ++i)
{
if (pBoneComb[iAttrib].BoneId != UINT_MAX)
{
NumBlend = i;
}
}

if (m_d3dCaps.MaxVertexBlendMatrices < NumBlend + 1)
{
// first calculate the world matrices for the current set of blend weights and get the accurate count of the number of blends
for (DWORD i = 0; i < pMeshContainer->NumInfl; ++i)
{
iMatrixIndex = pBoneComb[iAttrib].BoneId;
if (iMatrixIndex != UINT_MAX)
{
D3DXMatrixMultiply( &matTemp, &pMeshContainer->pBoneOffsets[iMatrixIndex], pMeshContainer->ppFrameMatrices[iMatrixIndex] );
m_pd3dDevice->SetTransform( D3DTS_WORLDMATRIX( i ), &matTemp );
}
}

m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, NumBlend);

// lookup the material used for this subset of faces
if ((AttribIdPrev != pBoneComb[iAttrib].AttribId) || (AttribIdPrev == UNUSED32))
{
m_pd3dDevice->SetMaterial( &pMeshContainer->pMaterials[pBoneComb[iAttrib].AttribId].MatD3D );
m_pd3dDevice->SetTexture( 0, pMeshContainer->ppTextures[pBoneComb[iAttrib].AttribId] );
AttribIdPrev = pBoneComb[iAttrib].AttribId;
}

// draw the subset now that the correct material and matrices are loaded
pMeshContainer->MeshData.pMesh->DrawSubset(iAttrib);
}
}

m_pd3dDevice->SetSoftwareVertexProcessing(FALSE);

}

m_pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, 0);
}
}
Windows programming is like going to the dentist: You know it’s good for you, but no one likes doing it.- Andre LaMothe.

This topic is closed to new replies.

Advertisement