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

天行健 君子當(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>
            亚洲黄色成人| 免费欧美电影| 亚洲欧美自拍偷拍| 欧美激情一区二区三区成人| 伊人精品成人久久综合软件| 91久久精品视频| 亚洲午夜精品国产| 亚洲国产欧美精品| 久久免费国产精品| 欧美日韩免费高清一区色橹橹| 午夜精品一区二区三区在线| 美女免费视频一区| 亚洲丶国产丶欧美一区二区三区 | 久久综合网hezyo| 六月丁香综合| 日韩亚洲一区二区| 欧美亚洲在线视频| 亚洲黄页一区| av不卡在线| 亚洲综合视频一区| 亚洲欧美另类久久久精品2019| 国产精品激情| 久久精品国产久精国产爱| 亚洲男人的天堂在线| 亚洲激情视频| 性久久久久久久| 夜夜狂射影院欧美极品| 亚洲精品在线视频观看| 精品粉嫩aⅴ一区二区三区四区| 91久久久精品| 国产精品久久一区主播| 亚洲三级毛片| 久久国产精品电影| 中日韩高清电影网| 欧美一区二区三区四区视频 | 久久国产黑丝| 国产麻豆成人精品| 亚洲一区二区三区中文字幕在线| 一区二区欧美视频| 国产精品视频在线观看| 亚洲人成亚洲人成在线观看图片| 亚洲欧美在线高清| 亚洲精品韩国| 亚洲性图久久| 国产精品免费电影| 欧美久久久久久久久久| 你懂的国产精品永久在线| 亚洲欧美日本另类| 中日韩在线视频| 亚洲欧美制服中文字幕| 国产亚洲一二三区| 欧美承认网站| 亚洲午夜精品在线| 欧美18av| 欧美一级专区| 亚洲狠狠丁香婷婷综合久久久| 久久精品免视看| 亚洲黄色三级| 亚洲高清在线观看| 久久久激情视频| 久久久精品午夜少妇| 亚洲国产欧美在线人成| 国产女人精品视频| 欧美精品少妇一区二区三区| 午夜精品久久| 一本色道久久99精品综合| 美女尤物久久精品| 久久精品国产久精国产思思| 日韩一级在线观看| 亚洲人成在线观看网站高清| 国产亚洲一区在线播放| 欧美日韩一本到| 欧美精品一区二区精品网 | 欧美一区二区三区精品 | 猛男gaygay欧美视频| 午夜精品久久久久影视| 一区二区高清视频在线观看| 91久久精品美女| 99国产一区二区三精品乱码| 亚洲国产精品成人| 亚洲高清成人| 亚洲国产老妈| 亚洲美女电影在线| 亚洲图片欧洲图片日韩av| 国产精品99久久不卡二区| 一区二区av| 午夜精品视频在线| 久久久久中文| 欧美国产日本| 亚洲最新视频在线| 午夜精品久久久久久久99水蜜桃| 亚洲欧美日韩国产一区| 欧美中文字幕在线视频| 美国十次成人| 亚洲三级影院| 亚洲欧美中日韩| 免费成人黄色片| 久久久久91| 欧美好骚综合网| 亚洲中字在线| 久久综合给合久久狠狠狠97色69| 老司机免费视频一区二区| 久久国产视频网| 国产日韩欧美综合| 国产精品入口尤物| 你懂的国产精品| 亚洲性xxxx| 欧美99在线视频观看| 亚洲午夜女主播在线直播| 国产欧美日韩综合一区在线观看 | 久久蜜桃资源一区二区老牛| 亚洲人成亚洲人成在线观看图片| 国产精品国产三级国产普通话三级 | 玖玖国产精品视频| 久久aⅴ国产欧美74aaa| 免费中文字幕日韩欧美| 久久噜噜亚洲综合| 国产日韩欧美不卡在线| 性久久久久久| 亚洲自拍偷拍色片视频| 久久九九热re6这里有精品| 久久久久久夜| 久久久久看片| 久久人人精品| 欧美一区二区在线视频| 亚洲一区二区视频| 亚洲午夜免费福利视频| 久久综合久色欧美综合狠狠| 久久精品亚洲| 欧美在线视频日韩| 免费中文日韩| 欧美日韩亚洲视频一区| 欧美专区第一页| 免费一级欧美片在线播放| 欧美人交a欧美精品| 欧美激情乱人伦| 欧美成人tv| 欧美伊人久久| 久久久久99| 午夜免费电影一区在线观看| 亚洲毛片一区二区| 99热精品在线| 亚洲一区二区三区四区中文| 亚洲欧美日韩在线播放| 欧美影院成人| 欧美精品免费在线| 国产精品乱码妇女bbbb| 一区二区三区在线视频免费观看| 亚洲美女淫视频| 亚洲欧美日韩一区二区在线| 欧美~级网站不卡| 免费不卡中文字幕视频| 久久香蕉国产线看观看av| 亚洲日本国产| 久久久久久久久久久成人| 国产欧美日韩伦理| 久久久久久久一区| 久久精品亚洲一区二区三区浴池 | 这里只有精品电影| 午夜日韩在线| 国产欧美一区二区精品性色| 久久狠狠婷婷| 国产亚洲aⅴaaaaaa毛片| 一区二区三区色| 国产欧美一区二区视频| 亚洲欧美中文日韩v在线观看| 欧美黄色片免费观看| 国产精品久久久久天堂| 一区二区三区黄色| 亚洲一级免费视频| 亚洲性视频网站| 国产精品久久久一区二区| 亚洲第一精品夜夜躁人人爽 | 先锋a资源在线看亚洲| 亚洲第一页在线| 欧美在线一二三| 久久精品国产99国产精品澳门| 免费一区视频| 日韩视频永久免费观看| 日韩亚洲在线| 欧美日韩国产丝袜另类| 亚洲免费观看| 亚洲欧美另类国产| 国产毛片久久| 美女主播一区| 亚洲欧洲视频在线| 亚洲永久精品大片| 国产精品豆花视频| 西西人体一区二区| 欧美sm极限捆绑bd| 日韩午夜av在线| 国产农村妇女毛片精品久久莱园子 | 一本色道精品久久一区二区三区 | 久久黄色级2电影| 国产精品网红福利| 久久久久久9999| 91久久精品国产| 久久一二三国产| 久久最新视频| 亚洲欧美制服另类日韩|