Changeset 3115 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 6, 2004, 1:03:07 PM (20 years ago)
- Location:
- orxonox/branches/images/importer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/images/importer/array.cc
r3064 r3115 33 33 printf("deleting array\n"); 34 34 Entry* walker = firstEntry; 35 Entry* last;36 while (walker != NULL)35 Entry* previous; 36 while (walker) 37 37 { 38 last= walker;38 previous = walker; 39 39 walker = walker->next; 40 delete last;40 delete previous; 41 41 } 42 42 if (finalized) 43 delete [] 43 delete []array; 44 44 } 45 45 -
orxonox/branches/images/importer/framework.cc
r3070 r3115 1 1 #include "framework.h" 2 2 3 int verbose = 1;3 int verbose = 2; 4 4 5 5 void DrawGLScene() -
orxonox/branches/images/importer/material.cc
r3110 r3115 48 48 Material::~Material() 49 49 { 50 if (verbose >= 2) 51 printf ("delete Material %s.\n", name); 50 52 if (name) 51 53 delete []name; 52 54 if (diffuseTextureSet) 53 55 glDeleteTextures (1, &diffuseTexture); 54 if (verbose >= 2) 55 printf ("delete Material %s.\n", name); 56 if (nextMat != NULL) 56 if (nextMat) 57 57 delete nextMat; 58 58 } -
orxonox/branches/images/importer/object.cc
r3093 r3115 17 17 18 18 #include "object.h" 19 using namespace std; 19 20 20 21 /** … … 82 83 } 83 84 85 if (objPath) 86 delete []objPath; 87 if (objFileName) 88 delete []objFileName; 89 if (mtlFileName) 90 delete []mtlFileName; 91 84 92 if (verbose >=2) 85 93 printf("Deleting Materials.\n"); 86 if (material != NULL)94 if (material) 87 95 delete material; 88 89 96 } 90 97 … … 192 199 193 200 initGroup (firstGroup); 194 mtlFileName = ""; 201 objPath = NULL; 202 objFileName = NULL; 203 mtlFileName = NULL; 195 204 scaleFactor = 1; 196 205 material = new Material(); … … 321 330 { 322 331 if (verbose >=3) 323 printf("preparing to read in file: %s\n", fileName); 324 objFileName = fileName; 325 this->readFromObjFile (fileName); 332 printf("preparing to read in file: %s\n", fileName); 333 334 335 #ifdef __WIN32__ 336 // win32 path reading 337 char pathSplitter= '\\'; 338 #else /* __WIN32__ */ 339 // unix path reading 340 char pathSplitter='/'; 341 #endif /* __WIN32__ */ 342 char* tmpName = fileName; 343 if (tmpName[0] == pathSplitter) 344 tmpName++; 345 char* name = tmpName; 346 while (( tmpName = strchr (tmpName+1, pathSplitter))) 347 { 348 name = tmpName+1; 349 } 350 objPath = new char[name-fileName]; 351 strncpy(objPath, fileName, name-fileName); 352 objPath[name-fileName] = '\0'; 353 if (verbose >=2) 354 if (strlen(objPath)> 0) 355 printf("Resolved file %s to folder: %s.\n", name, objPath); 356 else 357 printf("Resolved file %s.\n", name); 358 359 objFileName = new char[strlen(name)+1]; 360 strcpy (objFileName, name); 361 objFileName[strlen(name)] = '\0'; 362 this->readFromObjFile (); 326 363 return true; 327 364 } … … 330 367 \brief Reads in the .obj File and sets all the Values. 331 368 This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks 332 \param fileName the File that will be parsed (.obj-file) 333 */ 334 bool Object::readFromObjFile (char* fileName) 335 { 336 OBJ_FILE = new ifstream(fileName); 337 if (!OBJ_FILE->is_open()) 369 */ 370 bool Object::readFromObjFile (void) 371 { 372 char* fileName = new char [strlen(objPath)+strlen(objFileName)+2]; 373 fileName[0]='\0'; 374 if (objFileName != NULL && !strcmp(objFileName, "")) 375 return false; 376 strcat(fileName, objPath); 377 strcat(fileName, objFileName); 378 printf ("%s. %d\n", fileName, strlen(fileName)); 379 380 ifstream* OBJ_FILE = new ifstream(fileName); 381 if (OBJ_FILE->fail()) 338 382 { 339 383 if (verbose >=1) 340 384 printf ("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName); 385 exit(0); 341 386 BoxObject(); 342 387 return false; 343 388 } 344 objFileName = fileName; 389 if (verbose >=2) 390 printf ("Reading from opened file %s\n", fileName); 345 391 char Buffer[10000]; 346 392 while(!OBJ_FILE->eof()) … … 546 592 bool Object::readMtlLib (char* mtlFile) 547 593 { 548 MTL_FILE = new ifstream (mtlFile); 549 if (!MTL_FILE->is_open()) 594 mtlFileName = new char [strlen(mtlFile)+1]; 595 strcpy(mtlFileName, mtlFile); 596 char* fileName = new char [strlen(objPath) + strlen(mtlFileName)]; 597 fileName[0] = '\0'; 598 strcat(fileName, objPath); 599 strcat(fileName, mtlFileName); 600 601 602 if (verbose >=2) 603 printf ("Opening mtlFile: %s\n", fileName); 604 605 ifstream* MTL_FILE = new ifstream (fileName); 606 if (MTL_FILE->fail()) 550 607 { 551 608 if (verbose >= 1) 552 printf ("unable to open file: %s\n", mtlFile);609 printf ("unable to open file: %s\n", fileName); 553 610 return false; 554 611 } 555 mtlFileName = mtlFile;556 if (verbose >=2)557 printf ("Opening mtlFile: %s\n", mtlFileName);558 612 char Buffer[500]; 559 613 Material* tmpMat = material; -
orxonox/branches/images/importer/object.h
r3075 r3115 87 87 char* objFileName; 88 88 char* mtlFileName; 89 ifstream* OBJ_FILE;90 ifstream* MTL_FILE;91 89 92 90 bool initialize (void); … … 100 98 ///// readin /// 101 99 bool importFile (char* fileName); 102 bool readFromObjFile ( char* fileName);100 bool readFromObjFile (void); 103 101 104 102 bool readGroup (char* groupString);
Note: See TracChangeset
for help on using the changeset viewer.