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

天行健 君子當(dāng)自強(qiá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) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久一区二区三区四区| 亚洲一区在线播放| 久久精品欧美日韩精品| 欧美一区视频在线| 一区二区在线免费观看| 免费成人毛片| 欧美激情亚洲国产| 亚洲婷婷综合色高清在线 | 精品51国产黑色丝袜高跟鞋| 久久久久久69| 麻豆精品视频在线观看视频| 99在线观看免费视频精品观看| 亚洲精品欧美激情| 国产精品久久影院| 你懂的成人av| 欧美视频一区二区三区四区| 久久精品免费| 欧美日本不卡| 久久亚洲视频| 欧美日韩成人网| 久久精品成人| 欧美日本中文字幕| 久久久久久久综合狠狠综合| 女人香蕉久久**毛片精品| 亚洲一区二区少妇| 久久精品九九| 亚洲天堂成人| 噜噜噜噜噜久久久久久91 | 日韩视频中文| 亚洲影音一区| 亚洲精选中文字幕| 亚洲一区二区三区精品动漫| 亚洲国产高清在线观看视频| 在线亚洲精品| 亚洲国产三级网| 亚洲欧美在线高清| 中日韩高清电影网| 久久婷婷蜜乳一本欲蜜臀| 亚洲午夜精品视频| 蜜臀99久久精品久久久久久软件| 亚洲制服av| 欧美精品自拍| 欧美成人午夜视频| 国产在线麻豆精品观看| 99热这里只有成人精品国产| 亚洲高清久久网| 久久精品一区| 欧美一区=区| 国产精品av久久久久久麻豆网| 欧美激情欧美狂野欧美精品| 国内精品久久久久伊人av| 亚洲一区二区三区欧美 | 在线观看视频一区二区| 亚洲视频在线播放| 亚洲免费大片| 欧美成人精品福利| 欧美岛国在线观看| 韩日精品视频一区| 欧美一区二区三区视频| 亚洲一区久久久| 欧美日韩四区| 日韩视频三区| 一区二区三区精品国产| 欧美黑人在线播放| 亚洲第一视频网站| 在线精品一区二区| 久久久精彩视频| 免费成人在线视频网站| 一区在线影院| 久久尤物视频| 亚洲国产色一区| 99国产精品久久久久久久久久| 欧美成人免费在线观看| 亚洲精品久久久久久久久久久久久| 亚洲二区在线视频| 欧美韩日高清| 中国成人黄色视屏| 性色一区二区三区| 国语自产精品视频在线看一大j8| 久久福利精品| 欧美大片免费观看| 日韩一本二本av| 国产精品久久久久77777| 亚洲欧美国产三级| 麻豆国产精品777777在线| 亚洲黄一区二区三区| 欧美激情按摩| 亚洲女女女同性video| 久久久国产亚洲精品| 在线观看日韩国产| 欧美日韩一二三区| 亚洲男人天堂2024| 男人的天堂亚洲在线| 一区二区毛片| 国内精品久久久久久久影视麻豆| 久久一区二区精品| 在线视频精品| 欧美成人精品在线观看| 亚洲视频成人| 激情欧美一区二区| 欧美人与禽性xxxxx杂性| 午夜视频在线观看一区二区三区 | 亚洲激情国产| 久久福利毛片| 99精品国产热久久91蜜凸| 国产伦精品一区二区三区视频黑人 | 夜夜嗨一区二区三区| 国产免费亚洲高清| 欧美连裤袜在线视频| 亚洲欧美日韩在线不卡| 亚洲成人在线视频网站| 午夜精品久久久久99热蜜桃导演| 伊人精品视频| 国产精品久久国产精麻豆99网站| 久久这里只有| 亚洲欧美成人精品| 亚洲欧洲日本一区二区三区| 久久精品国产亚洲一区二区三区| 一本久道久久综合婷婷鲸鱼| 黄色工厂这里只有精品| 国产精品久久中文| 欧美久久一区| 久久影视三级福利片| 亚欧成人精品| 亚洲视频专区在线| 日韩视频免费观看高清完整版| 久久深夜福利| 欧美一区在线看| 亚洲综合欧美| 亚洲深夜福利在线| 夜夜精品视频一区二区| 亚洲国产精品毛片| 尤物网精品视频| 国产婷婷色一区二区三区四区| 国产精品高潮在线| 欧美日韩国产精品一区二区亚洲| 麻豆亚洲精品| 女人色偷偷aa久久天堂| 久久亚洲一区| 麻豆久久精品| 免费日韩成人| 欧美xart系列高清| 欧美国产亚洲另类动漫| 免费亚洲电影在线观看| 久久久久久日产精品| 久久九九精品99国产精品| 午夜精品视频在线观看一区二区| 亚洲午夜女主播在线直播| 亚洲午夜久久久久久尤物| 亚洲影视在线| 欧美一区二区三区在线看| 欧美一区国产在线| 久久青草福利网站| 久久综合狠狠| 欧美激情综合| 国产精品国产精品| 国产免费亚洲高清| 极品av少妇一区二区| 亚洲黄色av一区| 亚洲视频视频在线| 欧美一区二区三区视频免费| 久久精品91久久香蕉加勒比| 久热精品视频在线观看一区| 免费久久99精品国产自在现线| 欧美成人午夜剧场免费观看| 亚洲激情黄色| 亚洲欧美日韩成人高清在线一区| 香蕉亚洲视频| 欧美国产精品va在线观看| 欧美日本国产精品| 国产日韩精品视频一区| 影院欧美亚洲| 一区二区三区日韩欧美| 欧美在线中文字幕| 欧美成人影音| 亚洲午夜精品一区二区三区他趣| 午夜精品久久久久久久男人的天堂| 久久久久五月天| 欧美色综合天天久久综合精品| 国产免费观看久久| 亚洲精选大片| 久久精品亚洲| 亚洲精品影院| 久久久久久久999精品视频| 欧美大色视频| 国产一区在线播放| 99视频一区二区| 久久蜜桃精品| 一区二区三区欧美激情| 噜噜噜91成人网| 国产日韩1区| 亚洲私人影院在线观看| 欧美xx视频| 欧美一区二区在线免费播放| 欧美日韩一区在线观看视频| 亚洲国产成人高清精品| 欧美中文在线观看| 日韩一级黄色av| 欧美精品国产一区二区| 依依成人综合视频|