Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3207 in orxonox.OLD


Ignore:
Timestamp:
Dec 17, 2004, 9:44:10 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: object.cc in new look (with PRINTF())

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/importer/object.cc

    r3206 r3207  
    9090  if (this->mtlFileName)
    9191    delete []this->mtlFileName;
    92 
    9392  PRINTF(2)("Deleting Materials.\n");
    9493  if (this->material)
     
    103102void Object::draw (void) const
    104103{
    105   if (verbose >=2)
    106     printf("drawing the 3D-Objects\n");
     104  PRINTF(2)("drawing the 3D-Objects\n");
    107105  Group* walker = this->firstGroup;
    108106  while (walker != NULL)
    109107    {
    110       if (verbose >= 3)
    111         printf ("Drawing object %s\n", walker->name);
     108      PRINTF(3)("Drawing object %s\n", walker->name);
    112109      glCallList (walker->listNumber);
    113110      walker = walker->next;
     
    125122  if (groupNumber >= this->groupCount)
    126123    {
    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);
    129125      return;
    130126    }
    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");
    133128  Group* walker = this->firstGroup;
    134129  int counter = 0;
     
    137132      if (counter == groupNumber)
    138133        {
    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);
    141135          glCallList (walker->listNumber);
    142136          return;
     
    145139      walker = walker->next;
    146140    }
    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);
    149142  return;
    150143
     
    159152void Object::draw (char* groupName) const
    160153{
    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");
    163155  Group* walker = this->firstGroup;
    164156  while (walker != NULL)
     
    166158      if (!strcmp(walker->name, groupName))
    167159        {
    168           if (verbose >= 2)
    169             printf ("Drawing object %s\n", walker->name);
     160          PRINTF(2)("Drawing object %s\n", walker->name);
    170161          glCallList (walker->listNumber);
    171162          return;
     
    173164      walker = walker->next;
    174165    }
    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);
    177167  return;
    178168}
     
    194184bool Object::initialize (void)
    195185{
    196   if (verbose >=3)
    197     printf("new 3D-Object is being created\n");
     186  PRINTF(2)("new 3D-Object is being created\n");
    198187
    199188  // setting the start group;
     
    224213bool Object::initGroup(Group* group)
    225214{
    226   if (verbose >= 2)
    227     printf("Adding new Group\n");
     215  PRINTF(3)("Adding new Group\n");
    228216  group->name = "";
    229217  group->faceMode = -1;
     
    259247bool Object::cleanup(void)
    260248{
    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");
    263250
    264251  if (this->vertices)
     
    279266bool Object::cleanupGroup (Group* group)
    280267{
    281   if (verbose>=4)
    282     printf ("Cleaning up group\n");
     268  PRINTF(3)("Cleaning up group\n");
    283269  if (group->firstFace != NULL)
    284270    {
     
    298284bool Object::cleanupFace (Face* face)
    299285{
    300   if (verbose>=4)
    301     printf ("Cleaning up Face\n");
     286  PRINTF(3)("Cleaning up Face\n");
    302287
    303288  if (face->materialString != NULL)
     
    337322bool Object::importFile (char* fileName)
    338323{
    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);
    341325
    342326
     
    361345  if (verbose >=2)
    362346    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);
    366348    else
    367       printf("Resolved file %s.\n", name);
     349      PRINTF(0)("Resolved file %s.\n", name);
    368350 
    369351  if (this->material)
     
    390372  if (OBJ_FILE->fail())
    391373    {
    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);
    394375      BoxObject();
    395376      OBJ_FILE->close();
     
    398379      return false;
    399380    }
    400   if (verbose >=2)
    401     printf ("Reading from opened file %s\n", fileName);
     381  PRINTF(2)("Reading from opened file %s\n", fileName);
    402382  char Buffer[10000];
    403383  while(!OBJ_FILE->eof())
    404384    {
    405385      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);
    408387     
    409388
     
    449428        {
    450429          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);
    452431        }
    453432    }
     
    468447bool Object::readGroup (char* groupString)
    469448{
    470   if (verbose >=3)
    471     printf ("Read Group: %s.\n", groupString);
     449  PRINTF(3)("Read Group: %s.\n", groupString);
    472450  if (this->groupCount != 0 && this->currentGroup->faceCount>0)
    473451    {
     
    498476  float subbuffer3;
    499477  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);
    502479  this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor);
    503480  return true;
     
    580557  float subbuffer3;
    581558  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);
    584560  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
    585561  return true;
     
    598574  float subbuffer2;
    599575  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);
    602577  this->vTexture->addEntry(subbuffer1);
    603578  this->vTexture->addEntry(subbuffer2);
     
    623598 
    624599
    625   if (verbose >=2)
    626     printf ("Opening mtlFile: %s\n", fileName);
     600  PRINTF(2)("Opening mtlFile: %s\n", fileName);
    627601
    628602  ifstream* MTL_FILE = new ifstream (fileName);
     
    630604    {
    631605      if (verbose >= 1)
    632         printf ("unable to open file: %s\n", fileName);
     606        PRINTF(2)("unable to open file: %s\n", fileName);
    633607      MTL_FILE->close();
    634608      delete []fileName;
     
    641615    {
    642616      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);
    645618     
    646619
     
    649622        {
    650623          tmpMat = tmpMat->addMaterial(Buffer+7);
    651           //      printf ("%s, %p\n", tmpMat->getName(), tmpMat);
     624          //      PRINTF(2)("%s, %p\n", tmpMat->getName(), tmpMat);
    652625        }
    653626      // setting a illumMode
     
    720693  if (!this->mtlFileName)
    721694    {
    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");
    724696      return false;
    725697    }
     
    758730      if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
    759731        {
    760           printf ("list could not be created for this Object\n");
     732          PRINTF(1)("list could not be created for this Object\n");
    761733          return false;
    762734        }
     
    772744                glEnd();
    773745              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);
    776747              Material* tmpMat;
    777748              if ((tmpMat = material->search(tmpFace->materialString)) != NULL)
     
    790761             
    791762              this->currentGroup->faceMode = 3;
    792               if (verbose >=3)
    793                 printf ("found triag.\n");
     763              PRINTF(3)("found triag.\n");
    794764            }
    795765         
     
    803773                }
    804774              this->currentGroup->faceMode = 4;
    805               if (verbose >=3 )
    806                 printf ("found quad.\n");
     775              PRINTF(3)("found quad.\n");
    807776            }
    808777         
     
    812781                glEnd();
    813782              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);
    816784              this->currentGroup->faceMode = tmpFace->vertexCount;
    817785            }
     
    820788          while (tmpElem != NULL)
    821789            {
    822               //      printf ("%s\n", tmpElem->value);
     790              //      PRINTF(2)("%s\n", tmpElem->value);
    823791              this->addGLElement(tmpElem);
    824792              tmpElem = tmpElem->next;
     
    845813bool Object::addGLElement (FaceElement* elem)
    846814{
    847   if (verbose >=3)
    848     printf ("importing grafical Element to openGL.\n");
     815  PRINTF(3)("importing grafical Element to openGL.\n");
    849816
    850817  if (elem->texCoordNumber != -1)
     
    869836{
    870837 
    871   if (verbose >=2)
    872     printf("Normals are being calculated.\n");
     838  PRINTF(2)("Normals are being calculated.\n");
    873839
    874840  Vector* normArray = new Vector [vertices->getCount()/3];
     
    927893    {
    928894      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);
    931896
    932897      this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);
Note: See TracChangeset for help on using the changeset viewer.