本文整理汇总了C++中VertexData::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexData::reserve方法的具体用法?C++ VertexData::reserve怎么用?C++ VertexData::reserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexData
的用法示例。
在下文中一共展示了VertexData::reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadObj
void loadObj(const std::string &filename, VertexData &vd, IndexedFaceMesh &mesh, const Vector3r &scale)
{
std::vector<OBJLoader::Vec3f> x;
std::vector<OBJLoader::Vec3f> normals;
std::vector<OBJLoader::Vec2f> texCoords;
std::vector<MeshFaceIndices> faces;
OBJLoader::Vec3f s = { (float)scale[0], (float)scale[1], (float)scale[2] };
OBJLoader::loadObj(filename, &x, &faces, &normals, &texCoords, s);
mesh.release();
const unsigned int nPoints = (unsigned int)x.size();
const unsigned int nFaces = (unsigned int)faces.size();
const unsigned int nTexCoords = (unsigned int)texCoords.size();
mesh.initMesh(nPoints, nFaces * 2, nFaces);
vd.reserve(nPoints);
for (unsigned int i = 0; i < nPoints; i++)
{
vd.addVertex(Vector3r(x[i][0], x[i][1], x[i][2]));
}
for (unsigned int i = 0; i < nTexCoords; i++)
{
mesh.addUV(texCoords[i][0], texCoords[i][1]);
}
for (unsigned int i = 0; i < nFaces; i++)
{
// Reduce the indices by one
int posIndices[3];
int texIndices[3];
for (int j = 0; j < 3; j++)
{
posIndices[j] = faces[i].posIndices[j] - 1;
if (nTexCoords > 0)
{
texIndices[j] = faces[i].texIndices[j] - 1;
mesh.addUVIndex(texIndices[j]);
}
}
mesh.addFace(&posIndices[0]);
}
mesh.buildNeighbors();
mesh.updateNormals(vd, 0);
mesh.updateVertexNormals(vd);
LOG_INFO << "Number of triangles: " << nFaces;
LOG_INFO << "Number of vertices: " << nPoints;
}
开发者ID:InteractiveComputerGraphics,项目名称:PositionBasedDynamics,代码行数:48,代码来源:RigidBodyCollisionDemo.cpp