Changeset 2863 in orxonox.OLD for orxonox/trunk/importer/object.cc
- Timestamp:
- Nov 16, 2004, 1:19:54 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.