Changeset 3207 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 17, 2004, 9:44:10 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/importer/object.cc
r3206 r3207 90 90 if (this->mtlFileName) 91 91 delete []this->mtlFileName; 92 93 92 PRINTF(2)("Deleting Materials.\n"); 94 93 if (this->material) … … 103 102 void Object::draw (void) const 104 103 { 105 if (verbose >=2) 106 printf("drawing the 3D-Objects\n"); 104 PRINTF(2)("drawing the 3D-Objects\n"); 107 105 Group* walker = this->firstGroup; 108 106 while (walker != NULL) 109 107 { 110 if (verbose >= 3) 111 printf ("Drawing object %s\n", walker->name); 108 PRINTF(3)("Drawing object %s\n", walker->name); 112 109 glCallList (walker->listNumber); 113 110 walker = walker->next; … … 125 122 if (groupNumber >= this->groupCount) 126 123 { 127 if (verbose>=1) 128 printf ("You requested object number %i, but this File only contains of %i Objects.\n", groupNumber-1, this->groupCount); 124 PRINTF(1)("You requested object number %i, but this File only contains of %i Objects.\n", groupNumber-1, this->groupCount); 129 125 return; 130 126 } 131 if (verbose >=2) 132 printf("drawing the requested 3D-Objects if found.\n"); 127 PRINTF(2)("drawing the requested 3D-Objects if found.\n"); 133 128 Group* walker = this->firstGroup; 134 129 int counter = 0; … … 137 132 if (counter == groupNumber) 138 133 { 139 if (verbose >= 2) 140 printf ("Drawing object number %i named %s\n", counter, walker->name); 134 PRINTF(2)("Drawing object number %i named %s\n", counter, walker->name); 141 135 glCallList (walker->listNumber); 142 136 return; … … 145 139 walker = walker->next; 146 140 } 147 if (verbose >= 1) 148 printf("Object number %i in %s not Found.\n", groupNumber, this->objFileName); 141 PRINTF(1)("Object number %i in %s not Found.\n", groupNumber, this->objFileName); 149 142 return; 150 143 … … 159 152 void Object::draw (char* groupName) const 160 153 { 161 if (verbose >=2) 162 printf("drawing the requested 3D-Objects if found.\n"); 154 PRINTF(2)("drawing the requested 3D-Objects if found.\n"); 163 155 Group* walker = this->firstGroup; 164 156 while (walker != NULL) … … 166 158 if (!strcmp(walker->name, groupName)) 167 159 { 168 if (verbose >= 2) 169 printf ("Drawing object %s\n", walker->name); 160 PRINTF(2)("Drawing object %s\n", walker->name); 170 161 glCallList (walker->listNumber); 171 162 return; … … 173 164 walker = walker->next; 174 165 } 175 if (verbose >= 2) 176 printf("Object Named %s in %s not Found.\n", groupName, this->objFileName); 166 PRINTF(1)("Object Named %s in %s not Found.\n", groupName, this->objFileName); 177 167 return; 178 168 } … … 194 184 bool Object::initialize (void) 195 185 { 196 if (verbose >=3) 197 printf("new 3D-Object is being created\n"); 186 PRINTF(2)("new 3D-Object is being created\n"); 198 187 199 188 // setting the start group; … … 224 213 bool Object::initGroup(Group* group) 225 214 { 226 if (verbose >= 2) 227 printf("Adding new Group\n"); 215 PRINTF(3)("Adding new Group\n"); 228 216 group->name = ""; 229 217 group->faceMode = -1; … … 259 247 bool Object::cleanup(void) 260 248 { 261 if (verbose >=2) 262 printf("cleaning up the 3D-Object to save Memory.\n"); 249 PRINTF(3)("cleaning up the 3D-Object to save Memory.\n"); 263 250 264 251 if (this->vertices) … … 279 266 bool Object::cleanupGroup (Group* group) 280 267 { 281 if (verbose>=4) 282 printf ("Cleaning up group\n"); 268 PRINTF(3)("Cleaning up group\n"); 283 269 if (group->firstFace != NULL) 284 270 { … … 298 284 bool Object::cleanupFace (Face* face) 299 285 { 300 if (verbose>=4) 301 printf ("Cleaning up Face\n"); 286 PRINTF(3)("Cleaning up Face\n"); 302 287 303 288 if (face->materialString != NULL) … … 337 322 bool Object::importFile (char* fileName) 338 323 { 339 if (verbose >=3) 340 printf("preparing to read in file: %s\n", fileName); 324 PRINTF(3)("preparing to read in file: %s\n", fileName); 341 325 342 326 … … 361 345 if (verbose >=2) 362 346 if (strlen(objPath)> 0) 363 { 364 printf("Resolved file %s to folder: %s.\n", name, objPath); 365 } 347 PRINTF(0)("Resolved file %s to folder: %s.\n", name, objPath); 366 348 else 367 printf("Resolved file %s.\n", name);349 PRINTF(0)("Resolved file %s.\n", name); 368 350 369 351 if (this->material) … … 390 372 if (OBJ_FILE->fail()) 391 373 { 392 if (verbose >=1) 393 printf ("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName); 374 PRINTF(1)("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName); 394 375 BoxObject(); 395 376 OBJ_FILE->close(); … … 398 379 return false; 399 380 } 400 if (verbose >=2) 401 printf ("Reading from opened file %s\n", fileName); 381 PRINTF(2)("Reading from opened file %s\n", fileName); 402 382 char Buffer[10000]; 403 383 while(!OBJ_FILE->eof()) 404 384 { 405 385 OBJ_FILE->getline(Buffer, 10000); 406 if (verbose >=4) 407 printf ("Read input line: %s\n", Buffer); 386 PRINTF(3)("Read input line: %s\n", Buffer); 408 387 409 388 … … 449 428 { 450 429 if (verbose >= 2) 451 printf("smoothing groups not supportet yet. line: %s\n", Buffer);430 PRINTF(2)("smoothing groups not supportet yet. line: %s\n", Buffer); 452 431 } 453 432 } … … 468 447 bool Object::readGroup (char* groupString) 469 448 { 470 if (verbose >=3) 471 printf ("Read Group: %s.\n", groupString); 449 PRINTF(3)("Read Group: %s.\n", groupString); 472 450 if (this->groupCount != 0 && this->currentGroup->faceCount>0) 473 451 { … … 498 476 float subbuffer3; 499 477 sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3); 500 if (verbose >= 3) 501 printf ("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3); 478 PRINTF(3)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3); 502 479 this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor); 503 480 return true; … … 580 557 float subbuffer3; 581 558 sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3); 582 if (verbose >=3 ) 583 printf("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3); 559 PRINTF(3)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3); 584 560 this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3); 585 561 return true; … … 598 574 float subbuffer2; 599 575 sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2); 600 if (verbose >=3 ) 601 printf("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2); 576 PRINTF(3)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2); 602 577 this->vTexture->addEntry(subbuffer1); 603 578 this->vTexture->addEntry(subbuffer2); … … 623 598 624 599 625 if (verbose >=2) 626 printf ("Opening mtlFile: %s\n", fileName); 600 PRINTF(2)("Opening mtlFile: %s\n", fileName); 627 601 628 602 ifstream* MTL_FILE = new ifstream (fileName); … … 630 604 { 631 605 if (verbose >= 1) 632 printf("unable to open file: %s\n", fileName);606 PRINTF(2)("unable to open file: %s\n", fileName); 633 607 MTL_FILE->close(); 634 608 delete []fileName; … … 641 615 { 642 616 MTL_FILE->getline(Buffer, 500); 643 if (verbose >= 4) 644 printf("found line in mtlFile: %s\n", Buffer); 617 PRINTF(4)("found line in mtlFile: %s\n", Buffer); 645 618 646 619 … … 649 622 { 650 623 tmpMat = tmpMat->addMaterial(Buffer+7); 651 // printf("%s, %p\n", tmpMat->getName(), tmpMat);624 // PRINTF(2)("%s, %p\n", tmpMat->getName(), tmpMat); 652 625 } 653 626 // setting a illumMode … … 720 693 if (!this->mtlFileName) 721 694 { 722 if (verbose >= 1) 723 printf ("Not using new defined material, because no mtlFile found yet\n"); 695 PRINTF(4)("Not using new defined material, because no mtlFile found yet\n"); 724 696 return false; 725 697 } … … 758 730 if ((this->currentGroup->listNumber = glGenLists(1)) == 0) 759 731 { 760 printf("list could not be created for this Object\n");732 PRINTF(1)("list could not be created for this Object\n"); 761 733 return false; 762 734 } … … 772 744 glEnd(); 773 745 this->currentGroup->faceMode = 0; 774 if (verbose >= 2) 775 printf ("using material %s for coming Faces.\n", tmpFace->materialString); 746 PRINTF(2)("using material %s for coming Faces.\n", tmpFace->materialString); 776 747 Material* tmpMat; 777 748 if ((tmpMat = material->search(tmpFace->materialString)) != NULL) … … 790 761 791 762 this->currentGroup->faceMode = 3; 792 if (verbose >=3) 793 printf ("found triag.\n"); 763 PRINTF(3)("found triag.\n"); 794 764 } 795 765 … … 803 773 } 804 774 this->currentGroup->faceMode = 4; 805 if (verbose >=3 ) 806 printf ("found quad.\n"); 775 PRINTF(3)("found quad.\n"); 807 776 } 808 777 … … 812 781 glEnd(); 813 782 glBegin(GL_POLYGON); 814 if (verbose >=3) 815 printf ("Polygon with %i faces found.", tmpFace->vertexCount); 783 PRINTF(3)("Polygon with %i faces found.", tmpFace->vertexCount); 816 784 this->currentGroup->faceMode = tmpFace->vertexCount; 817 785 } … … 820 788 while (tmpElem != NULL) 821 789 { 822 // printf("%s\n", tmpElem->value);790 // PRINTF(2)("%s\n", tmpElem->value); 823 791 this->addGLElement(tmpElem); 824 792 tmpElem = tmpElem->next; … … 845 813 bool Object::addGLElement (FaceElement* elem) 846 814 { 847 if (verbose >=3) 848 printf ("importing grafical Element to openGL.\n"); 815 PRINTF(3)("importing grafical Element to openGL.\n"); 849 816 850 817 if (elem->texCoordNumber != -1) … … 869 836 { 870 837 871 if (verbose >=2) 872 printf("Normals are being calculated.\n"); 838 PRINTF(2)("Normals are being calculated.\n"); 873 839 874 840 Vector* normArray = new Vector [vertices->getCount()/3]; … … 927 893 { 928 894 normArray[i].normalize(); 929 if (verbose >=3) 930 printf ("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z); 895 PRINTF(3)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z); 931 896 932 897 this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);
Note: See TracChangeset
for help on using the changeset viewer.