Anyone have a good online tutorial on animation with meshes in DirectX?
A google search gives me dozens of sites, but I would like some opinions from some more experienced programmers.
Printable View
Anyone have a good online tutorial on animation with meshes in DirectX?
A google search gives me dozens of sites, but I would like some opinions from some more experienced programmers.
D3DX provides an animation controller just for this purpose. There are several methods for animation from vertex tweening (linear interpolation between two vertex positions over time), animation keyframing (just like it sounds), and other techniques.
You would need a book to cover these concepts fully. But I will say that the D3DX library makes all of this a snap.
OK, So I have found a couple of tutorials on Keyframe Animation, but I am having trouble making sense of some of it. I have an allocation class derived from ID3DXALLOCATEHIERARCHY here
and I have a CModel class that handles the loading, rendering, ect... of the mesh. Here is where I load the meshCode:class CAllocateHierarchy: public ID3DXAllocateHierarchy
{
public:
STDMETHOD(CreateFrame)(THIS_ LPCTSTR Name, LPD3DXFRAME *ppNewFrame);
STDMETHOD(CreateMeshContainer)(THIS_ LPCTSTR Name,
LPD3DXMESHDATA pMeshData,
LPD3DXMATERIAL pMaterials,
LPD3DXEFFECTINSTANCE pEffectInstances,
DWORD NumMaterials,
DWORD *pAdjacency,
LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer);
STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree);
STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerBase);
};
In red above I get an errorCode:void CModel::LoadXFile(char* strFileName)
{
//Allocation class
CAllocateHierarchy Alloc;
//Load the mesh
if(FAILED(D3DXLoadMeshHierarchyFromX(strFileName, // File load
D3DXMESH_MANAGED, // Load Options
m_pd3dDevice, // D3D Device
&Alloc, // Hierarchy allocation class
NULL, // NO Effects
&m_pFrameRoot, // Frame hierarchy
&m_pAnimController)))// Animation Controller
{
MessageBox(NULL, strFileName, "Model Load Error", MB_OK);
}
if(m_pAnimController)
m_dwAnimationSetCount = m_pAnimController->GetMaxNumAnimationSets();
if(m_pFrameRoot)
{
//Set the bones up
SetupBoneMatrices((LPFRAME)m_pFrameRoot, NULL);
//Setup the bone matrices array
m_pBoneMatrices = new D3DXMATRIX[m_uMaxBones];
ZeroMemory(m_pBoneMatrices, sizeof(D3DXMATRIX)*m_uMaxBones);
//Calculate the Bounding Sphere
D3DXFrameCalculateBoundingSphere(m_pFrameRoot, &m_vecCenter, &m_fRadius);
}
}
I am still kinda fuzzy when it comes to virtual functions. I tried removing the virtual tags from the functions in my derived class but I still get the same error.Code:cannot declare variable `Alloc' to be of type `CAllocateHierarchy'
since type `CAllocateHierarchy' has abstract virtual functions
I'm kinda stuck here, any help would be appreciated.
This is just a guess, but try:
I don't know if this will work, it's just a guess, i've never done mesh drawing and such before.Code:virtual CAllocateHierarchy Alloc;