青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當(dāng)自強而不息

D3D Animation Basis(9)

As for the second draw_mesh function, it skips using the DrawSubset function and uses its own function to render subsets of polygon faces, using the vertex shader and vertex declaration you specify. This second function is extremely useful if you are using vertex shaders to render your meshes.

First, let me show you some helper function usage information:


D3DXATTRIBUTERANGE

Stores an attribute table entry.

typedef struct D3DXATTRIBUTERANGE {
DWORD AttribId;
DWORD FaceStart;
DWORD FaceCount;
DWORD VertexStart;
DWORD VertexCount;
} D3DXATTRIBUTERANGE, *LPD3DXATTRIBUTERANGE;

Members

AttribId
Attribute table identifier.
FaceStart
Starting face.
FaceCount
Face count.
VertexStart
Starting vertex.
VertexCount
Vertex count.

Remarks

An attribute table is used to identify areas of the mesh that need to be drawn with different textures, render states, materials, and so on. In addition, the application can use the attribute table to hide portions of a mesh by not drawing a given attribute identifier (AttribId) when drawing the frame.

The LPD3DXATTRIBUTERANGE type is defined as a pointer to the D3DXATTRIBUTERANGE structure.

typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE;
 

ID3DXBaseMesh::GetAttributeTable

Retrieves either an attribute table for a mesh, or the number of entries stored in an attribute table for a mesh.

HRESULT GetAttributeTable(
D3DXATTRIBUTERANGE * pAttribTable,
DWORD * pAttribTableSize
);

Parameters

pAttribTable
[in, out] Pointer to an array of D3DXATTRIBUTERANGE structures, representing the entries in the mesh's attribute table. Specify NULL to retrieve the value for pAttribTableSize.
pAttribTableSize
[in, out] Pointer to either the number of entries stored in pAttribTable or a value to be filled in with the number of entries stored in the attribute table for the mesh.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

Remarks

An attribute table is created by ID3DXMesh::Optimize and passing D3DXMESHOPT_ATTRSORT for the Flags parameter.

An attribute table is used to identify areas of the mesh that need to be drawn with different textures, render states, materials, and so on. In addition, the application can use the attribute table to hide portions of a mesh by not drawing a given attribute identifier when drawing the frame.


ID3DXSkinInfo::UpdateSkinnedMesh

Applies software skinning to the target vertices based on the current matrices.

HRESULT UpdateSkinnedMesh(
CONST D3DXMATRIX * pBoneTransforms,
CONST D3DXMATRIX * pBoneInvTransposeTransforms,
LPCVOID pVerticesSrc,
PVOID pVerticesDst
);

Parameters

pBoneTransforms
[in] Bone transform matrix.
pBoneInvTransposeTransforms
[in] Inverse transpose of the bone transform matrix.
pVerticesSrc
[in] Pointer to the buffer containing the source vertices.
pVerticesDst
[in] Pointer to the buffer containing the destination vertices.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

Remarks

When used to skin vertices with two position elements, this method skins the second position element with the inverse of the bone instead of the bone itself.

Now, it is implementation of function draw_mesh:

