Direct3D 9学习笔记(11)网格(Mesh)2

 

七.网格优化

image

参数解释:

image

示例:

//
// Optimize the mesh to generate an attribute table.
//

std::vector<DWORD> adjacencyBuffer(Mesh->GetNumFaces() * 3);
Mesh->GenerateAdjacency(0.0f, &adjacencyBuffer[0]);

hr = Mesh->OptimizeInplace(        
    D3DXMESHOPT_ATTRSORT |
    D3DXMESHOPT_COMPACT  |
    D3DXMESHOPT_VERTEXCACHE,
    &adjacencyBuffer[0],
    0, 0, 0);

image

八.属性表

image

image

image

九.邻接信息

image

image

image

示例:

void dumpAdjacencyBuffer(std::ofstream& outFile, ID3DXMesh* mesh)
{
    outFile << "Adjacency Buffer:" << std::endl;
    outFile << "-----------------" << std::endl << std::endl;

    // three enttries per face
    std::vector<DWORD> adjacencyBuffer(mesh->GetNumFaces() * 3);

    mesh->GenerateAdjacency(0.0f, &adjacencyBuffer[0]);

    for(int i = 0; i < mesh->GetNumFaces(); i++)
    {
        outFile << "Triangle's adjacent to triangle " << i << ": ";
        outFile << adjacencyBuffer[i * 3    ] << " ";
        outFile << adjacencyBuffer[i * 3 + 1] << " ";
        outFile << adjacencyBuffer[i * 3 + 2] << std::endl;
    }

    outFile << std::endl << std::endl;
}

十.网格克隆

HRESULT CloneMesh(
    [in]           DWORD Options,
    [in]           const D3DVERTEXELEMENT9 *pDeclaration,
    [in]           LPDIRECT3DDEVICE9 pDevice,
    [out, retval]  LPD3DXMESH *ppCloneMesh
    );

image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值