A freind of mine and myself are trying to make a map for a game that I am working on. He made the map and the faces are triangulated to go into my .OBJ loader (it just reads off all of the verticies and stores them into an array in order). HOWEVER, when I try and render it to the screen, it seems like all of the faces are tilted. Here is the code for the rendering:
for(int i = 2;i <= coordcount-1;i++){
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(coord[i-2][0],coord[i-2][1],coord[i-2][2]);
glVertex3f(coord[i-1][0],coord[i-1][1],coord[i-1][2]);
glVertex3f(coord[i][0],coord[i][1],coord[i][2]);
}
glEnd( );
and this is the object loader:
ifstream objfile ("triangulatedrockyhills.obj"); //open the .obj file
while(!(objfile.eof())){
string line;
stringstream ss;
string trash;
getline(objfile,line);
ss.str(line);
if(line[0] == 'v' && line[1] == ' '){
ss >> trash >> coord[coordcount][0] >> coord[coordcount][1] >> coord[coordcount][2];
printf("V I:%d X:%f Y:%f Z:%f
",coordcount,coord[coordcount][0],coord[coordcount][1],coord[coordcount][2]);
coordcount++;
}else if(line[0] == 'v' && line[1] == 'n'){
ss >> trash >> normcoord[normcoordcount][0] >> normcoord[normcoordcount][1] >> normcoord[normcoordcount][2];
printf("VN I:%d X:%f Y:%f Z:%f
",normcoordcount,coord[normcoordcount][0],coord[normcoordcount][1],coord[normcoordcount][2]);
normcoordcount++;
}else if(line[0] == 'f' && line[1] == ' '){
ss >> trash >> face[facecount][0] >> face[facecount][1] >> face[facecount][2];
printf("F I:%d A:%s B:%s C:%s
",facecount,(char *)face[facecount][0].c_str(),(char *)face[facecount][1].c_str(),(char *)face[facecount][2].c_str());
facecount++;
}
}
not sure exactly where the problem is (if it is in the loader or the rendering) but I decided to post it here since I have more experience in the coding than OpenGL. I hope you can help.