HRESULT draw_mesh(D3DXMESHCONTAINER_EX* mesh_container,
                  IDirect3DVertexShader9
* vertex_shader,
                  IDirect3DVertexDeclaration9
* vertex_decl)
{
    
// error checking

    
if(mesh_container == NULL || vertex_shader == NULL || vertex_decl == NULL)
        
return E_FAIL;

    ID3DXMesh
* mesh = mesh_container->MeshData.pMesh;

    
if(mesh == NULL)
        
return E_FAIL;

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

    
// get the device interface
    IDirect3DDevice9* device;
    mesh
->GetDevice(&device);

    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;  

    
// get mesh buffer pointer
    IDirect3DVertexBuffer9* vertex_buffer;
    IDirect3DIndexBuffer9
*  index_buffer;
    mesh
->GetVertexBuffer(&vertex_buffer);
    mesh
->GetIndexBuffer(&index_buffer);

    
// get attribute table
    DWORD num_attr;
    mesh
->GetAttributeTable(NULL, &num_attr);
    D3DXATTRIBUTERANGE
* attrs = new D3DXATTRIBUTERANGE[num_attr];
    mesh
->GetAttributeTable(attrs, &num_attr);

    
// use the vertex shader interface passed
    device->SetFVF(0);
    device
->SetVertexShader(vertex_shader);
    device
->SetVertexDeclaration(vertex_decl);

    
// set stream sources
    device->SetStreamSource(0, vertex_buffer, 0, D3DXGetFVFVertexSize(mesh->GetFVF()));
    device
->SetIndices(index_buffer);

    
// go through each attribute group and render
    for(DWORD i = 0; i < num_attr; i++)
    {
        
if(attrs[i].FaceCount != 0)
        {
            DWORD mat_index 
= attrs[i].AttribId;
            device
->SetTexture(0, mesh_container->textures[mat_index]);

            
// 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);
                }
            }

            device
->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, attrs[i].VertexStart, attrs[i].VertexCount,
                                         attrs[i].FaceStart 
* 3, attrs[i].FaceCount);
        }
    }

    
// clear stream uses
    device->SetStreamSource(0, NULL, 00);
    device
->SetIndices(NULL);

    
// free resources
    release_com(vertex_buffer);
    release_com(index_buffer);
    delete[] attrs;

    
// 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();

    
// release vertex shader and declaration mapping
    device->SetVertexShader(NULL);
    device
->SetVertexDeclaration(NULL);

    
return S_OK;
}

 

