本文整理汇总了C++中TriangleMesh::num_vertices方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleMesh::num_vertices方法的具体用法?C++ TriangleMesh::num_vertices怎么用?C++ TriangleMesh::num_vertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleMesh
的用法示例。
在下文中一共展示了TriangleMesh::num_vertices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
int MeshObj::Create(WCHAR* szfn, ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dContext)
{
Release();
TriangleMesh mesh;
MeshObjReader::read(szfn, mesh);
int N = mesh.num_vertices();
m_vertices.resize(N);
for(int i = 0; i < N; ++i)
{
m_vertices[i].pos = mesh.vertices_[i];
m_vertices[i].norm = mesh.normals_[i];
}
D3D11_BUFFER_DESC bdesc;
bdesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bdesc.ByteWidth = mesh.num_vertices() * sizeof(D3DXVECTOR3) * 2;
bdesc.CPUAccessFlags = 0;
bdesc.MiscFlags = 0;
bdesc.StructureByteStride = sizeof(D3DXVECTOR3) * 2;
bdesc.Usage = D3D11_USAGE_DEFAULT;
D3D11_SUBRESOURCE_DATA srd;
srd.pSysMem = &m_vertices[0];
srd.SysMemPitch = 0;
srd.SysMemSlicePitch = 0;
pd3dDevice->CreateBuffer(&bdesc, &srd, &m_pVertexBuffer);
bdesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
bdesc.ByteWidth = mesh.num_triangles() * sizeof(Tuple3ui);
bdesc.CPUAccessFlags = 0;
bdesc.MiscFlags = 0;
bdesc.StructureByteStride = sizeof(unsigned);
bdesc.Usage = D3D11_USAGE_DEFAULT;
srd.pSysMem = &mesh.triangles_[0];
srd.SysMemPitch = 0;
srd.SysMemSlicePitch = 0;
pd3dDevice->CreateBuffer(&bdesc, &srd, &m_pIndexBuffer);
numVertices = mesh.num_vertices();
numIndices = mesh.num_triangles() * 3;
D3DXVECTOR3 bblow, bbhigh;
mesh.bounding_box(bblow, bbhigh);
m_bbox_center = (bblow + bbhigh) * 0.5f;
m_bbox_extent = (bbhigh - bblow) * 0.5f;
return 0;
}