- Timestamp:
- Mar 10, 2006, 2:37:11 AM (19 years ago)
- Location:
- branches/std/src/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/lib/graphics/importer/static_model.cc
r7203 r7210 225 225 ModelGroup* tmpGroup = this->firstGroup; 226 226 while (tmpGroup != NULL) 227 228 229 230 231 227 { 228 PRINTF(5)("Drawing model %s\n", tmpGroup->name); 229 glCallList (tmpGroup->listNumber); 230 tmpGroup = tmpGroup->next; 231 } 232 232 } 233 233 … … 242 242 { 243 243 if (unlikely(groupNumber >= this->groupCount)) 244 245 246 247 244 { 245 PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, this->groupCount); 246 return; 247 } 248 248 PRINTF(4)("drawing the requested 3D-Models if found.\n"); 249 249 ModelGroup* tmpGroup = this->firstGroup; 250 250 int counter = 0; 251 251 while (tmpGroup != NULL) 252 { 253 if (counter == groupNumber) 252 254 { 253 if (counter == groupNumber) 254 { 255 PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name); 256 glCallList (tmpGroup->listNumber); 257 return; 258 } 259 ++counter; 260 tmpGroup = tmpGroup->next; 255 PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name); 256 glCallList (tmpGroup->listNumber); 257 return; 261 258 } 259 ++counter; 260 tmpGroup = tmpGroup->next; 261 } 262 262 PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getName()); 263 263 return; … … 276 276 ModelGroup* tmpGroup = this->firstGroup; 277 277 while (tmpGroup != NULL) 278 { 279 if (tmpGroup->name == groupName) 278 280 { 279 if (tmpGroup->name == groupName) 280 { 281 PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str()); 282 glCallList (tmpGroup->listNumber); 283 return; 284 } 285 tmpGroup = tmpGroup->next; 281 PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str()); 282 glCallList (tmpGroup->listNumber); 283 return; 286 284 } 287 PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getName()); 285 tmpGroup = tmpGroup->next; 286 } 287 PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getName()); 288 288 return; 289 289 } … … 370 370 PRINTF(5)("Read Group: %s.\n", groupString); 371 371 if (this->groupCount != 0 && this->currentGroup->faceCount > 0) 372 373 374 375 372 { 373 // finalizeGroup(currentGroup); 374 this->currentGroup = this->currentGroup->next = new ModelGroup; 375 } 376 376 // setting the group name if not default. 377 377 if (groupString == "default") 378 379 380 378 { 379 this->currentGroup->name = groupString; 380 } 381 381 ++this->groupCount; 382 382 } … … 509 509 tmpElem->next = NULL; 510 510 while(strcmp (faceString, "\0")) 511 { 512 if (this->currentGroup->currentFace->vertexCount>0) 513 tmpElem = tmpElem->next = new ModelFaceElement; 514 tmpElem->next = NULL; 515 516 char tmpValue [50]; 517 int tmpLen; 518 char* vertex = NULL; 519 char* texture = NULL; 520 char* normal = NULL; 521 522 sscanf (faceString, "%s", tmpValue); 523 tmpLen = strlen(tmpValue); 524 vertex = tmpValue; 525 526 if ((texture = strstr (vertex, "/")) != NULL) 511 527 { 512 if (this->currentGroup->currentFace->vertexCount>0) 513 tmpElem = tmpElem->next = new ModelFaceElement; 514 tmpElem->next = NULL; 515 516 char tmpValue [50]; 517 int tmpLen; 518 char* vertex = NULL; 519 char* texture = NULL; 520 char* normal = NULL; 521 522 sscanf (faceString, "%s", tmpValue); 523 tmpLen = strlen(tmpValue); 524 vertex = tmpValue; 525 526 if ((texture = strstr (vertex, "/")) != NULL) 527 { 528 texture[0] = '\0'; 529 texture ++; 530 531 if ((normal = strstr (texture, "/")) !=NULL) 532 { 533 normal[0] = '\0'; 534 normal ++; 535 } 536 } 537 if (vertex) 538 tmpElem->vertexNumber = atoi(vertex)-1; 539 if (texture) 540 tmpElem->texCoordNumber = atoi(texture)-1; 541 if (normal) 542 tmpElem->normalNumber = atoi(normal)-1; 543 544 faceString += tmpLen; 545 if (strcmp (faceString, "\0")) 546 faceString++; 547 this->currentGroup->currentFace->vertexCount++; 528 texture[0] = '\0'; 529 texture ++; 530 531 if ((normal = strstr (texture, "/")) !=NULL) 532 { 533 normal[0] = '\0'; 534 normal ++; 535 } 548 536 } 537 if (vertex) 538 tmpElem->vertexNumber = atoi(vertex)-1; 539 if (texture) 540 tmpElem->texCoordNumber = atoi(texture)-1; 541 if (normal) 542 tmpElem->normalNumber = atoi(normal)-1; 543 544 faceString += tmpLen; 545 if (strcmp (faceString, "\0")) 546 faceString++; 547 this->currentGroup->currentFace->vertexCount++; 548 } 549 549 550 550 this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2; … … 568 568 569 569 for (int i = 0; i < faceElemCount; i++) 570 571 572 573 574 575 576 577 578 579 580 570 { 571 if (this->currentGroup->currentFace->vertexCount > 0) 572 tmpElem = tmpElem->next = new ModelFaceElement; 573 574 tmpElem->vertexNumber = va_arg (itemlist, int); 575 if (type & TEXCOORD) 576 tmpElem->texCoordNumber = va_arg (itemlist, int); 577 if (type & NORMAL) 578 tmpElem->normalNumber = va_arg(itemlist, int); 579 this->currentGroup->currentFace->vertexCount++; 580 } 581 581 va_end(itemlist); 582 582 … … 640 640 ModelGroup* tmpGroup = firstGroup; 641 641 while (tmpGroup != NULL) 642 { 643 ModelFace* tmpFace = tmpGroup->firstFace; 644 while (tmpFace != NULL) 642 645 { 643 ModelFace* tmpFace = tmpGroup->firstFace; 644 while (tmpFace != NULL) 646 if (tmpFace->firstElem != NULL) 647 { 648 ModelFaceElement* firstElem = tmpFace->firstElem; 649 ModelFaceElement* prevElem; 650 ModelFaceElement* curElem = firstElem; 651 ModelFaceElement* nextElem; 652 ModelFaceElement* lastElem; 653 // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop. 654 while (curElem != NULL) 645 655 { 646 if (tmpFace->firstElem != NULL) 647 { 648 ModelFaceElement* firstElem = tmpFace->firstElem; 649 ModelFaceElement* prevElem; 650 ModelFaceElement* curElem = firstElem; 651 ModelFaceElement* nextElem; 652 ModelFaceElement* lastElem; 653 // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop. 654 while (curElem != NULL) 655 { 656 prevElem = curElem; 657 curElem = curElem->next; 658 } 659 lastElem = prevElem; 660 661 curElem = firstElem; 662 for (int j=0; j<tmpFace->vertexCount; j++) 663 { 664 if (!(nextElem = curElem->next)) 665 nextElem = firstElem; 666 curElem->normalNumber = curElem->vertexNumber; 667 668 curV = Vector (this->vertices[curElem->vertexNumber*3], 669 this->vertices[curElem->vertexNumber*3+1], 670 this->vertices[curElem->vertexNumber*3+2]); 671 672 prevV = Vector (this->vertices[prevElem->vertexNumber*3], 673 this->vertices[prevElem->vertexNumber*3+1], 674 this->vertices[prevElem->vertexNumber*3+2]) - curV; 675 676 nextV = Vector (this->vertices[nextElem->vertexNumber*3], 677 this->vertices[nextElem->vertexNumber*3+1], 678 this->vertices[nextElem->vertexNumber*3+2]) - curV; 679 normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV); 680 681 prevElem = curElem; 682 curElem = curElem->next; 683 } 684 } 685 tmpFace = tmpFace->next; 656 prevElem = curElem; 657 curElem = curElem->next; 686 658 } 687 tmpGroup = tmpGroup->next; 659 lastElem = prevElem; 660 661 curElem = firstElem; 662 for (int j=0; j<tmpFace->vertexCount; j++) 663 { 664 if (!(nextElem = curElem->next)) 665 nextElem = firstElem; 666 curElem->normalNumber = curElem->vertexNumber; 667 668 curV = Vector (this->vertices[curElem->vertexNumber*3], 669 this->vertices[curElem->vertexNumber*3+1], 670 this->vertices[curElem->vertexNumber*3+2]); 671 672 prevV = Vector (this->vertices[prevElem->vertexNumber*3], 673 this->vertices[prevElem->vertexNumber*3+1], 674 this->vertices[prevElem->vertexNumber*3+2]) - curV; 675 676 nextV = Vector (this->vertices[nextElem->vertexNumber*3], 677 this->vertices[nextElem->vertexNumber*3+1], 678 this->vertices[nextElem->vertexNumber*3+2]) - curV; 679 normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV); 680 681 prevElem = curElem; 682 curElem = curElem->next; 683 } 684 } 685 tmpFace = tmpFace->next; 688 686 } 687 tmpGroup = tmpGroup->next; 688 } 689 689 690 690 for (int i=0; i < this->vertices.size()/3;i++) 691 692 693 694 695 696 697 691 { 692 normArray[i].normalize(); 693 PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z); 694 695 this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z); 696 697 } 698 698 delete[] normArray; 699 699 } … … 714 714 715 715 while (this->currentGroup != NULL) 716 { 717 718 // creating a glList for the Group 719 if ((this->currentGroup->listNumber = glGenLists(1)) == 0) 716 720 { 717 718 // creating a glList for the Group 719 if ((this->currentGroup->listNumber = glGenLists(1)) == 0) 721 PRINTF(2)("glList could not be created for this Model\n"); 722 return false; 723 } 724 glNewList (this->currentGroup->listNumber, GL_COMPILE); 725 726 // Putting Faces to GL 727 ModelFace* tmpFace = this->currentGroup->firstFace; 728 while (tmpFace != NULL) 729 { 730 if (tmpFace->vertexCount == 0 && tmpFace->material != NULL) 731 { 732 if (this->currentGroup->faceMode != -1) 733 glEnd(); 734 this->currentGroup->faceMode = 0; 735 Material* tmpMat; 736 if (tmpFace->material != NULL) 720 737 { 721 PRINTF(2)("glList could not be created for this Model\n");722 return false;738 tmpFace->material->select(); 739 PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName()); 723 740 } 724 glNewList (this->currentGroup->listNumber, GL_COMPILE);725 726 // Putting Faces to GL727 ModelFace* tmpFace = this->currentGroup->firstFace;728 while (tmpFace != NULL)741 } 742 743 else if (tmpFace->vertexCount == 3) 744 { 745 if (this->currentGroup->faceMode != 3) 729 746 { 730 if (tmpFace->vertexCount == 0 && tmpFace->material != NULL) 731 { 732 if (this->currentGroup->faceMode != -1) 733 glEnd(); 734 this->currentGroup->faceMode = 0; 735 Material* tmpMat; 736 if (tmpFace->material != NULL) 737 { 738 tmpFace->material->select(); 739 PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName()); 740 } 741 } 742 743 else if (tmpFace->vertexCount == 3) 744 { 745 if (this->currentGroup->faceMode != 3) 746 { 747 if (this->currentGroup->faceMode != -1) 748 glEnd(); 749 glBegin(GL_TRIANGLES); 750 } 751 752 this->currentGroup->faceMode = 3; 753 PRINTF(5)("found triag.\n"); 754 } 755 756 else if (tmpFace->vertexCount == 4) 757 { 758 if (this->currentGroup->faceMode != 4) 759 { 760 if (this->currentGroup->faceMode != -1) 761 glEnd(); 762 glBegin(GL_QUADS); 763 } 764 this->currentGroup->faceMode = 4; 765 PRINTF(5)("found quad.\n"); 766 } 767 768 else if (tmpFace->vertexCount > 4) 769 { 770 if (this->currentGroup->faceMode != -1) 771 glEnd(); 772 glBegin(GL_POLYGON); 773 PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount); 774 this->currentGroup->faceMode = tmpFace->vertexCount; 775 } 776 777 ModelFaceElement* tmpElem = tmpFace->firstElem; 778 while (tmpElem != NULL) 779 { 780 // PRINTF(2)("%s\n", tmpElem->value); 781 this->addGLElement(tmpElem); 782 tmpElem = tmpElem->next; 783 } 784 tmpFace = tmpFace->next; 747 if (this->currentGroup->faceMode != -1) 748 glEnd(); 749 glBegin(GL_TRIANGLES); 785 750 } 786 glEnd(); 787 glEndList(); 788 789 this->currentGroup = this->currentGroup->next; 751 752 this->currentGroup->faceMode = 3; 753 PRINTF(5)("found triag.\n"); 754 } 755 756 else if (tmpFace->vertexCount == 4) 757 { 758 if (this->currentGroup->faceMode != 4) 759 { 760 if (this->currentGroup->faceMode != -1) 761 glEnd(); 762 glBegin(GL_QUADS); 763 } 764 this->currentGroup->faceMode = 4; 765 PRINTF(5)("found quad.\n"); 766 } 767 768 else if (tmpFace->vertexCount > 4) 769 { 770 if (this->currentGroup->faceMode != -1) 771 glEnd(); 772 glBegin(GL_POLYGON); 773 PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount); 774 this->currentGroup->faceMode = tmpFace->vertexCount; 775 } 776 777 ModelFaceElement* tmpElem = tmpFace->firstElem; 778 while (tmpElem != NULL) 779 { 780 // PRINTF(2)("%s\n", tmpElem->value); 781 this->addGLElement(tmpElem); 782 tmpElem = tmpElem->next; 783 } 784 tmpFace = tmpFace->next; 790 785 } 786 glEnd(); 787 glEndList(); 788 789 this->currentGroup = this->currentGroup->next; 790 } 791 791 } 792 792 … … 807 807 ModelFace* tmpFace; //!< the temporary face referece 808 808 809 bool warned = false; 810 809 811 /* count the number of triangles */ 810 812 /* now iterate through all groups and build up the triangle list */ … … 827 829 else if( tmpFace->vertexCount > 4) 828 830 { 829 PRINTF(1)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getName()); 830 //exit(0); 831 if (!warned) 832 { 833 PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getName()); 834 warned = true; 835 } 836 //exit(0); 831 837 } 832 838 tmpFace = tmpFace->next; … … 851 857 while( this->currentGroup != NULL) 852 858 { 853 859 // Putting Faces to GL 854 860 tmpFace = this->currentGroup->firstFace; 855 861 while( tmpFace != NULL) … … 924 930 925 931 if (elem->texCoordNumber != -1) 926 927 928 929 930 931 932 932 { 933 if (likely(elem->texCoordNumber < this->pModelInfo.numTexCoor)) 934 glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2); 935 else 936 PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n", 937 elem->texCoordNumber, this->pModelInfo.numTexCoor); 938 } 933 939 if (elem->normalNumber != -1) 934 940 { 935 941 if (likely(elem->normalNumber < this->pModelInfo.numNormals)) 936 942 glNormal3fv(&this->normals[0] + elem->normalNumber * 3); 937 943 else 938 939 940 944 PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete", 945 elem->normalNumber, this->pModelInfo.numNormals); 946 } 941 947 if (elem->vertexNumber != -1) 942 943 944 945 946 947 948 948 { 949 if (likely(elem->vertexNumber < this->pModelInfo.numVertices)) 950 glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3); 951 else 952 PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete", 953 elem->vertexNumber, this->pModelInfo.numVertices); 954 } 949 955 950 956 } -
branches/std/src/lib/util/executor/executor.h
r7203 r7210 271 271 { 272 272 SubString sub(((const std::string*) parameters)->c_str(), " \n\t,", '\\'); 273 printf("%s :: %s\n", this->getName(), ((const std::string*) parameters)->c_str());274 273 //! FUNCTOR_LIST is the List of Executive Functions 275 274 #define FUNCTOR_LIST(x) ExecutorExecute ## x -
branches/std/src/lib/util/loading/factory.cc
r7209 r7210 178 178 else 179 179 { 180 PRINTF(2)("Could not Fabricate an Object of ClassID ' %h'\n", classID);180 PRINTF(2)("Could not Fabricate an Object of ClassID '0x%h'\n", classID); 181 181 return NULL; 182 182 } -
branches/std/src/lib/util/loading/factory.h
r7209 r7210 27 27 #include "parser/tinyxml/tinyxml.h" 28 28 #include "base_object.h" 29 #include "debug.h"30 29 #include <vector> 31 30 #include <list> … … 34 33 * Creates a factory to a Loadable Class. 35 34 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 36 */35 */ 37 36 #define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \ 38 37 tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID) … … 69 68 70 69 /** 71 * a factory that is able to load any kind of Object70 * @brief a factory that is able to load any kind of Object 72 71 * (this is a Functor) 73 72 */ … … 76 75 public: 77 76 /** 78 * creates a new type Factory to enable the loading of T77 * @brief creates a new type Factory to enable the loading of T 79 78 * @param factoryName the Name of the Factory to load. 80 79 * @param classID the ID of the Class to be created. … … 86 85 private: 87 86 /** 88 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)87 * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*) 89 88 * @param root the TiXmlElement T should load parameters from. 90 89 * @return the newly fabricated T. -
branches/std/src/lib/util/loading/resource_manager.cc
r7208 r7210 325 325 { 326 326 327 printf("LOADING:::::: %s\n", fileName.c_str());328 327 // searching if the resource was loaded before. 329 328 Resource* tmpResource;
Note: See TracChangeset
for help on using the changeset viewer.