当我渲染使用自己构建的解析器解析的 OBJ Wavefront 模型时,渲染时得到以下结果:
存在的差距是正常的还是仅仅是由于错误的渲染代码造成的?
这是渲染代码:
glPushMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glScaled(scale, scale, scale);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
for (int i = 0; i < vertices_indexes.size()-3; i+=3) {
glBegin(GL_TRIANGLE_FAN);
if (is_normals) glNormal3f(normals.at(normals_indexes[i]).x, normals.at(normals_indexes[i]).y, normals.at(normals_indexes[i]).z);
glVertex3f(vertices.at(vertices_indexes[i]).x, vertices.at(vertices_indexes[i]).y, vertices.at(vertices_indexes[i]).z);
if (is_normals) glNormal3f(normals.at(normals_indexes[i+1]).x, normals.at(normals_indexes[i+1]).y, normals.at(normals_indexes[i+1]).z);
glVertex3f(vertices.at(vertices_indexes[i + 1]).x, vertices.at(vertices_indexes[i + 1]).y, vertices.at(vertices_indexes[i + 1]).z);
if (is_normals) glNormal3f(normals.at(normals_indexes[i+2]).x, normals.at(normals_indexes[i+2]).y, normals.at(normals_indexes[i+2]).z);
glVertex3f(vertices.at(vertices_indexes[i + 2]).x, vertices.at(vertices_indexes[i + 2]).y, vertices.at(vertices_indexes[i + 2]).z);
glEnd();
}
glPopMatrix();