• <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游戲編程相關鏈接

            搜索

            最新評論

            久久狠狠一本精品综合网| 久久精品国产亚洲AV香蕉| 好属妞这里只有精品久久| 草草久久久无码国产专区| 日日狠狠久久偷偷色综合96蜜桃 | 国产亚洲精品久久久久秋霞| 一本色道久久88—综合亚洲精品| 久久精品国产亚洲av日韩| 国内精品久久久久久久久| 亚洲AV日韩AV永久无码久久| 欧美综合天天夜夜久久| 久久夜色精品国产亚洲| 91亚洲国产成人久久精品网址| 女同久久| 国产三级观看久久| 大伊人青草狠狠久久| 日本欧美久久久久免费播放网| 久久无码一区二区三区少妇| 91精品国产91久久综合| 久久久久久精品无码人妻| 久久精品99无色码中文字幕| 久久精品一区二区| …久久精品99久久香蕉国产| 亚洲精品乱码久久久久久| 亚洲国产成人久久综合一区77| 精品久久久久久综合日本| 蜜臀av性久久久久蜜臀aⅴ麻豆| 亚洲国产一成久久精品国产成人综合 | 韩国免费A级毛片久久| 亚洲综合伊人久久大杳蕉| 伊人久久精品影院| 欧美激情精品久久久久久| 久久综合狠狠综合久久97色| 久久精品中文字幕第23页| 精品水蜜桃久久久久久久| 国产精品成人99久久久久| 日本精品久久久久中文字幕8| 久久久久久狠狠丁香| 久久精品亚洲男人的天堂| 免费一级欧美大片久久网| 99久久免费国产精品特黄|