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

天行健 君子當自強而不息

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

公告

導航

統計

常用鏈接

隨筆分類(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久久久二8 | 欧美1级日本1级| 乱中年女人伦av一区二区| 夜夜爽av福利精品导航 | 日韩一区二区福利| 国产欧美一区二区三区另类精品| 久久一区激情| 欧美日韩精品不卡| 久久久久欧美精品| 欧美精品一区三区在线观看| 欧美在线|欧美| 欧美成人免费全部观看天天性色| 亚洲小少妇裸体bbw| 久久精视频免费在线久久完整在线看 | 日韩图片一区| 国产一区再线| 99视频在线精品国自产拍免费观看 | 日韩视频专区| 在线精品国产欧美| 亚洲视频在线看| 亚洲国产成人不卡| 亚洲一区二区三区精品在线| 最新国产乱人伦偷精品免费网站| 亚洲一区二区在线免费观看| 亚洲激情亚洲| 欧美在线|欧美| 亚洲专区在线| 欧美肥婆在线| 欧美xxxx在线观看| 国产欧美视频一区二区| 日韩小视频在线观看| 亚洲成人在线观看视频| 午夜日韩福利| 亚洲欧美日韩区| 欧美日韩国产电影| 亚洲第一在线综合网站| 好看的日韩视频| 欧美一级一区| 久久er精品视频| 国产精品入口尤物| 宅男精品视频| 亚洲一区制服诱惑| 欧美日韩日本国产亚洲在线| 亚洲国产日韩综合一区| 亚洲国产日韩欧美在线图片| 久久野战av| 免费一级欧美片在线播放| 国产一区二区高清| 欧美在线免费| 久久久91精品国产| 国产在线观看一区| 欧美在线短视频| 久久亚洲国产精品日日av夜夜| 国产欧美亚洲精品| 欧美一区日韩一区| 老司机成人网| 亚洲国产视频a| 欧美高清在线视频| 亚洲免费高清| 午夜国产一区| 国产一区二区毛片| 久久久久久久999精品视频| 美女黄色成人网| 亚洲国产精品久久久久| 欧美电影免费网站| 日韩午夜一区| 久久国产精品久久国产精品| 黑人一区二区| 欧美大片在线观看一区二区| 日韩一区二区精品在线观看| 亚洲在线免费视频| 国产亚洲精品久久久久动| 久久激情视频免费观看| 欧美国产三区| 亚洲综合国产激情另类一区| 国产一区二区你懂的| 欧美成人国产| 亚洲一区二区三区影院| 久久综合色88| 亚洲一区欧美一区| 韩国女主播一区二区三区| 欧美激情在线有限公司| 亚洲一区网站| 亚洲电影专区| 欧美一级理论性理论a| **欧美日韩vr在线| 国产精品久久精品日日| 久久久久久婷| 中文在线不卡| 亚洲高清影视| 久久爱91午夜羞羞| 日韩视频免费在线观看| 国产一区91精品张津瑜| 欧美日韩国产首页| 久久精品首页| 亚洲一区二区少妇| 亚洲精品国产视频| 久久综合色一综合色88| 鲁大师影院一区二区三区| 久久影视三级福利片| 国产在线观看91精品一区| 国产视频精品免费播放| 亚洲精品永久免费精品| 亚洲在线视频一区| 欧美激情一二三区| 亚洲在线免费视频| 欧美 亚欧 日韩视频在线| 欧美精品成人一区二区在线观看| 久久欧美肥婆一二区| 国产精品一区久久久久| 日韩亚洲一区在线播放| 久久久久久久国产| 亚洲午夜精品一区二区| 亚洲电影av在线| 国产一区二区三区久久悠悠色av| 欧美精品在线视频| 免费日韩av| 久久久亚洲高清| 欧美在线播放视频| 亚洲欧美日韩在线综合| 亚洲午夜高清视频| 在线视频免费在线观看一区二区| 亚洲成在人线av| 久久久久综合| 久久亚洲高清| 久久综合伊人77777蜜臀| 久久精品视频在线播放| 欧美一区二区精美| 性色一区二区| 亚洲欧美日韩另类| 午夜精品影院在线观看| 香蕉成人伊视频在线观看 | 午夜精彩国产免费不卡不顿大片| 136国产福利精品导航网址| 国模 一区 二区 三区| 国产伦精品一区二区三区照片91| 欧美三级在线| 欧美视频在线观看视频极品| 国产精品videosex极品| 国产精品黄视频| 国产欧美日韩激情| 黄色av日韩| 亚洲精品久久在线| 在线亚洲欧美视频| 亚洲女同精品视频| 久久激情视频免费观看| 久久久久成人精品| 欧美成人一区二区在线| 亚洲欧洲一区二区天堂久久| 99亚洲一区二区| 欧美一区二区三区在线| 久久久久久夜| 欧美日韩精品二区第二页| 国产精品激情电影| 国外精品视频| 亚洲裸体在线观看| 欧美亚洲免费电影| 欧美福利视频一区| 9久re热视频在线精品| 欧美一区网站| 欧美成人国产va精品日本一级| 欧美天天视频| 在线成人免费观看| 正在播放亚洲| 老司机67194精品线观看| 亚洲日韩视频| 欧美一区二区三区啪啪| 欧美高清在线视频| 国产日韩在线视频| 99精品欧美一区| 久久精品视频免费播放| 亚洲三级网站| 国产欧美日韩精品一区| 亚洲国产乱码最新视频| 亚洲欧美日韩精品久久久久| 欧美sm重口味系列视频在线观看| 亚洲日韩视频| 免费看精品久久片| 国产情人节一区| 亚洲午夜电影| 亚洲国产日韩一区| 久久激情视频久久| 国产精品免费视频观看| 亚洲毛片在线观看.| 美女任你摸久久| 欧美亚洲免费在线| 国产精品99一区二区| 亚洲美女精品久久| 欧美国产第一页| 久久国产福利|