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

天行健 君子當(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>
            国模精品一区二区三区| 国产婷婷成人久久av免费高清| 在线精品国产欧美| 国产日韩亚洲欧美综合| 亚洲欧美日韩另类| 午夜视频在线观看一区二区三区| 国产欧美二区| 久久综合久久久| 牛牛影视久久网| 国产亚洲成av人在线观看导航| 久久精品女人| 欧美va亚洲va香蕉在线| 亚洲婷婷免费| 香蕉成人伊视频在线观看| 玉米视频成人免费看| 91久久精品一区| 欧美午夜欧美| 另类av导航| 欧美日韩亚洲在线| 久久全球大尺度高清视频| 欧美福利电影在线观看| 亚洲制服av| 久久婷婷成人综合色| 一本综合久久| 久久久久久久久久久久久9999| 99re热这里只有精品视频| 亚洲尤物影院| 亚洲另类在线一区| 欧美怡红院视频| 亚洲一二三区在线| 久久一区亚洲| 欧美一区二粉嫩精品国产一线天| 老牛嫩草一区二区三区日本| 亚洲永久在线观看| 免费在线成人av| 久久国内精品视频| 欧美日韩午夜在线| 欧美暴力喷水在线| 国产一区深夜福利| 中文国产成人精品久久一| 亚洲国产另类精品专区| 亚洲欧美日韩另类| 亚洲私人影院| 欧美高清在线精品一区| 另类成人小视频在线| 国产精品久久久久久久久免费桃花| 欧美大片免费观看在线观看网站推荐| 国产精品久久久久一区二区| 91久久国产综合久久蜜月精品| 国产无一区二区| 亚洲一区三区电影在线观看| 99热在这里有精品免费| 久久中文在线| 久久综合久久美利坚合众国| 国产精品亚洲综合一区在线观看| 亚洲精品一二区| 亚洲久久视频| 欧美激情在线观看| 亚洲大片免费看| 亚洲国产精品久久久久秋霞蜜臀| 久久国产精品免费一区| 久久精品国产2020观看福利| 国产精品亚洲成人| 亚洲天堂久久| 欧美主播一区二区三区| 国产精品丝袜xxxxxxx| 亚洲午夜久久久久久久久电影院| 一区二区三区高清在线| 欧美日韩国产综合新一区| 亚洲国内在线| 国产精品99久久不卡二区| 欧美日本在线一区| 夜夜嗨一区二区| 午夜精彩国产免费不卡不顿大片| 欧美一区2区三区4区公司二百| 欧美一级在线亚洲天堂| 国产午夜精品久久| 久久久久久高潮国产精品视| 麻豆视频一区二区| 亚洲日本中文| 欧美色综合网| 香蕉久久国产| 欧美高清视频一二三区| 99在线精品观看| 国产精品黄视频| 久久久久国产精品厨房| 亚洲第一色中文字幕| 国产精品99久久久久久人| 国产精品欧美一区二区三区奶水| 欧美亚洲在线播放| 欧美激情 亚洲a∨综合| 亚洲午夜av| 黑人巨大精品欧美黑白配亚洲| 蜜乳av另类精品一区二区| 亚洲精选久久| 久久精品国产一区二区电影| 亚洲国产欧美在线| 欧美午夜剧场| 久久亚洲风情| 一区二区三区产品免费精品久久75| 久久精品动漫| 9色国产精品| 国产综合在线看| 欧美日韩成人综合| 久久国产欧美日韩精品| 99精品国产99久久久久久福利| 久久激情一区| 亚洲视频免费看| 1769国产精品| 国产精品美女久久久久久免费| 久久久噜噜噜久久| 亚洲午夜久久久久久久久电影院| 欧美v亚洲v综合ⅴ国产v| 亚洲影院色无极综合| 在线日韩欧美| 国产免费成人av| 欧美日韩大陆在线| 久久综合中文色婷婷| 亚洲免费视频网站| 欧美尤物巨大精品爽| 亚洲日产国产精品| 伊人精品成人久久综合软件| 国产精品裸体一区二区三区| 欧美精品久久久久久久久久| 久久久久.com| 欧美在线一二三四区| 亚洲午夜高清视频| 日韩一二三区视频| 亚洲欧洲日本专区| 亚洲国产成人porn| 免费视频亚洲| 免费成人在线观看视频| 久久精品视频va| 欧美中文字幕在线| 亚洲欧美文学| 亚洲男人的天堂在线| 在线视频一区二区| 99这里有精品| 中文亚洲视频在线| 一本色道久久综合亚洲精品按摩| 亚洲区中文字幕| 日韩亚洲欧美高清| 99视频精品| 亚洲午夜精品一区二区三区他趣| 99精品国产在热久久| 一本久道久久久| 夜夜嗨av色综合久久久综合网| 亚洲免费大片| 一区二区三区视频在线| 国产精品99久久久久久宅男| 一区二区三区视频免费在线观看| 一区二区三区毛片| 亚洲尤物影院| 久久狠狠一本精品综合网| 久久高清国产| 免费短视频成人日韩| 亚洲成人在线网| 午夜伦欧美伦电影理论片| 午夜精品www| 久久精品亚洲精品国产欧美kt∨| 久久精品视频在线播放| 欧美大秀在线观看| 亚洲激情影视| 亚洲免费在线视频| 久久精品国产91精品亚洲| 蜜桃av一区| 欧美午夜影院| 精品999久久久| 一本久久a久久精品亚洲| 欧美一区2区视频在线观看| 久久婷婷国产综合精品青草 | 欧美精品免费观看二区| 欧美色图五月天| 国产偷久久久精品专区| 亚洲丶国产丶欧美一区二区三区| 91久久极品少妇xxxxⅹ软件| 亚洲一区二区三区免费观看| 久久久久久久国产| 最新亚洲一区| 午夜精品理论片| 欧美另类亚洲| 国产无一区二区| 亚洲伦理在线| 久久婷婷久久| 一区二区高清| 欧美成人自拍| 国产一区二区三区四区| 中日韩美女免费视频网址在线观看| 午夜视频在线观看一区二区| 欧美高清不卡在线| 午夜精品国产| 国产精品v欧美精品v日本精品动漫| 极品少妇一区二区三区精品视频| 亚洲视频在线观看免费| 欧美激情a∨在线视频播放| 亚洲欧美日韩综合| 欧美日韩国产高清视频| 亚洲第一免费播放区| 欧美尤物一区| 一区二区三区日韩在线观看|