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

天行健 君子當(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>
            亚洲视频一区在线| 亚洲视频免费在线观看| 亚洲欧美久久| 国内久久婷婷综合| 亚洲福利小视频| 欧美精品二区三区四区免费看视频| 亚洲视频一区二区在线观看 | 欧美人与性动交cc0o| 欧美亚洲色图校园春色| 久久久一本精品99久久精品66| 久久婷婷亚洲| 亚洲欧美日韩精品在线| 免费h精品视频在线播放| 亚洲一区在线播放| 久久夜色精品国产亚洲aⅴ| 亚洲欧美日韩一区二区在线 | 一区二区三区高清| 久久精品1区| 亚洲在线观看免费视频| 久久综合伊人| 久久精品国产精品| 欧美四级在线观看| 欧美激情小视频| 韩国三级在线一区| 亚洲在线第一页| 一区二区三区视频观看| 久久免费午夜影院| 久久xxxx| 国产精品私房写真福利视频| 亚洲第一在线| 亚洲高清不卡av| 欧美一区二区三区在线观看视频| 亚洲网在线观看| 亚洲国产小视频在线观看| 国产精品一区亚洲| 一区二区三区黄色| 一区二区黄色| 欧美精品一区三区| 亚洲高清毛片| 在线看片成人| 久久久免费观看视频| 久久久久网址| 国产主播一区二区| 久久av资源网站| 久久国产精彩视频| 国产欧美日韩在线观看| 亚洲图片欧洲图片日韩av| 夜夜嗨av一区二区三区四区| 欧美成人精品高清在线播放| 亚洲成色最大综合在线| 亚洲国产天堂久久综合网| 久久久久亚洲综合| 欧美本精品男人aⅴ天堂| 亚洲第一级黄色片| 欧美mv日韩mv国产网站| 亚洲国产第一| 在线视频你懂得一区二区三区| 欧美激情综合色| 日韩一级片网址| 国产精品日韩一区二区三区| 亚洲午夜在线视频| 久久精品国产99精品国产亚洲性色| 国产麻豆一精品一av一免费| 欧美亚洲视频在线观看| 久久亚洲精选| 亚洲人屁股眼子交8| 欧美精品尤物在线| 一区二区三区av| 久久精品二区三区| 在线免费高清一区二区三区| 欧美大片在线看免费观看| 日韩亚洲欧美成人| 新67194成人永久网站| 国产综合视频| 欧美激情一区二区三区在线视频| 日韩一级免费| 久久久久久夜精品精品免费| 亚洲激情视频网| 国产精品国产成人国产三级| 欧美一区国产在线| 亚洲国产99精品国自产| 亚洲永久视频| 在线观看中文字幕不卡| 欧美精品一区在线观看| 亚洲欧美一区二区精品久久久| 久久人人精品| 一区二区三区三区在线| 国产一区日韩二区欧美三区| 欧美黄色成人网| 午夜亚洲性色福利视频| 亚洲高清三级视频| 午夜精品福利一区二区三区av| 极品少妇一区二区| 欧美网站在线| 免费亚洲电影在线| 午夜欧美精品久久久久久久| 欧美高清在线视频观看不卡| 亚洲一区二区免费看| 极品av少妇一区二区| 欧美精品二区| 欧美在线91| 999在线观看精品免费不卡网站| 久久国产精品高清| 一区二区免费在线播放| 在线观看av一区| 欧美婷婷久久| 免费看成人av| 欧美一级午夜免费电影| 亚洲乱码精品一二三四区日韩在线| 久久视频在线看| 午夜精品久久久久影视| 99精品热6080yy久久| 在线免费观看欧美| 国产一区二区剧情av在线| 欧美视频在线看| 欧美黄色影院| 欧美a级一区二区| 久久网站免费| 久久九九久精品国产免费直播 | 亚洲精品国产精品乱码不99按摩| 国产精品色网| 欧美三级精品| 欧美高清视频| 模特精品裸拍一区| 久久久综合网站| 久久成人免费电影| 亚洲一区网站| 一区二区三区视频免费在线观看| 亚洲国产精品va在线观看黑人 | 欧美三级不卡| 亚洲麻豆国产自偷在线| 蜜桃av综合| 久久狠狠婷婷| 久久精品国产第一区二区三区| 国产精品一区二区黑丝| 欧美连裤袜在线视频| 欧美高清影院| 欧美黑人国产人伦爽爽爽| 老妇喷水一区二区三区| 久久免费精品日本久久中文字幕| 久久成人免费网| 久久国产婷婷国产香蕉| 久久av红桃一区二区小说| 亚洲男人第一网站| 午夜国产精品影院在线观看| 亚洲免费在线视频| 亚洲欧美日韩精品久久奇米色影视| 亚洲一区二区在线观看视频| 亚洲影视综合| 欧美在线www| 性欧美大战久久久久久久久| 午夜在线视频观看日韩17c| 欧美在线播放一区| 久久久蜜桃精品| 蜜桃精品久久久久久久免费影院| 久久亚洲综合色一区二区三区| 久久夜色精品国产欧美乱| 蜜桃精品久久久久久久免费影院| 欧美成人激情视频免费观看| 美女亚洲精品| 欧美日本免费一区二区三区| 欧美精品免费观看二区| 欧美日韩精品三区| 国产精品久久久久毛片大屁完整版| 国产精品露脸自拍| 好吊视频一区二区三区四区| 1000精品久久久久久久久| 亚洲欧洲综合| 亚洲一区二区三区精品在线| 久久经典综合| 欧美韩日精品| 亚洲深夜av| 久久久久国产精品一区二区| 久久综合九色欧美综合狠狠| 欧美精品日韩| 国产视频自拍一区| 亚洲精品三级| 欧美在线三区| 91久久久久久久久| 香蕉成人伊视频在线观看 | 欧美一级大片在线免费观看| 久久综合五月| 亚洲乱码精品一二三四区日韩在线| 亚洲免费伊人电影在线观看av| 久久精品在线| 欧美视频第二页| 影音先锋久久久| 亚洲色在线视频| 欧美成人一品| 好吊视频一区二区三区四区 | 亚洲欧美影院| 久久综合中文色婷婷| 欧美三级日本三级少妇99| 国模精品一区二区三区| 一二美女精品欧洲| 另类天堂视频在线观看| 亚洲私人影吧| 欧美精品一区二区三区在线播放 | 亚洲欧美另类中文字幕| 欧美国产精品v|