Jump to content
  • Advertisement
Sign in to follow this  
roby65

Animating x model

This topic is 3988 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 guys! I have a serious problem: i'm able to load a .x file, but i can't understand how to animate it! someone knows how? i tryed using anim->AdvanceTime(time,0); but nothing changes..... heres the code i use to load the model: struct D3DXMESHCONTAINER_DERIVED: public D3DXMESHCONTAINER { LPD3DXMESH pOrigMesh; }; class CMeshHeirarchy : public ID3DXAllocateHierarchy { STDMETHOD( CreateFrame )( THIS_ LPCSTR Name, LPD3DXFRAME *ppNewFrame ); STDMETHOD( CreateMeshContainer )( THIS_ LPCSTR Name, CONST D3DXMESHDATA *pMeshData, CONST D3DXMATERIAL * pMaterials, CONST D3DXEFFECTINSTANCE * pEffectInstances, DWORD NumMaterials, CONST DWORD * pAdjacency, LPD3DXSKININFO pSkinInfo, LPD3DXMESHCONTAINER * ppNewMeshContainer ); STDMETHOD( DestroyFrame )( THIS_ LPD3DXFRAME pFrameToFree ); STDMETHOD( DestroyMeshContainer )( THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree ); }; HRESULT CMeshHeirarchy::CreateFrame(LPCSTR Name, LPD3DXFRAME *ppNewFrame) { D3DXFRAME *frame = new D3DXFRAME; *ppNewFrame=frame; char *nome=new char[strlen(Name)+1]; strcpy(nome,Name); frame->Name=nome; D3DXMatrixIdentity(&frame->TransformationMatrix); frame->pFrameFirstChild=0; frame->pFrameSibling=0; frame->pMeshContainer=0; return D3D_OK; } HRESULT CMeshHeirarchy::CreateMeshContainer( THIS_ LPCSTR Name, CONST D3DXMESHDATA *pMeshData, CONST D3DXMATERIAL * pMaterials, CONST D3DXEFFECTINSTANCE * pEffectInstances, DWORD NumMaterials, CONST DWORD * pAdjacency, LPD3DXSKININFO pSkinInfo, LPD3DXMESHCONTAINER * ppNewMeshContainer ) { UINT NumFaces = pMeshData->pMesh->GetNumFaces(); D3DXMESHCONTAINER_DERIVED *mesh=new D3DXMESHCONTAINER_DERIVED; char *nome=new char[strlen(Name)+1]; strcpy(nome,Name); mesh->Name=nome; mesh->MeshData=*pMeshData; mesh->NumMaterials = 0; //max(1, NumMaterials); mesh->pMaterials = 0; mesh->pAdjacency = new DWORD[NumFaces*3]; memcpy(mesh->pAdjacency, pAdjacency, sizeof(DWORD) * NumFaces*3); if(pSkinInfo) { mesh->pSkinInfo=pSkinInfo; pSkinInfo->AddRef(); } pMeshData->pMesh->AddRef(); (*ppNewMeshContainer)=mesh; return D3D_OK; } HRESULT CMeshHeirarchy::DestroyFrame(LPD3DXFRAME pFrameToFree) { delete pFrameToFree->Name; delete pFrameToFree; return D3D_OK; } HRESULT CMeshHeirarchy::DestroyMeshContainer(LPD3DXMESHCONTAINER pMeshContainerToFree) { pMeshContainerToFree->pSkinInfo->Release(); delete pMeshContainerToFree->Name; delete pMeshContainerToFree; return D3D_OK; } anyone can help me?:(

Share this post


Link to post
Share on other sites
Advertisement
There's an excellent article here. Also, you might want to read the article on mesh hierarchies (also in that link) before the one on character animation because it covers some of the transformation related material in more detail.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!