Changeset 2866 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Nov 16, 2004, 2:07:07 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/array.cc
r2853 r2866 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/src/object.cc
r2853 r2866 119 119 120 120 /** 121 121 \brief finalizes an Object. 122 122 This funcion is needed, to close the glList and all the other lists. 123 123 */ … … 226 226 if (verbose >= 2) 227 227 printf("Adding new Group\n"); 228 group->name = ""; 228 229 group->faceMode = -1; 229 group-> name = "";230 group->faceCount =0; 230 231 if ((group->listNumber = glGenLists(1)) == 0 ) 231 232 { … … 246 247 group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2; 247 248 } 248 249 if (verbose >=2) 250 printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal); 249 251 group->vertices = new Array(); 250 252 group->normals = new Array(); … … 256 258 /** 257 259 \brief finalizes a Group. 260 \param group the group to finalize. 258 261 */ 259 262 bool Object::finalizeGroup(Group* group) 260 263 { 264 if (verbose >=2) 265 printf ("Finalize group %s.\n", group->name); 261 266 glEnd(); 262 267 glEndList(); 268 } 269 /** 270 \brief deletes the Arrays of the Group to save space. 271 \param group the group to delete the arrays from. 272 */ 273 bool Object::cleanupGroup(Group* group) 274 { 275 if (verbose >=2) 276 printf ("cleaning up group %s.\n", group->name); 263 277 264 278 delete group->vertices; … … 266 280 delete group->vTexture; 267 281 } 282 268 283 /** 269 284 \brief Reads in the .obj File and sets all the Values. … … 330 345 } 331 346 OBJ_FILE->close(); 347 return true; 332 348 333 349 } … … 370 386 371 387 readingVertices = false; 388 currentGroup->faceCount++; 372 389 char subbuffer1[20]; 373 390 char subbuffer2[20]; … … 423 440 { 424 441 if (verbose >=3) 425 printf ("importing grafical Element .... includingto openGL\n");442 printf ("importing grafical Element to openGL\n"); 426 443 char* vertex = elementString; 427 444 … … 430 447 texture[0] = '\0'; 431 448 texture ++; 449 if (verbose>=3) 450 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()); 432 451 glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2); 433 452 … … 440 459 glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3); 441 460 } 461 if (verbose>=3) 462 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()); 442 463 glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3); 443 464 … … 488 509 bool Object::readGroup (char* groupString) 489 510 { 490 // printf ("test\n"); 491 if (!strcmp(groupString, "default")) 492 { 493 if (groupCount != 0) 494 { 495 Group* newGroup = new Group; 496 finalizeGroup(currentGroup); 497 currentGroup->nextGroup = newGroup; 498 initGroup(newGroup); 499 currentGroup = newGroup; // must be after init see initGroup for more info 500 } 501 ++groupCount; 502 } 503 else 504 { 505 506 currentGroup->name = new char [strlen(groupString)]; 511 // setting the group name if not default. 512 if (strcmp(currentGroup->name, "default")) 513 { 514 currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char)); 507 515 strcpy(currentGroup->name, groupString); 508 516 } 517 if (groupCount != 0 && currentGroup->faceCount>0) 518 { 519 Group* newGroup = new Group; 520 finalizeGroup(currentGroup); 521 currentGroup->nextGroup = newGroup; 522 initGroup(newGroup); 523 cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup. 524 currentGroup = newGroup; // must be after init see initGroup for more info 525 } 526 527 ++groupCount; 528 509 529 } 510 530 -
orxonox/trunk/src/object.h
r2853 r2866 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.