使用ID3DXMesh锁定顶点后,想重新拿出顶点数据怎样能做到?
//
//
Vertex* v = 0;
Mesh->LockVertexBuffer(0, (void**)&v);
..........
Mesh->UnlockVertexBuffer();
//
//
WORD* i = 0;
Mesh->LockIndexBuffer(0, (void**)&i);
.........
Mesh->Unlock IndexBuffer();
//
//
DWORD* attributeBuffer = 0;
Mesh->LockAttributeBuffer(0, &attributeBuffer);
.........
Mesh->UnlockAttributeBuffer();
std::vector<DWORD> adjacencyBuffer(Mesh->GetNumFaces() * 3);
Mesh->GenerateAdjacency(0.0f, &adjacencyBuffer[0]);
Mesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT|D3DXMESHOPT_COMPACT|D3DXMESHOPT_VERTEXCACHE,&adjacencyBuffer[0],0, 0, 0);
按照上面的代码可以把顶点数据加载到网格中,但是经过优化以后网格的索引位置可能会有一定的变化。要怎样做才能取出网格中的顶点数据和索引数据?
[解决办法]
再lock一遍 flag设置成为 readonly
[解决办法]
Lock之后本来就能又读又写,看你标志怎么置了