Changeset 2761 in orxonox.OLD for orxonox/branches/importer
- Timestamp:
- Nov 9, 2004, 3:32:54 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/importer/importer/object.cc
r2760 r2761 3 3 Object::Object () 4 4 { 5 this->readFromObjFile (" cube.obj");5 this->readFromObjFile ("sphere.obj"); 6 6 7 7 glEnableClientState (GL_VERTEX_ARRAY); … … 19 19 glArrayElement((int)faces->getArray()[i] -1); 20 20 } 21 /* glArrayElement(1);22 glArrayElement(3);23 glArrayElement(2);24 25 glArrayElement(2);26 glArrayElement(3);27 glArrayElement(5);28 glArrayElement(4);29 30 glArrayElement(4);31 glArrayElement(5);32 glArrayElement(7);33 glArrayElement(6);34 35 glArrayElement(6);36 glArrayElement(7);37 glArrayElement(1);38 glArrayElement(0);39 40 glArrayElement(1);41 glArrayElement(7);42 glArrayElement(5);43 glArrayElement(3);44 45 glArrayElement(6);46 glArrayElement(0);47 glArrayElement(2);48 glArrayElement(4);49 */50 51 21 52 22 glEnd(); … … 72 42 else 73 43 { 74 char Buffer[10 ];44 char Buffer[100]; 75 45 vertices = new Array(); 76 46 faces = new Array(); 77 47 char lastWas = '0'; 48 78 49 while (fscanf (OBJ_FILE, "%s", Buffer) != EOF) 79 50 { 80 // printf ("%s\n",Buffer); 81 51 82 52 // case we read it is a vertex 83 53 if (!strcmp (Buffer, "v")) 84 { 85 for (int i=0; i<=2;i++) 86 { 87 fscanf (OBJ_FILE, "%s", Buffer); 88 //printf ("float: %f\n", atof(Buffer)); 89 vertices->addEntry(atof(Buffer)); 90 } 54 { 55 lastWas = 'v'; 91 56 } 92 57 // case we read a Face 93 if (!strcmp (Buffer, "f"))58 else if (!strcmp (Buffer, "f")) 94 59 { 95 for (int i=0; i<=3;i++) 60 lastWas = 'f'; 61 } 62 else if (!strcmp (Buffer, "vn")) 63 { 64 lastWas = 'n'; 65 } 66 else if (!strcmp (Buffer, "vt")) 67 { 68 lastWas = 't'; 69 } 70 // all other cases 71 else 72 { 73 if (lastWas == 'v') 74 { 75 vertices->addEntry(atof(Buffer)); 76 printf ("v: %s\n", Buffer); 77 } 78 else if (lastWas == 'f') 96 79 { 97 80 char* pointTo; 98 fscanf (OBJ_FILE, "%s", Buffer);99 81 pointTo = strstr (Buffer, "/"); 100 82 pointTo[0] = '\0'; 101 printf (" int: %s\n", Buffer);83 printf ("f: %s\n", Buffer); 102 84 faces->addEntry(atof(Buffer)); 103 85 } 86 104 87 } 105 88 } 106 89 vertices->finalizeArray(); 90 faces->finalizeArray(); 107 91 fclose (OBJ_FILE); 92 printf("test\n"); 108 93 return true; 109 94 }
Note: See TracChangeset
for help on using the changeset viewer.