The code:
Here i'm just calculating vertices, faces and normals
procedure TForm1.Import(failas : string);var F : TextFile;begin AssignFile(F,failas); Reset(F); vertexCount := 0; facesCount := 0; texCoordsCount := 0; normalsCount := 0; while not Eof(F) do begin Readln(F,buffer[0]); if buffer[0] = 'v' then begin vertexCount := vertexCount + 1; //Read(F,buffer[0],vertex[vertexCount].x,vertex[vertexCount].y,vertex[vertexCount].z); end else if buffer[0] = 'f' then begin facesCount := facesCount + 1; //Read(F, buffer[0], vertices[facesCount].v1, texNormals[facesCount].v1, normals[facesCount].v1, //vertices[facesCount].v2, texNormals[facesCount].v2, normals[facesCount].v2, //vertices[facesCount].v3, texNormals[facesCount].v3, normals[facesCount].v3); end else if buffer[0] = 'n' then begin normalsCount := normalsCount + 1; //Read(F, buffer[0], normals2[normalsCount].x, normals2[normalsCount].y, normals2[normalsCount].z); end else if buffer[0] = 't' then begin texCoordsCount := texCoordsCount + 1; //Read(F, buffer[0], texCoords[texCoordsCount].x,texCoords[texCoordsCount].y,texCoords[texCoordsCount].z); end end; memo1.Lines.add('FacesCount = ' + IntToStr(facesCount)); memo1.Lines.add('VertexCount = ' + IntToStr(vertexCount)); memo1.Lines.add('NormalsCount = ' + IntToStr(normalsCount)); CloseFile(F);end;
Result:
FacesCount = 2256VertexCount = 1178NormalsCount = 1178
If i try to read, result is:
FacesCount = 1128VertexCount = 589NormalsCount = 589
Any ideas?