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

天行健 君子當自強而不息

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>
            亚洲欧美视频一区| 国产人久久人人人人爽| 久久精品国产一区二区电影 | 欧美日韩你懂的| 麻豆精品视频在线观看| 国产精品久久久久av| 亚洲第一福利在线观看| 国产精品亚洲片夜色在线| 最近中文字幕日韩精品| 在线播放中文字幕一区| 欧美中文字幕精品| 午夜精品一区二区三区在线视| 欧美激情91| 欧美高清视频一区| 精品51国产黑色丝袜高跟鞋| 欧美一区三区二区在线观看| 亚洲一区免费视频| 欧美日本一道本| 亚洲国产经典视频| 亚洲国产一区二区三区青草影视| 欧美一级在线视频| 亚洲欧美制服中文字幕| 国产精品狠色婷| 一区二区三区精品视频| 99国产精品私拍| 欧美精品在线一区二区| 亚洲精选一区| 一区二区三区精品久久久| 欧美精品123区| 亚洲人成网站精品片在线观看 | 久久久久欧美| 国产亚洲欧美日韩美女| 欧美在线不卡| 免费不卡在线视频| 亚洲国产精品传媒在线观看 | 男女精品视频| 亚洲高清在线精品| 日韩午夜在线播放| 欧美日韩一区二区精品| 正在播放亚洲一区| 久久激情视频| 亚洲国产高清自拍| 欧美精品二区| 亚洲一品av免费观看| 久久精品国产91精品亚洲| 伊人久久亚洲热| 欧美国产高潮xxxx1819| 99视频有精品| 久久国产精品72免费观看| 极品日韩av| 欧美久久久久久久| 亚洲一区高清| 欧美xx视频| 亚洲社区在线观看| 国产一区二区三区久久久| 另类综合日韩欧美亚洲| 9色国产精品| 久久人91精品久久久久久不卡| 亚洲第一福利在线观看| 欧美体内she精视频在线观看| 亚洲欧美激情视频在线观看一区二区三区| 久久精视频免费在线久久完整在线看 | 欧美.www| 亚洲一区久久| 亚洲国产天堂网精品网站| 午夜精彩视频在线观看不卡| 一区精品在线| 国产精品视频yy9299一区| 久久看片网站| 亚洲在线播放电影| 亚洲国产成人精品久久| 久久国产精品亚洲77777| 在线看视频不卡| 国产精品羞羞答答xxdd| 欧美成人精品福利| 欧美在线观看视频一区二区三区| 亚洲人成在线播放网站岛国| 欧美在线综合视频| 一区二区三区久久网| 揄拍成人国产精品视频| 国产精品v欧美精品v日韩| 久久综合九色九九| 欧美在线视频不卡| 一本色道久久综合亚洲精品高清| 欧美成人亚洲| 久久五月天婷婷| 亚洲综合精品一区二区| 亚洲精品一区二区在线观看| 韩国精品主播一区二区在线观看| 欧美视频二区| 欧美日韩第一区| 看欧美日韩国产| 欧美一区二区免费视频| 亚洲天堂av在线免费观看| 亚洲国产精品精华液网站| 久久综合九色综合欧美就去吻| 亚洲欧美一级二级三级| 一区二区三区视频在线看 | 国内精品福利| 国产伦精品一区二区三区在线观看| 欧美日韩国产系列| 欧美经典一区二区三区| 欧美www视频| 蜜臀av性久久久久蜜臀aⅴ四虎 | 韩国女主播一区| 国产精品综合视频| 国产精品腿扒开做爽爽爽挤奶网站| 欧美精彩视频一区二区三区| 欧美成人情趣视频| 欧美777四色影视在线| 久久综合色一综合色88| 久久免费国产精品| 老司机凹凸av亚洲导航| 欧美成人免费全部| 欧美成人精品h版在线观看| 欧美大片一区二区三区| 欧美96在线丨欧| 欧美国产免费| 欧美日韩国产成人在线91| 欧美日韩国产另类不卡| 欧美视频中文一区二区三区在线观看| 欧美精品www在线观看| 欧美日韩国产精品自在自线| 欧美日韩在线直播| 国产精品三级视频| 国产一区二区按摩在线观看| 娇妻被交换粗又大又硬视频欧美| 在线观看欧美一区| 亚洲乱码视频| 亚洲欧美国产精品专区久久| 久久成人一区| 欧美黄色大片网站| 99精品国产一区二区青青牛奶| 亚洲色图自拍| 久久琪琪电影院| 欧美另类在线观看| 国产精品日韩欧美一区| 加勒比av一区二区| 99精品免费| 欧美一区二区在线观看| 免费欧美在线视频| 日韩视频国产视频| 欧美一站二站| 欧美激情中文字幕在线| 国产精品久久久久久亚洲调教| 国产自产v一区二区三区c| 亚洲人成在线播放| 欧美一二区视频| 欧美高清视频在线播放| 宅男噜噜噜66一区二区| 久久精品主播| 欧美三级日本三级少妇99| 韩国v欧美v日本v亚洲v| 野花国产精品入口| 久久香蕉精品| 一本久久综合亚洲鲁鲁| 久久偷看各类wc女厕嘘嘘偷窃| 欧美黄色大片网站| 国产在线精品自拍| 亚洲无亚洲人成网站77777| 久久一区免费| 亚洲天天影视| 欧美国产综合视频| 国产中文一区二区三区| 亚洲午夜久久久久久久久电影网| 免费不卡在线观看av| 亚洲永久免费| 欧美日韩国产天堂| 亚洲国产精品成人一区二区| 欧美淫片网站| 一区二区三区不卡视频在线观看 | 亚洲欧洲日韩在线| 久久激五月天综合精品| 国产精品色婷婷| 一区二区三区国产在线观看| 欧美成人综合| 久久久精品一区| 国内自拍一区| 久久不射中文字幕| 亚洲性夜色噜噜噜7777| 欧美日韩系列| 一区二区久久久久久| 亚洲国产专区校园欧美| 免费不卡视频| 亚洲激情欧美| 欧美成人亚洲| 久热精品视频在线免费观看| 韩国精品在线观看| 久久天天躁夜夜躁狠狠躁2022| 亚洲一区在线视频| 国产精品人人做人人爽人人添| 亚洲午夜精品久久| 亚洲视频在线观看三级| 国产精品扒开腿爽爽爽视频| 亚洲午夜电影网| 亚洲另类在线视频| 欧美日韩一区二区三区在线视频 | 久久国产精品亚洲va麻豆| 国产一区二区三区在线观看精品 | 1024成人|