Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3115 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Dec 6, 2004, 1:03:07 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/images: ability to read-in from a folder of your desire

Location:
orxonox/branches/images/importer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/images/importer/array.cc

    r3064 r3115  
    3333    printf("deleting array\n");
    3434  Entry* walker = firstEntry;
    35   Entry* last;
    36   while (walker != NULL)
     35  Entry* previous;
     36  while (walker)
    3737    {
    38       last = walker;
     38      previous = walker;
    3939      walker = walker->next;
    40       delete last;
     40      delete previous;
    4141    }
    4242  if (finalized)
    43     delete [] array;
     43    delete []array;
    4444}
    4545
  • orxonox/branches/images/importer/framework.cc

    r3070 r3115  
    11#include "framework.h"
    22
    3 int verbose = 1;
     3int verbose = 2;
    44
    55void DrawGLScene()
  • orxonox/branches/images/importer/material.cc

    r3110 r3115  
    4848Material::~Material()
    4949{
     50  if (verbose >= 2)
     51    printf ("delete Material %s.\n", name);
    5052  if (name)
    5153    delete []name;
    5254  if (diffuseTextureSet)
    5355    glDeleteTextures (1, &diffuseTexture);
    54   if (verbose >= 2)
    55     printf ("delete Material %s.\n", name);
    56   if (nextMat != NULL)
     56  if (nextMat)
    5757    delete nextMat;
    5858}
  • orxonox/branches/images/importer/object.cc

    r3093 r3115  
    1717
    1818#include "object.h"
     19using namespace std;
    1920
    2021/**
     
    8283    }
    8384
     85  if (objPath)
     86    delete []objPath;
     87  if (objFileName)
     88    delete []objFileName;
     89  if (mtlFileName)
     90    delete []mtlFileName;
     91
    8492  if (verbose >=2)
    8593    printf("Deleting Materials.\n");
    86   if (material != NULL)
     94  if (material)
    8795    delete material;
    88 
    8996}
    9097
     
    192199 
    193200  initGroup (firstGroup);
    194   mtlFileName = "";
     201  objPath = NULL;
     202  objFileName = NULL;
     203  mtlFileName = NULL;
    195204  scaleFactor = 1;
    196205  material = new Material();
     
    321330{
    322331  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 ();
    326363  return true;
    327364}
     
    330367   \brief Reads in the .obj File and sets all the Values.
    331368   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*/
     370bool 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())
    338382    {
    339383      if (verbose >=1)
    340384        printf ("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName);
     385      exit(0);
    341386      BoxObject();
    342387      return false;
    343388    }
    344   objFileName = fileName;
     389  if (verbose >=2)
     390    printf ("Reading from opened file %s\n", fileName);
    345391  char Buffer[10000];
    346392  while(!OBJ_FILE->eof())
     
    546592bool Object::readMtlLib (char* mtlFile)
    547593{
    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())
    550607    {
    551608      if (verbose >= 1)
    552         printf ("unable to open file: %s\n", mtlFile);
     609        printf ("unable to open file: %s\n", fileName);
    553610      return false;
    554611    }
    555   mtlFileName = mtlFile;
    556   if (verbose >=2)
    557     printf ("Opening mtlFile: %s\n", mtlFileName);
    558612  char Buffer[500];
    559613  Material* tmpMat = material;
  • orxonox/branches/images/importer/object.h

    r3075 r3115  
    8787  char* objFileName;
    8888  char* mtlFileName;
    89   ifstream* OBJ_FILE;
    90   ifstream* MTL_FILE;
    9189
    9290  bool initialize (void);
     
    10098  ///// readin ///
    10199  bool importFile (char* fileName);
    102   bool readFromObjFile (char* fileName);
     100  bool readFromObjFile (void);
    103101 
    104102  bool readGroup (char* groupString);
Note: See TracChangeset for help on using the changeset viewer.