Changes between Version 32 and Version 33 of tutorial
- Timestamp:
- Jun 30, 2013, 4:34:04 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
tutorial
v32 v33 530 530 #define MaxGroups 100 531 531 532 GLfloat vertex[MaxVertices ][3];533 GLuint face[MaxFaces ][3];532 GLfloat vertex[MaxVertices*3]; 533 GLuint face[MaxFaces*3]; 534 534 char group_name[MaxGroups][80]; 535 535 int start_face[MaxGroups]; … … 547 547 { 548 548 case 'v': 549 sscanf(&line[1], "%f %f %f", &vertex[vertices ][0],550 &vertex[vertices ][1], &vertex[vertices][2]);549 sscanf(&line[1], "%f %f %f", &vertex[vertices+3], 550 &vertex[vertices*3+1], &vertex[vertices*3+2]); 551 551 ++vertices; 552 552 break; … … 556 556 break; 557 557 case 'f': 558 sscanf(&line[1], "%d %d %d", &face[faces][0], 559 &face[faces][1], &face[faces][2]); 560 ++faces; 558 sscanf(&line[1], "%d %d %d", &face[faces*3], 559 &face[faces*3+1], &face[faces*3+2]); 560 --face[faces*3]; --face[faces*3+1]; 561 --face[faces*3+2]; ++faces; 561 562 break; 562 563 } … … 574 575 FILE *f = fopen(n, "w"); fprintf(f, "# Wavefront OBJ file\n"); 575 576 for (i = 0; i < vertices; i++) 576 fprintf(f, "v %g %g %g\n", vertex[i ][0], vertex[i][1], vertex[i][2]);577 fprintf(f, "v %g %g %g\n", vertex[i*3], vertex[i*3+1], vertex[i*3+2]); 577 578 fprintf(f, "g %s\n", group_name[group_number]); 578 579 for (i = start_face[group_number]; i < start_face[group_number+1]; ++i) 579 fprintf(f, "f %d %d %d\n", face[i ][0], face[i][1], face[i][2]);580 fprintf(f, "f %d %d %d\n", face[i*3]+1, face[i*3+1]+1, face[i*3+2]+1); 580 581 fclose(f); 581 582 }