Thread: Animation

  1. #1
    Darkness Prevails Dark_Phoenix's Avatar
    Join Date
    Oct 2006
    Houston, Texas


    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.
    Using Code::Blocks and Windows XP

    In every hero, there COULD be a villain!

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    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.

  3. #3
    Darkness Prevails Dark_Phoenix's Avatar
    Join Date
    Oct 2006
    Houston, Texas
    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
    class CAllocateHierarchy: public ID3DXAllocateHierarchy
        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);
    and I have a CModel class that handles the loading, rendering, ect... of the mesh. Here is where I load the mesh
    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);
            m_dwAnimationSetCount = m_pAnimController->GetMaxNumAnimationSets();
            //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);
    In red above I get an error
    cannot declare variable `Alloc' to be of type `CAllocateHierarchy' 
    since type `CAllocateHierarchy' has abstract virtual functions
    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.

    I'm kinda stuck here, any help would be appreciated.
    Using Code::Blocks and Windows XP

    In every hero, there COULD be a villain!

  4. #4
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    This is just a guess, but try:
    virtual CAllocateHierarchy Alloc;
    I don't know if this will work, it's just a guess, i've never done mesh drawing and such before.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opengl walking leg animation
    By Bobby230 in forum C Programming
    Replies: 3
    Last Post: 03-05-2006, 03:41 PM
  2. Threads in MFC
    By VirtualAce in forum Windows Programming
    Replies: 4
    Last Post: 12-28-2005, 06:03 PM
  3. Animation class not working
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 03-02-2005, 06:48 AM
  4. animation timing
    By Eber Kain in forum Game Programming
    Replies: 2
    Last Post: 06-29-2004, 06:32 PM
  5. 3D animation (difficult?)
    By maes in forum Game Programming
    Replies: 3
    Last Post: 09-08-2003, 10:44 PM