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

天行健 君子當(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>
            国产欧美一区二区三区久久| 老鸭窝91久久精品色噜噜导演| 欧美国产高潮xxxx1819| 亚洲先锋成人| 亚洲精品一区在线观看| 亚洲大片在线观看| 欧美制服丝袜第一页| 亚洲女优在线| 欧美一区二区三区视频免费播放| 亚洲一区二区在线免费观看视频| 一区二区激情小说| 一本久久精品一区二区| 亚洲精品黄网在线观看| 亚洲精品国产精品久久清纯直播| 亚洲第一区在线| 亚洲三级电影全部在线观看高清| 亚洲激情一区二区三区| 日韩亚洲欧美一区二区三区| 一区二区日本视频| 香蕉久久夜色精品国产使用方法| 亚洲欧美日韩国产一区二区| 久久精品国产久精国产一老狼 | 亚洲嫩草精品久久| 亚洲私拍自拍| 久久精品一区二区三区中文字幕| 久久久久久自在自线| 国产色视频一区| 影音先锋日韩资源| 亚欧成人在线| 欧美一区二区精美| 久久精品国语| 欧美激情视频一区二区三区免费 | 亚洲免费一级电影| 久久av资源网站| 欧美成人一区二区在线| 欧美视频专区一二在线观看| 国产欧美日韩在线| 亚洲激情欧美| 午夜欧美精品久久久久久久| 久久亚洲精品欧美| 日韩性生活视频| 久久精品国产免费观看| 欧美日韩你懂的| 精品成人乱色一区二区| 亚洲性线免费观看视频成熟| 久久久久国内| 中日韩男男gay无套| 久久五月激情| 国产精品一区二区久久久| 91久久精品国产91性色tv| 欧美亚洲视频一区二区| 亚洲精品国产视频| 久久久精品一区二区三区| 欧美日韩亚洲国产一区| 亚洲高清不卡在线| 久久国产88| 中文精品视频| 欧美精品一区三区| 亚洲电影天堂av| 久久婷婷丁香| 欧美一二三区精品| 国产精品乱看| 亚洲影视在线| 一本大道久久精品懂色aⅴ| 欧美肥婆在线| 亚洲国产日韩精品| 另类天堂av| 久久精品国产免费看久久精品| 国产精品久久久久久av下载红粉| 日韩一区二区免费看| 欧美二区在线| 美国十次了思思久久精品导航| 国产综合在线视频| 久久都是精品| 欧美一区二区啪啪| 国产区日韩欧美| 久久久久国色av免费看影院| 亚洲精品午夜| 欧美激情国产精品| 亚洲人成在线观看网站高清| 欧美a一区二区| 久久人人精品| 欧美一区国产一区| 亚洲一区视频| 国产精品一区三区| 欧美专区日韩专区| 欧美在线视屏| 亚洲丁香婷深爱综合| 欧美国产日韩在线| 欧美1区2区3区| 一区二区三区成人精品| 一本久久a久久免费精品不卡| 欧美日韩黄色大片| 亚洲欧美久久久| 亚洲欧美一区二区激情| 欧美精品91| 亚洲免费影视| 欧美在线www| 最新亚洲视频| 99亚洲一区二区| 国产伦精品一区二区三区| 久久久久免费视频| 欧美日本国产精品| 亚洲精品一区二区三区樱花| 亚洲精品欧美日韩| 国产精品午夜在线| 母乳一区在线观看| 欧美日韩国产精品专区| 性欧美暴力猛交69hd| 久久亚洲精品视频| 亚洲综合精品| 久久久人成影片一区二区三区 | 亚洲乱码国产乱码精品精可以看| 女生裸体视频一区二区三区| 欧美精品在线观看播放| 亚洲欧美一区二区激情| 久久久久久穴| 亚洲综合社区| 麻豆精品一区二区综合av | 亚洲一级在线| 久久狠狠婷婷| 亚洲婷婷综合色高清在线| 久久精品视频播放| 亚洲自拍三区| 欧美α欧美αv大片| 欧美诱惑福利视频| 欧美日产在线观看| 免费毛片一区二区三区久久久| 欧美日韩中文精品| 欧美激情视频在线播放| 国产日韩欧美成人| 一区二区三区不卡视频在线观看| 1000部精品久久久久久久久| 亚洲一区精品在线| 99精品99久久久久久宅男| 久久精品视频网| 欧美影院视频| 国产精品中文字幕欧美| 99国产精品一区| 亚洲免费影视| 国产精品超碰97尤物18| 蜜臀av在线播放一区二区三区| 欧美视频一区二区三区| 亚洲经典在线看| 亚洲国产99| 久久激情综合网| 欧美中文字幕在线视频| 国产精品久久国产愉拍 | 久久野战av| 国产日本精品| 亚洲欧美亚洲| 久久久久99| 国产一区二区三区四区在线观看| 亚洲婷婷综合久久一本伊一区| 在线视频欧美日韩| 欧美日韩欧美一区二区| 亚洲伦理精品| 亚洲视频视频在线| 欧美日韩视频第一区| 亚洲精品一区二区三区蜜桃久| 亚洲精品孕妇| 欧美日韩一视频区二区| 一本一本a久久| 午夜在线一区二区| 国产日产精品一区二区三区四区的观看方式 | 韩国av一区二区三区四区| 亚洲综合电影| 久久精品国产91精品亚洲| 国模精品一区二区三区| 久久精品免费电影| 亚洲国产精品悠悠久久琪琪| 亚洲精品美女久久久久| 欧美女人交a| 亚洲午夜av| 久久久久综合一区二区三区| 伊人成人网在线看| 欧美大片在线观看| 一区二区免费在线视频| 久久精品视频播放| 在线精品一区二区| 欧美日韩成人免费| 亚洲影院免费| 欧美1区3d| 亚洲一二三区视频在线观看| 国产美女精品人人做人人爽| 久久久久在线观看| 日韩视频中文字幕| 久久国产乱子精品免费女| 亚洲国产精品高清久久久| 欧美日韩亚洲一区三区 | 亚洲电影毛片| 欧美亚州在线观看| 久久精品免费看| 亚洲卡通欧美制服中文| 久久国产夜色精品鲁鲁99| 亚洲国产二区| 国产欧美二区| 欧美日韩免费网站| 久久综合一区二区| 国产精品wwwwww|