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

天行健 君子當(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>
            久久久久成人网| 亚洲精品美女在线观看播放| 国产一区二区精品久久99| 激情成人综合| 亚洲性夜色噜噜噜7777| 久久一区二区精品| 亚洲图中文字幕| 欧美成人一区二免费视频软件| 国产精品mm| 99视频有精品| 欧美高清视频在线| 欧美资源在线| 国产伦精品一区二区三区视频黑人| 亚洲精品在线观看免费| 久久一区二区视频| 免费亚洲电影在线| 在线精品国精品国产尤物884a| 欧美一区1区三区3区公司| 亚洲精品国精品久久99热一| 欧美偷拍一区二区| 久久精品五月| 性视频1819p久久| 国产毛片一区| 欧美激情一区二区三区四区| 噜噜爱69成人精品| 精品动漫3d一区二区三区免费| 亚洲动漫精品| 欧美成年人视频网站欧美| 亚洲午夜精品一区二区| 欧美在线观看视频| 一本色道88久久加勒比精品| 性欧美xxxx大乳国产app| 亚洲欧洲在线播放| 亚洲国产第一页| 国产日韩欧美一区二区三区在线观看| 欧美一区二区成人| 欧美黄色一级视频| 99视频一区二区三区| 午夜在线一区二区| 亚洲视频一区二区免费在线观看| 99re6热只有精品免费观看 | 性欧美精品高清| 一本一本久久a久久精品牛牛影视| 欧美日韩成人在线视频| 亚洲小说欧美另类婷婷| 久久免费视频观看| 亚洲精品欧美日韩专区| 99视频精品在线| 国产精品网站在线| 久久蜜桃精品| 欧美激情一区二区三区成人| 亚洲午夜精品一区二区| 欧美成人激情在线| 麻豆成人在线| 欧美亚州在线观看| 亚洲激情自拍| 国产日韩在线不卡| 亚洲调教视频在线观看| 9色精品在线| 欧美精品福利在线| 亚洲激情视频网| 亚洲人体大胆视频| 欧美不卡在线| 亚洲高清色综合| 最新亚洲视频| 欧美精品免费观看二区| 亚洲国产另类精品专区| 国产欧美日韩一区二区三区| 亚洲电影免费| 亚洲九九精品| 欧美日韩国产天堂| 亚洲精品欧美一区二区三区| 国产一区99| 久久久久久伊人| 男人天堂欧美日韩| 国产视频一区免费看| 午夜精品在线观看| 久久久久久9| 国产精品一二一区| 午夜一区二区三区在线观看| 久久久久久九九九九| 在线精品亚洲| 欧美精品综合| 亚洲高清视频一区二区| av成人免费| 国产精品久久午夜| 亚洲国产黄色| 亚洲在线播放| 欧美日韩综合精品| 亚洲黄色成人久久久| 在线一区亚洲| 欧美精品在线观看91| 亚洲天堂av高清| 久久久夜色精品亚洲| 最新日韩中文字幕| 欧美午夜视频一区二区| 久久精品国产精品亚洲| 久久不射网站| 国产农村妇女毛片精品久久麻豆 | 欧美黄色视屏| 亚洲欧美日韩天堂一区二区| 欧美日韩一区成人| 一本久久精品一区二区| 久久久久久网址| 99成人精品| 欧美日韩免费一区| 欧美在线视频一区二区| 亚洲免费观看高清完整版在线观看| 亚洲欧美视频一区| 国产精品视频免费一区| 美女爽到呻吟久久久久| 中文日韩电影网站| 香蕉尹人综合在线观看| 亚洲精品乱码久久久久久日本蜜臀| 国产精品久久久久久户外露出| 夜夜爽夜夜爽精品视频| 欧美aa在线视频| 欧美中文字幕在线播放| 夜夜嗨网站十八久久| 激情综合网址| 国产丝袜一区二区三区| 欧美色精品在线视频| 免费在线观看日韩欧美| 欧美一区午夜精品| 亚洲香蕉网站| 亚洲精品一区二区在线观看| 欧美大片国产精品| 久久久人成影片一区二区三区观看 | 欧美精品久久一区| 麻豆精品在线视频| 久久狠狠久久综合桃花| 亚洲欧美日韩久久精品| 久久婷婷久久| 久久精品国产69国产精品亚洲| 亚洲影院免费观看| aⅴ色国产欧美| 亚洲精品国精品久久99热| 一区二区三区在线视频免费观看 | 欧美午夜精品伦理| 欧美精品一区二区在线播放| 免费成人av资源网| 免费黄网站欧美| 欧美91大片| 欧美精品国产一区二区| 欧美精品久久一区| 欧美理论电影网| 欧美麻豆久久久久久中文| 欧美精品综合| 欧美日韩亚洲在线| 国产精品看片资源| 国产美女精品人人做人人爽| 国产日韩欧美二区| 国内自拍亚洲| 国产精品爱久久久久久久| 欧美视频一二三区| 国产精品系列在线| 国产专区精品视频| 国产精品男人爽免费视频1| 国产精品久久久久久久免费软件| 国产精品区免费视频| 国产欧美日本在线| 在线成人亚洲| 国产日韩精品视频一区| 国产综合色产在线精品| 亚洲第一页在线| 一本一本久久a久久精品牛牛影视| 亚洲美女中文字幕| 亚洲欧洲99久久| 麻豆freexxxx性91精品| 亚洲国产精品综合| 亚洲自啪免费| 亚洲影视综合| 亚洲一区二区在线视频| 久久成人人人人精品欧| 久久在线免费视频| 久久人人超碰| 欧美日韩国产一区二区三区| 国产精品一区二区三区乱码| 永久久久久久| 亚洲欧美bt| 亚洲第一级黄色片| 亚洲先锋成人| 欧美国产日韩一区二区在线观看 | 另类国产ts人妖高潮视频| 欧美日韩免费视频| 伊人久久亚洲影院| 亚洲欧美日韩国产综合在线| 免费看精品久久片| 免费欧美日韩| 亚洲午夜日本在线观看| 久久一区中文字幕| 国产精品夜夜夜一区二区三区尤| 亚洲第一在线| 午夜欧美大尺度福利影院在线看| 欧美福利视频网站| 亚洲欧美日韩精品综合在线观看| 欧美激情在线狂野欧美精品| 国产有码在线一区二区视频| 亚洲永久精品大片| 亚洲二区在线视频|