• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            http://hi.baidu.com/zyb_debug/blog/item/cb3fe2ca9ca3f015bf09e682.html

            開始了Advanced Animation with DirectX的閱讀
            基礎(chǔ)類庫的構(gòu)建是重要的,過后打算把它們加入我的zybToos的Framework里。
            代碼來自書中

            #ifndef ZYBANIMATIONTOOLS_H

            #define ZYBANIMATIONTOOLS_H

            #include 
            "DXUT.h"

            //=========================================
                /**
                擴(kuò)充D3DXMESHCONTAINER
                擴(kuò)充D3DXFrame
                
            */
            //=========================================


            namespace zyb
            {

                
            #define ReleaseCOM(x) { if(x!=NULL) x->Release(); x=NULL; }

                
            // Declare an extended version of D3DXFRAME
                
            // that contains a constructor and destructor
                
            // as well as a combined transformation matrix
                struct D3DXFRAME_EX : D3DXFRAME 
                {
                    D3DXMATRIX matCombined;   
            // Combined matrix
                    D3DXMATRIX matOriginal;   // Original transformation from .X

                    D3DXFRAME_EX()
                    {
                        Name 
            = NULL;
                        pMeshContainer 
            = NULL;
                        pFrameSibling 
            = pFrameFirstChild = NULL;
                        D3DXMatrixIdentity(
            &matCombined);
                        D3DXMatrixIdentity(
            &matOriginal);
                        D3DXMatrixIdentity(
            &TransformationMatrix);
                    }

                    
            ~D3DXFRAME_EX()
                    { 
                        delete [] Name;          Name 
            = NULL;
                        delete pFrameSibling;    pFrameSibling 
            = NULL;
                        delete pFrameFirstChild; pFrameFirstChild 
            = NULL;
                    }

                    
            // Function to scan hierarchy for matching frame name
                    D3DXFRAME_EX *Find(const char *FrameName)
                    {
                        D3DXFRAME_EX 
            *pFrame, *pFramePtr;

                        
            // Return this frame instance if name matched
                        if(Name && FrameName && !strcmp(FrameName, Name))
                            
            return this;

                        
            // Scan siblings
                        if((pFramePtr = (D3DXFRAME_EX*)pFrameSibling)) {
                            
            if((pFrame = pFramePtr->Find(FrameName)))
                                
            return pFrame;
                        }

                        
            // Scan children
                        if((pFramePtr = (D3DXFRAME_EX*)pFrameFirstChild)) {
                            
            if((pFrame = pFramePtr->Find(FrameName)))
                                
            return pFrame;
                        }

                        
            // Return none found
                        return NULL;
                    }

                    
            // Reset transformation matrices to originals
                    void Reset()
                    {
                        
            // Copy original matrix
                        TransformationMatrix = matOriginal;

                        
            // Reset sibling frames
                        D3DXFRAME_EX *pFramePtr;
                        
            if((pFramePtr = (D3DXFRAME_EX*)pFrameSibling))
                            pFramePtr
            ->Reset();

                        
            // Reset child frames
                        if((pFramePtr = (D3DXFRAME_EX*)pFrameFirstChild))
                            pFramePtr
            ->Reset();
                    }

                    
            // Function to combine matrices in frame hiearchy
                    void UpdateHierarchy(D3DXMATRIX *matTransformation = NULL)
                    {
                        D3DXFRAME_EX 
            *pFramePtr;
                        D3DXMATRIX matIdentity;

                        
            // Use an identity matrix if none passed
                        if(!matTransformation) {
                            D3DXMatrixIdentity(
            &matIdentity);
                            matTransformation 
            = &matIdentity;
                        }

                        
            // Combine matrices w/supplied transformation matrix
                        matCombined = TransformationMatrix * (*matTransformation);

                        
            // Combine w/sibling frames
                        if((pFramePtr = (D3DXFRAME_EX*)pFrameSibling))
                            pFramePtr
            ->UpdateHierarchy(matTransformation);

                        
            // Combine w/child frames
                        if((pFramePtr = (D3DXFRAME_EX*)pFrameFirstChild))
                            pFramePtr
            ->UpdateHierarchy(&matCombined);
                    }

                    
            void Count(DWORD *Num)
                    {
                        
            // Error checking
                        if(!Num)
                            
            return;

                        
            // Increase count of frames
                        (*Num)+=1;

                        
            // Process sibling frames
                        D3DXFRAME_EX *pFrame;
                        
            if((pFrame=(D3DXFRAME_EX*)pFrameSibling))
                            pFrame
            ->Count(Num);

                        
            // Process child frames
                        if((pFrame=(D3DXFRAME_EX*)pFrameFirstChild))
                            pFrame
            ->Count(Num);
                    }
                };

                
            // Declare an extended version of D3DXMESHCONTAINER
                
            // that contains a constructor and destructor
                
            // as well as an array of textures, a mesh object
                
            // that contains the generated skin mesh, and 
                
            // matrices that map to the frame hierarchy's and
                
            // for updating bones.
                struct D3DXMESHCONTAINER_EX : D3DXMESHCONTAINER
                {
                    IDirect3DTexture9 
            **pTextures;
                    ID3DXMesh          
            *pSkinMesh;

                    D3DXMATRIX        
            **ppFrameMatrices;
                    D3DXMATRIX         
            *pBoneMatrices;

                    D3DXMESHCONTAINER_EX()
                    {
                        Name               
            = NULL;
                        MeshData.pMesh     
            = NULL;
                        pMaterials         
            = NULL;
                        pEffects           
            = NULL;
                        NumMaterials       
            = 0;
                        pAdjacency         
            = NULL;
                        pSkinInfo          
            = NULL;
                        pNextMeshContainer 
            = NULL;
                        pTextures          
            = NULL;
                        pSkinMesh          
            = NULL;
                        ppFrameMatrices    
            = NULL;
                        pBoneMatrices      
            = NULL;
                    }

                    
            ~D3DXMESHCONTAINER_EX()
                    {
                        
            if(pTextures && NumMaterials) {
                            
            for(DWORD i=0;i<NumMaterials;i++)
                                ReleaseCOM(pTextures[i]);
                        }
                        delete [] pTextures;       pTextures 
            = NULL;
                        NumMaterials 
            = 0;

                        delete [] Name;            Name 
            = NULL;
                        delete [] pMaterials;      pMaterials 
            = NULL;
                        delete pEffects;           pEffects 
            = NULL;

                        delete [] pAdjacency;      pAdjacency 
            = NULL;
                        delete [] ppFrameMatrices; ppFrameMatrices 
            = NULL;
                        delete [] pBoneMatrices;   pBoneMatrices 
            = NULL;

                        ReleaseCOM(MeshData.pMesh);
                        ReleaseCOM(pSkinInfo);
                        ReleaseCOM(pSkinMesh);

                        delete pNextMeshContainer; pNextMeshContainer 
            = NULL;
                    }

                    D3DXMESHCONTAINER_EX 
            *Find(char *MeshName)
                    {
                        D3DXMESHCONTAINER_EX 
            *pMesh, *pMeshPtr;

                        
            // Return this mesh instance if name matched
                        if(Name && MeshName && !strcmp(MeshName, Name))
                            
            return this;

                        
            // Scan next in list
                        if((pMeshPtr = (D3DXMESHCONTAINER_EX*)pNextMeshContainer)) {
                            
            if((pMesh = pMeshPtr->Find(MeshName)))
                                
            return pMesh;
                        }

                        
            // Return none found
                        return NULL;
                    }
                };

                

                








            }


            #endif
            Posted on 2009-09-11 21:51 zyb_debug 閱讀(1409) 評論(0)  編輯 收藏 引用
            亚洲AV无码久久精品狠狠爱浪潮| 人人狠狠综合久久亚洲| 久久精品中文字幕久久| 久久久久国产精品三级网 | 午夜精品久久久久久毛片| 久久久噜噜噜久久中文字幕色伊伊| 国产午夜福利精品久久2021 | 日韩人妻无码一区二区三区久久99 | 久久99精品国产麻豆宅宅| 少妇久久久久久被弄到高潮| 久久久久亚洲AV成人片| 亚洲Av无码国产情品久久| 亚洲国产综合久久天堂| 久久香蕉一级毛片| 久久久久人妻精品一区二区三区| 久久播电影网| 色88久久久久高潮综合影院| 久久这里有精品视频| 久久亚洲国产午夜精品理论片| 精品多毛少妇人妻AV免费久久| 久久国产热这里只有精品| 久久国产高潮流白浆免费观看| 欧美日韩成人精品久久久免费看| 亚洲日本va中文字幕久久| 亚洲欧美国产精品专区久久| 一级女性全黄久久生活片免费 | 久久夜色精品国产噜噜麻豆 | 色婷婷综合久久久久中文字幕| 亚洲国产日韩欧美久久| 国产香蕉久久精品综合网| 国产亚洲美女精品久久久2020| 乱亲女H秽乱长久久久| 久久精品国产久精国产| 久久久久这里只有精品 | 久久精品无码一区二区app| 综合久久给合久久狠狠狠97色| 亚洲乱码精品久久久久..| 欧美久久综合性欧美| 国产精品中文久久久久久久| 久久超乳爆乳中文字幕| 久久男人AV资源网站|