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

天行健 君子當(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>
            午夜精品视频在线| 久久精品系列| 日韩视频在线免费观看| 欧美美女福利视频| 在线一区观看| 一本一本久久a久久精品综合妖精| 欧美人妖在线观看| 99国产精品| 亚洲一区中文字幕在线观看| 国产精品亚洲综合| 久久九九热re6这里有精品| 香蕉久久久久久久av网站| 黑人巨大精品欧美一区二区 | 欧美午夜视频网站| 午夜影院日韩| 美女在线一区二区| 亚洲小视频在线| 欧美与欧洲交xxxx免费观看 | 国产亚洲一区二区精品| 欧美成年人网| 欧美日韩亚洲一区二| 久久精品日韩欧美| 欧美电影电视剧在线观看| 亚洲欧美视频在线观看| 久久久久久综合网天天| 一区二区三区视频在线播放| 亚洲已满18点击进入久久 | 欧美日本高清视频| 翔田千里一区二区| 久久精品国产第一区二区三区最新章节 | 99视频精品在线| 国产精品美女在线| 久久精品亚洲精品| 免费不卡在线观看av| 亚洲福利视频一区| 亚洲成色www久久网站| 久久成年人视频| 久久久99久久精品女同性| 在线观看精品视频| 日韩视频永久免费| 国产一区二区中文| 日韩亚洲欧美中文三级| 樱桃国产成人精品视频| 一区二区三区久久精品| 亚洲国产va精品久久久不卡综合| 99精品99| 亚洲人成啪啪网站| 亚洲欧美国产高清va在线播| 亚洲第一区中文99精品| 亚洲精品乱码久久久久久蜜桃91| 国产一区二区三区四区hd| 亚洲国产精彩中文乱码av在线播放| 欧美日韩成人网| 久久久欧美精品sm网站| 欧美日韩亚洲国产精品| 久久一区二区三区四区| 国产视频不卡| 香港成人在线视频| 欧美一级专区| 欧美日韩国产精品专区| 男人插女人欧美| 国产麻豆成人精品| 夜夜精品视频| 亚洲开发第一视频在线播放| 亚洲视频 欧洲视频| 一区二区欧美日韩| 久久一区中文字幕| 久久久久久综合网天天| 国产精品国产馆在线真实露脸| 欧美高清影院| 精品白丝av| 欧美一级视频| 亚洲欧美日韩国产一区二区| 欧美~级网站不卡| 欧美xxxx在线观看| 国内精品99| 亚洲视频在线观看免费| 先锋亚洲精品| 欧美日韩综合另类| 亚洲伦理自拍| 日韩特黄影片| 欧美激情一区二区三区蜜桃视频| 裸体女人亚洲精品一区| 黄色成人在线网址| 欧美亚洲在线| 久久综合电影| 狠狠色综合色区| 久久人人97超碰国产公开结果| 亚洲欧美久久久| 亚洲欧洲综合另类在线| 欧美精品偷拍| 亚洲精品精选| 亚洲性感激情| 国产精品99免费看| 正在播放欧美一区| 香蕉亚洲视频| 国内精品久久久| 久久伊人免费视频| 欧美成人视屏| 激情综合自拍| 午夜精品久久久久久久99水蜜桃| 久久综合中文色婷婷| 亚洲高清久久| 欧美高清在线视频| 亚洲裸体俱乐部裸体舞表演av| 亚洲图色在线| 国产日韩高清一区二区三区在线| 香蕉久久夜色精品国产使用方法| 久久久另类综合| 亚洲高清av在线| 欧美精品日韩www.p站| 中国女人久久久| 久久精品夜色噜噜亚洲aⅴ| 国产老肥熟一区二区三区| av成人动漫| 性色一区二区三区| 黄色成人91| 欧美精选午夜久久久乱码6080| 99国产精品久久久| 久久精品一区蜜桃臀影院 | 欧美一区二区日韩一区二区| 久久视频精品在线| 亚洲精品在线一区二区| 蜜乳av另类精品一区二区| 亚洲伦伦在线| 久久综合久久综合久久| 99这里只有精品| 国产在线拍揄自揄视频不卡99| 猫咪成人在线观看| 亚洲一区国产视频| 亚洲成人在线网站| 午夜一区不卡| 99re成人精品视频| 国产在线拍偷自揄拍精品| 欧美成年人在线观看| 欧美一区二区三区在线看| 亚洲三级电影在线观看 | 国产午夜精品视频免费不卡69堂| 欧美成人精品h版在线观看| 午夜精品视频一区| 亚洲精品一区二区三区蜜桃久| 久久精品国产在热久久| 亚洲视频一区二区| 亚洲黄色av| 狠狠色狠狠色综合系列| 国产精品女人毛片| 麻豆精品视频在线| 久久中文字幕一区二区三区| 久久福利电影| 亚洲图片自拍偷拍| 亚洲免费av片| 亚洲国产免费| 精品999久久久| 国产色婷婷国产综合在线理论片a| 欧美日韩精品欧美日韩精品一 | 欧美在线播放一区二区| 制服丝袜激情欧洲亚洲| 国产一区在线观看视频| 欧美性一二三区| 国产精品久久久一本精品| 欧美日韩麻豆| 欧美日韩综合久久| 欧美三级电影一区| 欧美日韩国产系列| 欧美精品免费在线| 欧美理论片在线观看| 欧美肥婆在线| 毛片基地黄久久久久久天堂| 欧美激情a∨在线视频播放| 麻豆精品一区二区av白丝在线| 久久人人爽人人| 久久夜色精品亚洲噜噜国产mv| 久久福利毛片| 巨乳诱惑日韩免费av| 久久亚洲美女| 欧美激情国产高清| 欧美视频在线观看免费网址| 欧美性淫爽ww久久久久无| 国产精品扒开腿做爽爽爽软件| 欧美精品一区二区三区高清aⅴ| 欧美精品国产精品| 欧美日韩成人一区二区| 国产精品欧美一区二区三区奶水| 国产精品h在线观看| 国产一区999| 亚洲激情欧美激情| 亚洲精品欧美日韩专区| 亚洲嫩草精品久久| 久久久中精品2020中文| 欧美第一黄色网| 日韩视频一区二区三区在线播放免费观看 | 欧美日韩一区在线| 国产区日韩欧美| 亚洲国产天堂久久综合网| 一区二区三区四区五区精品视频| 亚洲欧美日韩精品久久久久| 久久精品国产综合| 欧美激情区在线播放| 亚洲午夜免费视频| 欧美精品一区二区三区一线天视频|