- Timestamp:
- Nov 16, 2004, 1:19:54 AM (20 years ago)
- Location:
- orxonox/trunk/importer
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/array.cc
r2848 r2863 69 69 printf ("Finalizing array.\n"); 70 70 if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) 71 // if ((array = new GLfloat [entryCount]) == NULL) 71 72 printf ("could not allocate %i data Blocks\n", entryCount); 72 73 Entry* walker = firstEntry; … … 77 78 } 78 79 finalized = true; 80 79 81 return; 80 82 } … … 91 93 printf ("adding new Entry to Array: %f\n", entry); 92 94 93 entryCount++;94 95 currentEntry->value = entry; 95 96 currentEntry->next = new Entry; 96 97 currentEntry = currentEntry->next; 97 98 currentEntry->next = NULL; 99 ++entryCount; 98 100 } 99 101 else -
orxonox/trunk/importer/framework.cc
r2850 r2863 2 2 #include "object.h" 3 3 4 int verbose = 2;4 int verbose = 1; 5 5 WindowHandler wHandler; // Create an instance of the whandler basecode class 6 6 Object* obj; … … 74 74 switch (event.type) { 75 75 // If a quit event was recieved 76 77 76 case SDL_QUIT: 77 // then we're done and we'll end this program 78 78 done=TRUE; 79 79 break; 80 80 default: 81 81 break; 82 82 } -
orxonox/trunk/importer/object.cc
r2852 r2863 117 117 118 118 /** 119 119 \brief finalizes an Object. 120 120 This funcion is needed, to close the glList and all the other lists. 121 121 */ … … 224 224 if (verbose >= 2) 225 225 printf("Adding new Group\n"); 226 group->name = ""; 226 227 group->faceMode = -1; 227 group-> name = "";228 group->faceCount =0; 228 229 if ((group->listNumber = glGenLists(1)) == 0 ) 229 230 { … … 244 245 group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2; 245 246 } 246 247 if (verbose >=2) 248 printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal); 247 249 group->vertices = new Array(); 248 250 group->normals = new Array(); … … 254 256 /** 255 257 \brief finalizes a Group. 258 \param group the group to finalize. 256 259 */ 257 260 bool Object::finalizeGroup(Group* group) 258 261 { 262 if (verbose >=2) 263 printf ("Finalize group %s.\n", group->name); 259 264 glEnd(); 260 265 glEndList(); 266 } 267 /** 268 \brief deletes the Arrays of the Group to save space. 269 \param group the group to delete the arrays from. 270 */ 271 bool Object::cleanupGroup(Group* group) 272 { 273 if (verbose >=2) 274 printf ("cleaning up group %s.\n", group->name); 261 275 262 276 delete group->vertices; … … 264 278 delete group->vTexture; 265 279 } 280 266 281 /** 267 282 \brief Reads in the .obj File and sets all the Values. … … 328 343 } 329 344 OBJ_FILE->close(); 345 return true; 330 346 331 347 } … … 368 384 369 385 readingVertices = false; 386 currentGroup->faceCount++; 370 387 char subbuffer1[20]; 371 388 char subbuffer2[20]; … … 421 438 { 422 439 if (verbose >=3) 423 printf ("importing grafical Element .... includingto openGL\n");440 printf ("importing grafical Element to openGL\n"); 424 441 char* vertex = elementString; 425 442 … … 428 445 texture[0] = '\0'; 429 446 texture ++; 447 if (verbose>=3) 448 printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount()); 430 449 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 431 450 … … 438 457 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 439 458 } 459 if (verbose>=3) 460 printf ("includeing vertex #%i, and mapping it to group vertex #%i, vertexArray has %i entries.\n", atoi(vertex), (atoi(vertex)-1 - currentGroup->firstVertex)*3, currentGroup->vertices->getCount()); 440 461 glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3); 441 462 … … 486 507 bool Object::readGroup (char* groupString) 487 508 { 488 // printf ("test\n"); 489 if (!strcmp(groupString, "default")) 490 { 491 if (groupCount != 0) 492 { 493 Group* newGroup = new Group; 494 finalizeGroup(currentGroup); 495 currentGroup->nextGroup = newGroup; 496 initGroup(newGroup); 497 currentGroup = newGroup; // must be after init see initGroup for more info 498 } 499 ++groupCount; 500 } 501 else 502 { 503 504 currentGroup->name = new char [strlen(groupString)]; 509 // setting the group name if not default. 510 if (strcmp(currentGroup->name, "default")) 511 { 512 currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char)); 505 513 strcpy(currentGroup->name, groupString); 506 514 } 515 if (groupCount != 0 && currentGroup->faceCount>0) 516 { 517 Group* newGroup = new Group; 518 finalizeGroup(currentGroup); 519 currentGroup->nextGroup = newGroup; 520 initGroup(newGroup); 521 cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup. 522 currentGroup = newGroup; // must be after init see initGroup for more info 523 } 524 525 ++groupCount; 526 507 527 } 508 528 -
orxonox/trunk/importer/object.h
r2852 r2863 49 49 Array* vTexture; 50 50 int faceMode; 51 int faceCount; 51 52 52 53 int firstVertex; … … 74 75 bool initGroup(Group* group); 75 76 bool finalizeGroup (Group* group); 77 bool cleanupGroup(Group* group); 76 78 77 79
Note: See TracChangeset
for help on using the changeset viewer.