。OBJ OpenGL错误渲染

问题描述 投票:1回答:1

有人知道,为什么会发生?尝试使用Opengl渲染OBJ文件。

enter image description here

  // (0 - индекс вершины / 1 - индекс текстурной координаты / 2 - индекс нормали)
  for i := 0 to length(faces) - 1 do
  begin
    glBegin(faces[i].mode);
    Count := length(faces[i].data);
    for k := 0 to Count - 1 do
    begin
      glNormal3fv(@normals[faces[i].data[k].normalIndex]);
      glTexCoord2fv(@texcoords[faces[i].data[k].texCoodIndex]);
      glVertex3fv(@vertexes[faces[i].data[k].vIndex]);
    end;
    glEnd();
delphi opengl 3d wavefront opengl-compat
1个回答
0
投票
Wavefront OBJ从1开始。因此您必须从每个索引中减去1:

glNormal3fv(@normals[faces[i].data[k].normalIndex - 1]); glTexCoord2fv(@texcoords[faces[i].data[k].texCoodIndex - 1]); glVertex3fv(@vertexes[faces[i].data[k].vIndex - 1]);

© www.soinside.com 2019 - 2024. All rights reserved.