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

            搜索

            最新評論

            欧美熟妇另类久久久久久不卡 | 国产精品无码久久久久久| 久久受www免费人成_看片中文| 国产精品久久久久久久人人看| 一本一道久久a久久精品综合 | 狠狠狠色丁香婷婷综合久久五月 | 一本大道久久东京热无码AV| 久久狠狠爱亚洲综合影院| 精品久久无码中文字幕| 久久久久久亚洲精品无码| 久久久噜噜噜www成人网| 久久精品亚洲男人的天堂| 婷婷伊人久久大香线蕉AV| 国产精品日韩深夜福利久久| 久久久久久国产精品无码超碰| 久久99国产一区二区三区| 久久99国产综合精品| 久久久久亚洲AV无码去区首| 久久亚洲欧美国产精品| 久久免费大片| 亚洲天堂久久精品| 久久亚洲国产精品一区二区| 中文字幕久久久久人妻| 久久毛片免费看一区二区三区| 久久青草国产手机看片福利盒子| 亚洲精品美女久久久久99| 久久最新免费视频| 国产福利电影一区二区三区久久老子无码午夜伦不 | 国产精品国色综合久久| 一本一本久久A久久综合精品| 久久人人爽人人爽人人片AV麻豆| 久久免费美女视频| .精品久久久麻豆国产精品| 日日躁夜夜躁狠狠久久AV| 久久天天躁狠狠躁夜夜avapp| 亚洲精品久久久www| 亚洲美日韩Av中文字幕无码久久久妻妇| 99久久国产主播综合精品 | 国产精品99久久久久久www| 国产精品久久久久jk制服| 久久99国产精品久久99|