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

天行健 君子當(dāng)自強(qiá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) 評(píng)論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

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

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美.日韩.国产.一区.二区| 欧美国产综合一区二区| 国产精品久久久久久久久免费| 亚洲精品日韩一| 亚洲人体1000| 欧美午夜久久久| 性欧美大战久久久久久久免费观看| 亚洲一区二区三区视频播放| 国产精品丝袜xxxxxxx| 久久久久久久久一区二区| 久久精品av麻豆的观看方式 | 亚洲激情视频网| 欧美日韩视频不卡| 欧美在线视频一区二区| 久久久999成人| 99精品99久久久久久宅男| 亚洲一区二区三区四区视频| 国产欧美丝祙| 亚洲国产老妈| 国产欧美午夜| 亚洲国产精品悠悠久久琪琪| 国产精品色午夜在线观看| 久久综合国产精品| 欧美日韩精品高清| 久久久久久网| 欧美日韩大陆在线| 美日韩精品视频免费看| 欧美国产日韩免费| 久久精品一区二区三区不卡牛牛| 麻豆精品一区二区综合av| 亚洲免费综合| 欧美激情一二区| 久久九九免费| 国产精品hd| 亚洲国产成人午夜在线一区| 国产欧美日韩三区| 亚洲欧洲一区二区三区久久| 国产一区二区三区电影在线观看| 亚洲精品在线电影| 在线成人免费视频| 午夜久久久久久久久久一区二区| 亚洲日韩欧美视频| 久久久91精品国产一区二区三区| 亚洲一区二区免费看| 欧美电影免费观看高清完整版| 久久aⅴ国产欧美74aaa| 国产精品成人免费| 亚洲品质自拍| 美女网站在线免费欧美精品| 国产精品一区免费在线观看| 亚洲激情综合| 亚洲国产一区二区三区在线播| 欧美一区日韩一区| 久久av最新网址| 国产女主播一区| 亚洲图片在线观看| 亚洲一区二区三区乱码aⅴ| 欧美大片第1页| 久久精品国内一区二区三区| 国产精品伊人日日| 亚洲主播在线| 午夜精品久久一牛影视| 欧美精品一区二区三区在线看午夜| 欧美第十八页| 91久久精品日日躁夜夜躁欧美 | 亚洲欧美日韩在线综合| 亚洲欧美日韩综合国产aⅴ| 欧美凹凸一区二区三区视频| 欧美日韩一区二区三区高清| 亚洲国内自拍| 一本色道久久综合狠狠躁篇怎么玩 | 免费观看欧美在线视频的网站| 久久亚洲风情| 亚洲国产成人av| 欧美大秀在线观看| 99ri日韩精品视频| 亚洲一区在线观看免费观看电影高清 | 久久精品人人爽| 国产主播一区二区三区| 久久久噜噜噜久久中文字免| 欧美成人精品在线视频| 亚洲日韩欧美视频| 欧美日韩综合在线免费观看| 亚洲午夜国产一区99re久久 | 日韩特黄影片| 国产精品久久一级| 久久国产免费| 亚洲国产精品999| 亚洲无线视频| 国内精品久久久久久久97牛牛| 久久三级福利| 一区二区欧美精品| 欧美中文字幕在线播放| 亚洲成色777777女色窝| 欧美精品一区二区三区蜜臀| 亚洲一区二区三区中文字幕| 欧美在线免费视频| 亚洲国产一区二区a毛片| 欧美噜噜久久久xxx| 欧美一区二区三区在线免费观看| 免费欧美日韩国产三级电影| 正在播放亚洲一区| 国产一区二区剧情av在线| 欧美刺激性大交免费视频| 亚洲一区观看| 亚洲成色777777在线观看影院| 亚洲摸下面视频| 亚洲高清色综合| 国产精品亚洲视频| 欧美人体xx| 久久久久国产精品人| 亚洲图片你懂的| 亚洲国产精品一区| 久久久精品国产免费观看同学| 亚洲美洲欧洲综合国产一区| 国产日韩在线视频| 国产精品嫩草影院一区二区| 免费中文日韩| 久久久无码精品亚洲日韩按摩| 亚洲丝袜av一区| 亚洲欧洲在线看| 欧美凹凸一区二区三区视频| 久久福利视频导航| 午夜电影亚洲| 亚洲无限乱码一二三四麻| 亚洲丰满在线| 国内一区二区三区在线视频| 国产麻豆午夜三级精品| 欧美性jizz18性欧美| 欧美破处大片在线视频| 美女任你摸久久| 麻豆成人精品| 久久久久久综合| 久久久国产精品一区| 欧美亚洲免费在线| 午夜精品久久久久久久久久久久| 一本色道久久综合一区| 亚洲美女视频网| 亚洲精品一区二区三区99| 亚洲国产成人在线| 亚洲黄色高清| 亚洲精品日韩在线观看| 91久久精品日日躁夜夜躁欧美 | 亚洲一区二区三区在线播放| 亚洲毛片一区| 9i看片成人免费高清| 亚洲免费观看在线观看| 一区二区三区欧美| 一区二区激情视频| 亚洲一区三区在线观看| 亚洲一区二区成人| 欧美一级播放| 久久久伊人欧美| 欧美成人精品1314www| 欧美黄色aa电影| 亚洲免费久久| 亚洲综合好骚| 久久精品噜噜噜成人av农村| 久久嫩草精品久久久精品一| 久久婷婷久久| 欧美日韩黄色大片| 国产精品人人做人人爽| 国产在线精品一区二区夜色| 一区三区视频| 一本一本a久久| 羞羞色国产精品| 久久尤物视频| 日韩午夜电影| 久久9热精品视频| 欧美二区在线| 国产精品素人视频| 伊人激情综合| 亚洲综合成人婷婷小说| 久久久91精品国产| 亚洲国产精品va| 亚洲欧美日韩在线不卡| 免费高清在线视频一区·| 欧美日韩国产美女| 国产综合精品| 亚洲图片欧美一区| 麻豆精品视频在线| 一本一本久久| 蜜乳av另类精品一区二区| 国产精品爽黄69| 亚洲麻豆av| 看欧美日韩国产| 亚洲小视频在线观看| 免费日本视频一区| 国产一区导航| 亚洲一区在线免费观看| 欧美高清自拍一区| 亚洲欧美中文另类| 欧美日韩中文精品| 亚洲七七久久综合桃花剧情介绍| 亚洲欧美日韩人成在线播放| 亚洲国产裸拍裸体视频在线观看乱了中文 | 欧美亚洲专区| 国产精品大片免费观看| 亚洲国产精品久久人人爱蜜臀 | 久久久久九九九九|