Changeset 2765 in orxonox.OLD
- Timestamp:
- Nov 9, 2004, 2:54:49 PM (20 years ago)
- Location:
- orxonox/branches/importer/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/importer/importer/framework.cc
r2759 r2765 9 9 void DrawGLScene() 10 10 { 11 rotator +=.0 001;11 rotator +=.01; 12 12 13 13 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); … … 17 17 glLoadIdentity(); 18 18 gluPerspective(45.0f,500/375,0.1f,100.0f); 19 gluLookAt (10*sin(rotator), 5,10*cos(rotator), 0,0,0, 0,1,0);20 19 gluLookAt (10*sin(rotator),15,10*cos(rotator), 0,0,0, 0,1,0); 20 21 21 obj->draw(); 22 23 24 22 25 23 SDL_GL_SwapBuffers(); // Swap the buffers -
orxonox/branches/importer/importer/object.cc
r2762 r2765 1 1 #include "object.h" 2 3 2 Object::Object () 4 3 { 5 this->readFromObjFile ("reaphigh.obj"); 6 4 this->readFromObjFile ("sphere.obj"); 5 6 listNumber = glGenLists(1); 7 glNewList (listNumber, GL_COMPILE); 8 7 9 glEnableClientState (GL_VERTEX_ARRAY); 8 10 glVertexPointer(3, GL_FLOAT, 0, vertices->getArray()); 9 11 10 listNumber = glGenLists(1);11 glNewList (listNumber, GL_COMPILE);12 13 12 glColor3f(1.0,0,0); 14 13 glBegin(GL_QUADS); 15 14 printf ("face-count %i\n", faces->getCount()); 16 15 for (int i=0; i<=faces->getCount();++i) 17 16 { 18 printf ("%i, %i\n", i, (int) faces->getArray()[i]);19 17 glArrayElement((int)faces->getArray()[i] -1); 20 18 } … … 35 33 bool Object::readFromObjFile (char* fileName) 36 34 { 35 OBJ_FILE = new ifstream (fileName); 36 char Buffer[500]; 37 vertices = new Array(); 38 faces = new Array(); 39 while(!OBJ_FILE->eof()) 40 { 41 OBJ_FILE->getline(Buffer, 500); 42 // printf("%s\n", Buffer); 43 44 45 // case vertice 46 if (!strncmp(Buffer, "v ", 2)) 47 { 48 char subbuffer1[10]; 49 char subbuffer2[10]; 50 char subbuffer3[10]; 51 sscanf (Buffer, "v %s %s %s", subbuffer1, subbuffer2, subbuffer3); 52 vertices->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3)); 53 } 54 55 // case face 56 else if (!strncmp(Buffer, "f ", 2)) 57 { 58 char subbuffer1[10]; 59 char subbuffer2[10]; 60 char subbuffer3[10]; 61 char subbuffer4[10] =""; 62 sscanf (Buffer, "f %s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 63 // vertices->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3)); 64 if (!strcmp(subbuffer4, "")) 65 { 66 printf ("triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3); 67 faces->addEntry(atof(subbuffer1)); 68 faces->addEntry(atof(subbuffer2)); 69 faces->addEntry(atof(subbuffer3)); 70 } 71 else 72 { 73 printf ("quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4); 74 faces->addEntry(atof(subbuffer1)); 75 faces->addEntry(atof(subbuffer2)); 76 faces->addEntry(atof(subbuffer3)); 77 faces->addEntry(atof(subbuffer4)); 78 79 } 80 } 81 82 // case vt 83 else if (!strncmp(Buffer, "vt ", 2)) 84 { 85 // printf ("verticeTangent found"); 86 } 87 88 89 } 90 91 92 93 OBJ_FILE->close(); 94 95 /* 96 37 97 if ( (OBJ_FILE = fopen (fileName, "r")) == NULL) 38 98 { … … 43 103 { 44 104 char Buffer[100]; 45 vertices = new Array();46 faces = new Array();47 char lastWas = '0';48 49 while (fscanf (OBJ_FILE, "% s", Buffer) != EOF)105 char optionIs = '0'; 106 char optionWas = '0'; 107 int entryCount = 0; //counts how many inputs an option has. 108 int lastEntryCount = 0; 109 while (fscanf (OBJ_FILE, "%c10", Buffer) != EOF) 50 110 { 51 111 printf("%s", Buffer); 112 52 113 // case we read it is a vertex 53 114 if (!strcmp (Buffer, "v")) 54 115 { 55 lastWas = 'v'; 116 optionIs = 'v'; 117 entryCount = 0; 56 118 } 57 119 // case we read a Face 58 120 else if (!strcmp (Buffer, "f")) 59 121 { 60 lastWas = 'f'; 122 optionIs = 'f'; 123 entryCount = 0; 61 124 } 62 125 else if (!strcmp (Buffer, "vn")) 63 126 { 64 lastWas = 'n'; 127 optionIs = 'n'; 128 entryCount = 0; 65 129 } 66 130 else if (!strcmp (Buffer, "vt")) 67 131 { 68 lastWas = 't'; 132 optionIs = 't'; 133 entryCount = 0; 69 134 } 70 135 else if (!strcmp (Buffer,"s")) 71 136 { 72 lastWas = '0'; 137 optionIs = '0'; 138 entryCount = 0; 73 139 } 74 140 else if (!strncmp (Buffer,"u", 1)) 75 141 { 76 lastWas = '0'; 142 optionIs = '0'; 143 entryCount = 0; 77 144 } 78 145 else if (!strcmp (Buffer,"g")) 79 146 { 80 lastWas = '0'; 147 optionIs = '0'; 148 entryCount = 0; 81 149 } 82 150 … … 85 153 else 86 154 { 87 if ( lastWas == 'v')155 if (optionIs == 'v') 88 156 { 89 157 vertices->addEntry(atof(Buffer)); 90 printf ("v: %s\n", Buffer); 158 ++entryCount; 159 160 // printf ("v: %s\n", Buffer); 91 161 } 92 else if ( lastWas == 'f')162 else if (optionIs == 'f') 93 163 { 94 164 char* pointTo; 95 165 pointTo = strstr (Buffer, "/"); 96 166 pointTo[0] = '\0'; 97 printf ("f: %s\n", Buffer);167 // printf ("f: %s\n", Buffer); 98 168 faces->addEntry(atof(Buffer)); 169 ++entryCount; 99 170 } 100 171 101 172 } 173 174 if (entryCount == 0 && (optionWas == 'f')) 175 { 176 if (lastEntryCount == 3) 177 printf ("triang\n"); 178 else if (lastEntryCount == 4) 179 printf ("quads\n"); 180 181 } 182 183 lastEntryCount = entryCount; 184 optionWas = optionIs; 185 102 186 } 103 187 vertices->finalizeArray(); 104 188 faces->finalizeArray(); 105 189 fclose (OBJ_FILE); 106 printf("test\n");107 190 return true; 108 191 } 192 */ 109 193 } 194 195 //caseChange (char optionIs, int entryCount) -
orxonox/branches/importer/importer/object.h
r2760 r2765 1 1 #include "windowHandler.h" 2 2 #include "array.h" 3 #include <fstream.h> 3 4 4 5 class Object … … 20 21 Array* faces; 21 22 22 FILE* OBJ_FILE;23 FILE* MTL_FILE;23 ifstream* OBJ_FILE; 24 ifstream* MTL_FILE; 24 25 25 26
Note: See TracChangeset
for help on using the changeset viewer.