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

天行健 君子當自強而不息

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


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(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>
            在线播放豆国产99亚洲| 久久精品女人| 性久久久久久| 国产麻豆精品在线观看| 午夜在线视频一区二区区别| 久久只精品国产| 欧美一区二区免费视频| 国内精品久久久久国产盗摄免费观看完整版 | 亚洲性感美女99在线| 欧美理论电影在线播放| 国产精品久久久久久久久搜平片| 樱桃国产成人精品视频| 一区二区三区.www| 久久影院亚洲| 亚洲一二三区视频在线观看| 玖玖在线精品| 一区二区三区**美女毛片 | 午夜天堂精品久久久久| 男女激情视频一区| 欧美激情视频在线播放| 亚洲欧美日本日韩| 久久久久欧美精品| 国产嫩草影院久久久久| 久久综合色婷婷| 欧美高清视频一区二区三区在线观看| 在线视频亚洲欧美| 亚洲国内高清视频| 久久国产精彩视频| 国产精品视频999| 亚洲一区二区三区精品动漫| 91久久精品国产91久久性色tv| 欧美中在线观看| 亚洲精品小视频| 欧美高清hd18日本| 久久这里只有| 亚洲女同在线| 免费视频最近日韩| 久久精品99久久香蕉国产色戒| 欧美成人免费网站| 久久九九热免费视频| 欧美日韩成人在线观看| 老司机精品导航| 国产精品久久久久影院亚瑟| 欧美激情综合色| 国内精品久久久久影院薰衣草| 欧美在线91| 欧美亚洲视频一区二区| 在线视频免费在线观看一区二区| 亚洲精品美女免费| 尤物99国产成人精品视频| 亚洲欧美99| 国产亚洲精品aa午夜观看| 亚洲精品国产精品乱码不99按摩| 国内精品久久久久影院 日本资源| 亚洲视频一区在线| 国产精品私房写真福利视频| 欧美怡红院视频| 欧美在线在线| 亚洲欧美在线一区二区| 欧美日本久久| 亚洲欧美久久久| 欧美日韩国产首页在线观看| 欧美福利影院| 亚洲国产99精品国自产| 亚洲精品美女久久7777777| 亚洲激情综合| 这里只有精品视频| 海角社区69精品视频| 欧美大片免费看| 欧美日韩一区二区三区四区五区| 亚洲国产精品一区| 99精品免费视频| 欧美日韩性生活视频| 久久国产精品电影| 蜜桃av一区| 亚洲一区二区3| 国产精品高潮粉嫩av| 亚洲欧美日韩精品久久亚洲区| 伊人久久综合97精品| 久久精品30| 亚洲一级黄色| 国产精品久久久免费| 欧美国产欧美亚洲国产日韩mv天天看完整| 欧美精品一区二| 久久五月婷婷丁香社区| 在线精品视频一区二区| 一本色道久久综合精品竹菊| 午夜在线观看免费一区| 好吊妞这里只有精品| 老司机免费视频一区二区| 欧美一级专区| 在线看欧美视频| 亚洲一区日韩| 久久综合久久综合久久| 亚洲国产99| 国产精品久久久久影院亚瑟| 久久久久久久久一区二区| 性xx色xx综合久久久xx| 欧美日韩精品免费观看视一区二区| 9人人澡人人爽人人精品| 久久成人一区二区| 亚洲精品乱码久久久久久黑人 | 欧美96在线丨欧| 亚洲视频网站在线观看| 裸体素人女欧美日韩| 日韩视频在线一区二区| 国产一区二区三区在线观看视频 | 亚洲日本激情| 久久久久中文| 亚洲伦理在线| 美日韩精品免费| 亚洲一区二区三区精品动漫| 一区视频在线看| 久久久久一区二区三区四区| 久久精品理论片| 99视频日韩| 欧美日韩你懂的| 久久久噜噜噜久久中文字幕色伊伊| 日韩午夜在线观看视频| 一本一本a久久| 欧美午夜片在线观看| 亚洲精品一区二区在线观看| 久久久久免费观看| 亚洲一线二线三线久久久| 国产精品久久国产愉拍| 亚洲小视频在线观看| 亚洲承认在线| 久久九九久久九九| 在线视频免费在线观看一区二区| 亚洲高清中文字幕| 巨胸喷奶水www久久久免费动漫| 亚洲欧美日韩国产中文| 洋洋av久久久久久久一区| 欧美午夜精品久久久久久超碰| 玖玖综合伊人| 久久一区二区三区国产精品| 西瓜成人精品人成网站| 亚洲一区综合| 亚洲桃花岛网站| 在线亚洲免费| 这里是久久伊人| 亚洲一区二区三区午夜| 9i看片成人免费高清| 久久久国产精品亚洲一区 | 日韩午夜在线观看视频| 亚洲国产国产亚洲一二三| 欧美国产日韩精品| 欧美国产成人在线| 亚洲午夜小视频| 久久人人超碰| 亚洲免费观看高清完整版在线观看| 在线精品一区| 国产精品v欧美精品v日韩精品| 亚洲综合精品四区| 亚洲欧美激情一区二区| 亚洲高清毛片| 欧美中文字幕精品| 久久国产精品第一页| 亚洲精品日韩在线观看| 亚洲免费观看高清在线观看| 一区二区日韩免费看| 黑丝一区二区| 国产精品国产三级国产普通话蜜臀 | 国产视频久久久久久久| 国产婷婷色综合av蜜臀av | 欧美激情一区在线| 欧美日韩成人在线| 国产精品亚洲视频| 国内精品久久久久伊人av| 欧美三区在线| 国产亚洲成精品久久| 激情综合在线| 一区二区三区精品| 亚洲国产日韩在线| 一区二区三区产品免费精品久久75 | 国产精品99久久99久久久二8| 亚洲永久精品大片| 欧美在线观看视频| 男人的天堂亚洲| 久久精品中文字幕一区| 亚洲视频欧洲视频| 91久久夜色精品国产九色| 99在线精品视频在线观看| 性亚洲最疯狂xxxx高清| 免费观看成人网| 久久精品最新地址| 亚洲黄一区二区三区| 午夜国产不卡在线观看视频| 欧美+亚洲+精品+三区| 国产欧美日韩一级| 一本一本久久a久久精品综合麻豆| 亚洲国产视频直播| 亚洲二区精品| 在线观看福利一区| 黑丝一区二区| 在线免费观看日本一区| 亚洲免费网址| 亚洲日本激情| 久久综合一区| 国产一区二区日韩|