posted on 2008-04-15 13:06 lovedday 閱讀(463) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久综合中文| 久久久亚洲国产天美传媒修理工| 欧美日韩一区二区三区| 免费看精品久久片| 老司机精品视频网站| 欧美**人妖| 欧美日韩一区二区视频在线| 欧美日精品一区视频| 国产精品无码专区在线观看| 国产欧美一区二区精品仙草咪 | 六月丁香综合| 欧美成人免费小视频| 欧美午夜精品伦理| 国产欧美日韩视频在线观看 | 国产婷婷97碰碰久久人人蜜臀| 国产精品视频一区二区高潮| 国内外成人在线| 亚洲欧洲日韩综合二区| 亚洲一区在线播放| 久久亚洲国产精品一区二区| 亚洲福利视频一区| 亚洲三级免费| 欧美在线亚洲在线| 欧美日韩高清在线| 国产在线观看91精品一区| 亚洲美女精品成人在线视频| 午夜精品福利在线| 欧美激情视频一区二区三区在线播放| 亚洲国产小视频| 欧美一级视频一区二区| 欧美极品影院| 精品99视频| 欧美一级艳片视频免费观看| 欧美大片一区二区| 午夜久久资源| 欧美三级午夜理伦三级中视频| 国产综合色一区二区三区| 一本色道久久88综合日韩精品 | 亚洲一区二区在线播放| 农村妇女精品| 国内精品久久久久久久97牛牛| 亚洲午夜电影网| 亚洲韩国青草视频| 美女主播一区| 在线观看视频亚洲| 久久久久在线| 午夜精品福利一区二区蜜股av| 欧美日韩高清一区| 亚洲免费久久| 亚洲黄色成人网| 免费在线看成人av| 激情欧美一区二区三区| 欧美一区二区三区免费在线看| 亚洲蜜桃精久久久久久久| 免费亚洲电影在线观看| 在线观看亚洲视频啊啊啊啊| 久久国产精品一区二区三区| 中文亚洲免费| 国产精品久久午夜夜伦鲁鲁| 亚洲午夜伦理| 一区二区日韩精品| 国产精品大全| 亚洲欧美日韩精品综合在线观看| 91久久夜色精品国产网站| 免费成人网www| 亚洲精品激情| 久久久久久精| 欧美激情精品久久久久久免费印度 | 制服诱惑一区二区| 亚洲三级免费| 欧美三级黄美女| 亚洲一区二区三区四区在线观看| av不卡在线| 欧美性色综合| 久久都是精品| 久久精品成人| 亚洲欧洲一区二区三区| 亚洲日本理论电影| 欧美网站在线观看| 欧美一区二区三区日韩视频| 欧美一区二区三区四区视频| 在线观看av不卡| 亚洲国产免费| 国产精品日日摸夜夜摸av| 久久精品免费| 欧美jizzhd精品欧美喷水| 一区二区91| 亚洲欧美制服另类日韩| 在线电影一区| 91久久精品国产91久久性色| 欧美偷拍一区二区| 久久九九国产精品| 欧美国产日韩一区二区| 欧美一区二区精品在线| 久久综合色天天久久综合图片| 99热免费精品在线观看| 欧美一区二区免费视频| 亚洲美女区一区| 亚洲一区二区三区四区视频| 一区二区三区在线观看视频| 亚洲乱码久久| 一区二区亚洲精品| 一本久道久久久| 伊人久久亚洲热| 亚洲一区区二区| 亚洲巨乳在线| 久久久久成人精品| 亚洲综合国产激情另类一区| 久久久久久久精| 香蕉久久夜色精品| 欧美精品一区二区久久婷婷| 久久精品视频亚洲| 亚洲图片在线| 午夜视频一区在线观看| 亚洲性感激情| 亚洲精品男同| 美女亚洲精品| 欧美专区福利在线| 欧美激情精品久久久六区热门 | 午夜在线成人av| 欧美电影免费网站| 国产精品综合色区在线观看| 亚洲精品美女91| 91久久国产自产拍夜夜嗨| 欧美一区二区私人影院日本 | 亚洲欧美另类国产| 欧美精品不卡| 亚洲电影免费| 91久久夜色精品国产九色| 久久国产日韩| 久久久亚洲高清| 国内一区二区三区在线视频| 香蕉久久一区二区不卡无毒影院 | 午夜久久一区| 久久精品日产第一区二区三区| 国产精品成av人在线视午夜片| 91久久精品国产91性色tv| 91久久在线观看| 免播放器亚洲一区| 欧美成人精品h版在线观看| 激情欧美日韩一区| 久久先锋影音av| 欧美激情国产日韩| 亚洲人成在线播放| 欧美日韩国产在线播放网站| 亚洲精品一级| 亚洲欧美日韩一区在线| 国产精品一区二区三区久久| 欧美一区二区三区免费视| 久久人人爽爽爽人久久久| 一区在线播放视频| 欧美成人乱码一区二区三区| 亚洲国产日韩欧美在线99| 亚洲美女av黄| 国产精品久久久久久久久久尿| 亚洲午夜视频在线观看| 久久精品人人做人人爽| 亚洲高清不卡一区| 欧美日韩国产一区二区| 亚洲欧美日本日韩| 欧美大片一区二区三区| 亚洲午夜视频| 精品999网站| 欧美日韩在线电影| 久久不射中文字幕| 亚洲第一网站| 午夜精品久久久久久久久 | 一色屋精品视频免费看| 欧美高清视频一区二区| 亚洲尤物在线视频观看| 久久久777| 日韩视频在线观看| 国产伦精品一区二区三区视频黑人 | 欧美国产日韩亚洲一区| 中文有码久久| 免费成人黄色| 国产精品久久久久三级| 久久国产精品72免费观看| 亚洲国产一区二区精品专区| 亚洲私人影吧| 欧美日韩精品免费观看| 欧美在线播放| 99精品热视频| 美女尤物久久精品| 先锋影音久久久| 日韩午夜精品视频| 一色屋精品视频在线观看网站| 国产精品久久久久久久久婷婷| 免费日韩av电影| 先锋影音一区二区三区| 日韩午夜电影| 欧美激情精品久久久六区热门| 久久er99精品| 亚洲一区二区三区四区五区午夜 | 欧美激情1区| 麻豆国产精品777777在线| 亚洲私人影吧| 99精品热视频只有精品10| 亚洲福利久久| 性色av一区二区三区在线观看 |