Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7210 in orxonox.OLD


Ignore:
Timestamp:
Mar 10, 2006, 2:37:11 AM (18 years ago)
Author:
bensch
Message:

std::less warn stuff

Location:
branches/std/src/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/graphics/importer/static_model.cc

    r7203 r7210  
    225225  ModelGroup* tmpGroup = this->firstGroup;
    226226  while (tmpGroup != NULL)
    227     {
    228       PRINTF(5)("Drawing model %s\n", tmpGroup->name);
    229       glCallList (tmpGroup->listNumber);
    230       tmpGroup = tmpGroup->next;
    231     }
     227  {
     228    PRINTF(5)("Drawing model %s\n", tmpGroup->name);
     229    glCallList (tmpGroup->listNumber);
     230    tmpGroup = tmpGroup->next;
     231  }
    232232}
    233233
     
    242242{
    243243  if (unlikely(groupNumber >= this->groupCount))
    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     }
     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  }
    248248  PRINTF(4)("drawing the requested 3D-Models if found.\n");
    249249  ModelGroup* tmpGroup = this->firstGroup;
    250250  int counter = 0;
    251251  while (tmpGroup != NULL)
     252  {
     253    if (counter == groupNumber)
    252254    {
    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;
    261258    }
     259    ++counter;
     260    tmpGroup = tmpGroup->next;
     261  }
    262262  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getName());
    263263  return;
     
    276276  ModelGroup* tmpGroup = this->firstGroup;
    277277  while (tmpGroup != NULL)
     278  {
     279    if (tmpGroup->name == groupName)
    278280    {
    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;
    286284    }
    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());
    288288  return;
    289289}
     
    370370  PRINTF(5)("Read Group: %s.\n", groupString);
    371371  if (this->groupCount != 0 && this->currentGroup->faceCount > 0)
    372     {
    373       // finalizeGroup(currentGroup);
    374       this->currentGroup = this->currentGroup->next = new ModelGroup;
    375     }
     372  {
     373    // finalizeGroup(currentGroup);
     374    this->currentGroup = this->currentGroup->next = new ModelGroup;
     375  }
    376376  // setting the group name if not default.
    377377  if (groupString == "default")
    378     {
    379       this->currentGroup->name = groupString;
    380     }
     378  {
     379    this->currentGroup->name = groupString;
     380  }
    381381  ++this->groupCount;
    382382}
     
    509509  tmpElem->next = NULL;
    510510  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)
    511527    {
    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      }
    548536    }
     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  }
    549549
    550550  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
     
    568568
    569569  for (int i = 0; i < faceElemCount; i++)
    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     }
     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  }
    581581  va_end(itemlist);
    582582
     
    640640  ModelGroup* tmpGroup = firstGroup;
    641641  while (tmpGroup != NULL)
     642  {
     643    ModelFace* tmpFace = tmpGroup->firstFace;
     644    while (tmpFace != NULL)
    642645    {
    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)
    645655        {
    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;
    686658        }
    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;
    688686    }
     687    tmpGroup = tmpGroup->next;
     688  }
    689689
    690690  for (int i=0; i < this->vertices.size()/3;i++)
    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     }
     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  }
    698698  delete[] normArray;
    699699}
     
    714714
    715715  while (this->currentGroup != NULL)
     716  {
     717
     718    // creating a glList for the Group
     719    if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
    716720    {
    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)
    720737        {
    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());
    723740        }
    724       glNewList (this->currentGroup->listNumber, GL_COMPILE);
    725 
    726       // Putting Faces to GL
    727       ModelFace* tmpFace = this->currentGroup->firstFace;
    728       while (tmpFace != NULL)
     741      }
     742
     743      else if (tmpFace->vertexCount == 3)
     744      {
     745        if (this->currentGroup->faceMode != 3)
    729746        {
    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);
    785750        }
    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;
    790785    }
     786    glEnd();
     787    glEndList();
     788
     789    this->currentGroup = this->currentGroup->next;
     790  }
    791791}
    792792
     
    807807  ModelFace* tmpFace;              //!< the temporary face referece
    808808
     809  bool warned = false;
     810
    809811  /* count the number of triangles */
    810812  /* now iterate through all groups and build up the triangle list */
     
    827829      else if( tmpFace->vertexCount > 4)
    828830      {
    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);
    831837      }
    832838      tmpFace = tmpFace->next;
     
    851857  while( this->currentGroup != NULL)
    852858  {
    853       // Putting Faces to GL
     859    // Putting Faces to GL
    854860    tmpFace = this->currentGroup->firstFace;
    855861    while( tmpFace != NULL)
     
    924930
    925931  if (elem->texCoordNumber != -1)
    926     {
    927       if (likely(elem->texCoordNumber < this->pModelInfo.numTexCoor))
    928         glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2);
    929       else
    930         PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
    931                   elem->texCoordNumber, this->pModelInfo.numTexCoor);
    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  }
    933939  if (elem->normalNumber != -1)
    934     {
     940  {
    935941    if (likely(elem->normalNumber < this->pModelInfo.numNormals))
    936942      glNormal3fv(&this->normals[0] + elem->normalNumber * 3);
    937943    else
    938         PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
    939                   elem->normalNumber, this->pModelInfo.numNormals);
    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  }
    941947  if (elem->vertexNumber != -1)
    942     {
    943       if (likely(elem->vertexNumber < this->pModelInfo.numVertices))
    944           glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3);
    945       else
    946         PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
    947                   elem->vertexNumber, this->pModelInfo.numVertices);
    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  }
    949955
    950956}
  • branches/std/src/lib/util/executor/executor.h

    r7203 r7210  
    271271    {
    272272      SubString sub(((const std::string*) parameters)->c_str(), " \n\t,", '\\');
    273       printf("%s :: %s\n", this->getName(), ((const std::string*) parameters)->c_str());
    274273//! FUNCTOR_LIST is the List of Executive Functions
    275274#define FUNCTOR_LIST(x) ExecutorExecute ## x
  • branches/std/src/lib/util/loading/factory.cc

    r7209 r7210  
    178178  else
    179179  {
    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);
    181181    return NULL;
    182182  }
  • branches/std/src/lib/util/loading/factory.h

    r7209 r7210  
    2727#include "parser/tinyxml/tinyxml.h"
    2828#include "base_object.h"
    29 #include "debug.h"
    3029#include <vector>
    3130#include <list>
     
    3433 * Creates a factory to a Loadable Class.
    3534 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    36 */
     35 */
    3736#define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
    3837    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
     
    6968
    7069/**
    71  *  a factory that is able to load any kind of Object
     70 *  @brief a factory that is able to load any kind of Object
    7271 * (this is a Functor)
    7372 */
     
    7675 public:
    7776 /**
    78   * creates a new type Factory to enable the loading of T
     77  * @brief creates a new type Factory to enable the loading of T
    7978  * @param factoryName the Name of the Factory to load.
    8079  * @param classID the ID of the Class to be created.
     
    8685  private:
    8786   /**
    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*)
    8988    * @param root the TiXmlElement T should load parameters from.
    9089    * @return the newly fabricated T.
  • branches/std/src/lib/util/loading/resource_manager.cc

    r7208 r7210  
    325325{
    326326
    327   printf("LOADING:::::: %s\n", fileName.c_str());
    328327  // searching if the resource was loaded before.
    329328  Resource* tmpResource;
Note: See TracChangeset for help on using the changeset viewer.