• <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>

            天行健 君子當自強而不息

            D3D Animation Basis(8)

            Drawing Meshes

            Now that you have your meshes loaded and you've updated those skinned meshes that needed updating, it is time to throw some pixels at the display and show off those meshes! In total, I have created four mesh−rendering functions to help you in your projects.

            HRESULT draw_mesh(D3DXMESHCONTAINER_EX* mesh_container)
            {
                
            // error checking

                
            if(mesh_container == NULL)
                    
            return E_FAIL;

                
            if(mesh_container->MeshData.pMesh == NULL)
                    
            return E_FAIL;

                
            if(mesh_container->NumMaterials == 0 || mesh_container->pMaterials == NULL)
                    
            return E_FAIL;

                
            // get the device interface
                IDirect3DDevice9* device;
                mesh_container
            ->MeshData.pMesh->GetDevice(&device);

                
            // release vertex shader if being used
                device->SetVertexShader(NULL);
                device
            ->SetVertexDeclaration(NULL);

                DWORD last_alpha_blend, old_alpha_blend, old_src_blend, old_dest_blend;

                
            // save render states
                device->GetRenderState(D3DRS_ALPHABLENDENABLE,    &old_alpha_blend);
                device
            ->GetRenderState(D3DRS_SRCBLEND,            &old_src_blend);
                device
            ->GetRenderState(D3DRS_DESTBLEND,            &old_dest_blend);
                last_alpha_blend 
            = old_alpha_blend;

                
            // setup pointer for mesh to draw, either regular or skinned.
                ID3DXMesh* mesh_to_draw = (mesh_container->skin_mesh == NULL) ? 
                                          mesh_container
            ->MeshData.pMesh : mesh_container->skin_mesh;

                
            // look through all subsets
                for(DWORD i = 0; i < mesh_container->NumMaterials; i++)
                {
                    
            // set material and texture
                    device->SetMaterial(&mesh_container->pMaterials[i].MatD3D);
                    device
            ->SetTexture(0, mesh_container->textures[i]);

                    
            // enable or disable alpha blending per material
                    if(mesh_container->pMaterials[i].MatD3D.Diffuse.a != 1.0f)
                    {
                        
            if(last_alpha_blend != TRUE)
                        {
                            last_alpha_blend 
            = TRUE;

                            device
            ->SetRenderState(D3DRS_ALPHABLENDENABLE,    TRUE);
                            device
            ->SetRenderState(D3DRS_SRCBLEND,            D3DBLEND_ONE);    // src color
                            device->SetRenderState(D3DRS_DESTBLEND,            D3DBLEND_DESTCOLOR);
                        }
                    }
                    
            else
                    {
                        
            if(last_alpha_blend != FALSE)
                        {
                            last_alpha_blend 
            = FALSE;
                            device
            ->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
                        }
                    }

                    mesh_to_draw
            ->DrawSubset(i);
                }

                
            // restore alpha blending states
                if(last_alpha_blend != old_alpha_blend)
                {
                    device
            ->SetRenderState(D3DRS_ALPHABLENDENABLE, old_alpha_blend);
                    device
            ->SetRenderState(D3DRS_SRCBLEND,           old_src_blend);
                    device
            ->SetRenderState(D3DRS_DESTBLEND,           old_dest_blend);
                }
                
                
            // make sure to release the device object!
                device->Release();

                
            return S_OK;
            }

             

            If a material being used specifies an alpha value other than 1, then alpha blending is enabled. This way, you can specify portions of a mesh to use alpha blending by merely changing the material information. Also, if a D3DXMESHCONTAINER_EX object contains a skinned mesh, that mesh is rendered instead of the regular mesh.

            posted on 2008-04-15 11:16 lovedday 閱讀(318) 評論(0)  編輯 收藏 引用

            公告

            導航

            統計

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關鏈接

            搜索

            最新評論

            日本久久久久久中文字幕| 久久久无码精品亚洲日韩蜜臀浪潮| 超级碰碰碰碰97久久久久| 久久人与动人物a级毛片| 午夜不卡久久精品无码免费| 久久亚洲中文字幕精品有坂深雪| AV无码久久久久不卡蜜桃 | 国内精品久久久久影院网站| 青青青青久久精品国产h久久精品五福影院1421 | 狠狠色丁香久久婷婷综合蜜芽五月| 久久久www免费人成精品| 69SEX久久精品国产麻豆| 日韩一区二区三区视频久久| 久久久久亚洲AV无码麻豆| 久久久久这里只有精品| 久久久久久综合网天天| 国产一区二区精品久久岳| 潮喷大喷水系列无码久久精品| 亚洲人成电影网站久久| 亚洲国产精品无码久久一区二区| 国产成人久久激情91| 国产亚洲美女精品久久久2020| 99久久精品九九亚洲精品| 麻豆成人久久精品二区三区免费| 久久性精品| 草草久久久无码国产专区| 99久久精品国产高清一区二区| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久精品无码一区二区三区日韩| 色综合久久久久无码专区| 亚洲午夜久久久| 欧美日韩久久中文字幕| 久久精品99无色码中文字幕| 99久久99久久精品国产片| 国内精品久久久久伊人av| 亚洲成色WWW久久网站| av色综合久久天堂av色综合在| 久久强奷乱码老熟女网站| 狠狠色婷婷久久综合频道日韩| 理论片午午伦夜理片久久| 久久久久亚洲av成人无码电影 |