我使用以下教程在OpenGL中绘制网格:https://www.d.umn.edu/ddunham/cs5721f07/进度/资源/lab_opengl07.html
在该站点上,有用于加载OBJ网格的GLM源文件的链接。我能够使用这种技术成功地绘制网格。然而,我需要能够得到网格的顶点(比如在一个矢量中)来分析和操作。如何做到这一点?
这应该有帮助(请参考提供的头/源):
GLMmodel* model = glmReadOBJ(...);
int vertex_count = model->numvertices; // # of vertices in the mesh
float x0 = model->vertices[3 * 0 + 0]; // x coordinates of the 1st vertex
float y0 = model->vertices[3 * 0 + 1]; // y coordinates of the 1st vertex
float z0 = model->vertices[3 * 0 + 2]; // z coordinates of the 1st vertex
float x1 = model->vertices[3 * 1 + 1]; // x coordinates of the 2nd vertex
...
int triangle_count = obj_model->numtriangles; // # of triangles in the mesh
const GLMtriangle& triangle0 = model->triangles[0]; // 1st triangle
int index0 = triangle0.vindices[0]; // index of the 1st vertex of the 1st triangle
...
const GLMtriangle& triangle1 = model->triangles[1]; // 2nd triangle
...