Changeset 3072 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 3, 2004, 10:25:20 PM (20 years ago)
- Location:
- orxonox/trunk/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/importer/object.cc
r3071 r3072 302 302 bool Object::cleanupFaceElement(FaceElement* faceElem) 303 303 { 304 if (faceElem->value != NULL)305 if (verbose>=4)306 printf ("Cleaning up faceElement %s\n", faceElem->value);307 //delete faceElem->value;308 309 304 if (faceElem->next != NULL) 310 305 { 311 306 cleanupFaceElement (faceElem->next); 312 //delete faceElem->next;307 delete faceElem->next; 313 308 } 314 309 } … … 456 451 FaceElement* tmpElem = currentGroup->currentFace->firstElem = new FaceElement; 457 452 tmpElem->next = NULL; 458 tmpElem->value = NULL;459 453 while(strcmp (faceString, "\0")) 460 454 { … … 462 456 tmpElem = tmpElem->next = new FaceElement; 463 457 tmpElem->next = NULL; 464 tmpElem->value = NULL;465 458 466 459 char tmpValue [50]; 460 int tmpLen; 461 char* vertex = NULL; 462 char* texture = NULL; 463 char* normal = NULL; 464 467 465 sscanf (faceString, "%s", tmpValue); 468 tmpElem->value = new char [strlen(tmpValue)]; 469 strcpy (tmpElem->value, tmpValue); 470 471 faceString += strlen(tmpElem->value); 466 tmpLen = strlen(tmpValue); 467 vertex = tmpValue; 468 469 if ((texture = strstr (vertex, "/")) != NULL) 470 { 471 texture[0] = '\0'; 472 texture ++; 473 474 if ((normal = strstr (texture, "/")) !=NULL) 475 { 476 normal[0] = '\0'; 477 normal ++; 478 } 479 } 480 if (vertex) 481 tmpElem->vertexNumber = atoi(vertex); 482 else 483 tmpElem->vertexNumber = 0; 484 if (texture) 485 tmpElem->texCoordNumber = atoi(texture); 486 else 487 tmpElem->texCoordNumber = 0; 488 if (normal) 489 tmpElem->normalNumber = atoi(normal); 490 else 491 tmpElem->normalNumber = 0; 492 493 faceString += tmpLen; 472 494 if (strcmp (faceString, "\0")) 473 495 faceString++; … … 709 731 { 710 732 // printf ("%s\n", tmpElem->value); 711 addGLElement(tmpElem ->value);733 addGLElement(tmpElem); 712 734 tmpElem = tmpElem->next; 713 735 } … … 729 751 730 752 */ 731 bool Object::addGLElement ( char* elementString)753 bool Object::addGLElement (FaceElement* elem) 732 754 { 733 755 if (verbose >=3) 734 printf ("importing grafical Element to openGL: %s\n", elementString); 735 char vertex [100]; 736 strcpy (vertex, elementString); 737 738 char* texture; 739 if ((texture = strstr (vertex, "/")) != NULL) 740 { 741 texture[0] = '\0'; 742 texture ++; 743 glTexCoord2fv(vTexture->getArray()+(atoi(texture)-1)*2); 744 745 char* normal; 746 if ((normal = strstr (texture, "/")) !=NULL) 747 { 748 normal[0] = '\0'; 749 normal ++; 750 //glArrayElement(atoi(vertex)-1); 751 glNormal3fv(normals->getArray() +(atoi(normal)-1)*3); 752 } 753 } 754 glVertex3fv(vertices->getArray() +(atoi(vertex)-1)*3); 756 printf ("importing grafical Element to openGL.\n"); 757 758 if (elem->texCoordNumber) 759 glTexCoord2fv(vTexture->getArray()+(elem->texCoordNumber-1)*2); 760 if (elem->normalNumber) 761 glNormal3fv(normals->getArray() +(elem->normalNumber-1)*3); 762 if (elem->vertexNumber) 763 glVertex3fv(vertices->getArray() +(elem->vertexNumber-1)*3); 755 764 756 765 } -
orxonox/trunk/importer/object.h
r3068 r3072 37 37 struct FaceElement 38 38 { 39 char* value; 39 int vertexNumber; 40 int normalNumber; 41 int texCoordNumber; 40 42 FaceElement* next; 41 43 }; … … 108 110 109 111 bool importToGL (void); 110 bool addGLElement ( char* elementString);112 bool addGLElement (FaceElement* elem); 111 113 112 114 void BoxObject (void);
Note: See TracChangeset
for help on using the changeset viewer.