2012-10-11 3 views
-1

, 나는 그 결과를 다음 얻을 : OBJ 모델 Renderering는 간격

enter image description here

은 격차 있습니까 현재 정상 또는 결함있는 렌더링 코드에서 오는 것입니까?

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(); 
+0

파서가 생성 한 모델의 토폴로지를 나타내시겠습니까? –

+1

각 지수에서 1을 뺍니다. Wavefront 파일의 색인은 1부터 시작하지만 OpenGL은 0부터 계산되기 시작합니다. – TheAmateurProgrammer

+0

꼭지점/색인 데이터는 정상적으로 보이지만 삼각형 컬링처럼 보입니다. 뒤에서 도려내 기가없는 동일한 장면을 렌더링하고 구멍이 사라 졌는지 확인하십시오. – kolenda

답변

0

당신이 당신의 모델이 삼각형이 아니라 쿼드로 생성되는 것을 확인 했 : 여기

는 렌더링 코드? 대부분의 모델은 기본적으로 쿼드로 렌더링 될 것이므로 3D 프로그램 (Blender 또는 Maya와 같은)에서로드하고 삼각형 (Blender에서는 Ctrl + T)으로 변환하거나 파서를 쿼드를 처리하도록 변경할 수 있습니다 .