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

天行健 君子當自強而不息

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 閱讀(460) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久免费的精品国产v∧| 国产伦精品一区二区三| 亚洲日本激情| 亚洲国产精品久久久久| 欧美www在线| 夜夜爽夜夜爽精品视频| 亚洲毛片播放| 国产欧美精品一区二区三区介绍 | 国产精品系列在线播放| 欧美一区在线直播| 久久久久久久一区二区| 亚洲毛片一区| 亚洲影视中文字幕| 在线观看欧美精品| 久久久www成人免费无遮挡大片| 国产一区二区看久久| 欧美成人综合在线| 一本久久a久久免费精品不卡| 一本色道久久综合狠狠躁篇怎么玩 | 欧美自拍丝袜亚洲| 欧美成人午夜激情| 欧美在线综合| 欧美精品一区二区三区高清aⅴ| 性一交一乱一区二区洋洋av| 久久久人人人| 欧美一区二区三区免费视频| 欧美成年人视频网站| 欧美一区二区在线| 欧美经典一区二区三区| 亚洲精品一区二区三区四区高清| 欧美一区91| 欧美自拍偷拍| 欧美乱大交xxxxx| 久久黄色影院| 欧美日韩成人在线观看| 久久久久九九九| 欧美先锋影音| 亚洲成人中文| 国产一区二区三区高清播放| 最新热久久免费视频| 一区二区视频欧美| 亚洲主播在线| 亚洲欧美电影院| 免费在线亚洲欧美| 麻豆91精品| 国产婷婷成人久久av免费高清 | 亚洲一区二区三区乱码aⅴ| 亚洲精品你懂的| 久久九九国产| 久久裸体艺术| 久久gogo国模裸体人体| 欧美日本一道本| 91久久精品视频| 91久久极品少妇xxxxⅹ软件| 久久久久久久97| 久久综合影视| 国产在线日韩| 欧美一区激情| 久久人人超碰| 国内精品久久久久久久97牛牛| 亚洲在线电影| 欧美在线一二三四区| 国产精品免费一区二区三区在线观看| 亚洲精品国产精品乱码不99按摩| 亚洲国产日韩欧美在线99| 久久亚洲电影| 亚洲国产精品99久久久久久久久| 亚洲国产欧美在线人成| 欧美成人精品在线播放| 91久久综合亚洲鲁鲁五月天| 亚洲精品日韩激情在线电影| 欧美精品久久久久久久免费观看 | 亚洲午夜精品| 国产精品色一区二区三区| 亚洲香蕉成视频在线观看| 欧美亚洲视频一区二区| 国产视频一区欧美| 久久激情五月丁香伊人| 欧美 日韩 国产在线| 亚洲精品国产精品乱码不99| 欧美日韩国产不卡在线看| 这里只有精品视频| 久久美女性网| 亚洲黄网站在线观看| 欧美另类在线播放| 午夜亚洲伦理| 亚洲高清免费| 午夜激情综合网| 影音先锋另类| 欧美日韩成人激情| 午夜一级在线看亚洲| 欧美激情视频一区二区三区不卡| 亚洲理伦电影| 国产免费亚洲高清| 免费在线成人| 午夜国产不卡在线观看视频| 欧美国内亚洲| 销魂美女一区二区三区视频在线| 好吊色欧美一区二区三区视频| 欧美激情亚洲| 先锋影音网一区二区| 亚洲福利视频三区| 久久av二区| 一区二区三区精密机械公司| 国产主播精品| 欧美日韩精品免费在线观看视频| 欧美一级在线亚洲天堂| 亚洲美洲欧洲综合国产一区| 久久久久国产一区二区三区四区| 99精品免费| 亚洲欧美日韩在线不卡| 久久亚洲精选| 欧美大片专区| 亚洲综合激情| 亚洲韩日在线| 久久只有精品| 欧美亚洲一区二区在线| 亚洲人被黑人高潮完整版| 国产精品一区二区久久精品| 欧美韩国日本一区| 久久精品女人| 亚洲欧美中文字幕| 一本大道久久a久久综合婷婷 | 亚洲第一黄网| 国产亚洲精品7777| 国产精品久久久久久久电影| 欧美激情在线有限公司| 老色鬼久久亚洲一区二区| 欧美一区二区三区在| 中国日韩欧美久久久久久久久| 亚洲精品国产欧美| 亚洲娇小video精品| 欧美大片一区二区三区| 免费久久99精品国产| 久久久一二三| 久久天天躁狠狠躁夜夜av| 久久国产精品久久久久久久久久| 亚洲欧美色婷婷| 亚洲综合色在线| 亚洲伊人一本大道中文字幕| av成人天堂| 亚洲视频一区二区| 亚洲欧美激情四射在线日 | 午夜精品理论片| 亚洲天堂偷拍| 亚洲欧美视频在线| 欧美在线影院| 久久色在线观看| 久久综合999| 亚洲福利小视频| 亚洲日本国产| 一区二区三区欧美亚洲| 亚洲视频日本| 性色av一区二区三区红粉影视| 香蕉尹人综合在线观看| 久久精品在线| 欧美激情一二三区| 欧美日韩免费观看一区| 国产精品yjizz| 国产欧美一区二区精品仙草咪| 国产一区二区三区在线观看精品| 精品电影一区| 日韩视频在线播放| 亚洲一区二区欧美| 欧美一区二粉嫩精品国产一线天| 亚洲影院色在线观看免费| 欧美性片在线观看| 亚洲激情国产| 亚洲午夜精品久久久久久app| 亚洲影院免费| 久久久久久有精品国产| 欧美va天堂va视频va在线| 亚洲黄色成人| 亚洲欧美精品在线观看| 久久久久久久网| 欧美日韩在线播放三区| 国产主播一区| 一区二区三区视频在线播放| 午夜在线a亚洲v天堂网2018| 毛片一区二区| 宅男噜噜噜66一区二区66| 久久久久久久性| 国产精品高潮呻吟久久av黑人| 在线欧美视频| 欧美在线视频导航| 亚洲精品永久免费| 久久精品亚洲一区| 国产精品人成在线观看免费 | aa级大片欧美| 欧美国产日韩一区二区三区| 欧美一区二区三区四区在线| 一区二区高清在线| 久久精品网址| 日韩视频免费观看高清在线视频| 亚洲欧美中文在线视频| 欧美色图五月天| 亚洲国产精品一区二区尤物区| 香蕉久久一区二区不卡无毒影院| 欧美激情一区二区三级高清视频| 欧美在线影院在线视频|