Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4106 in orxonox.OLD


Ignore:
Timestamp:
May 7, 2005, 4:26:35 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new Model Definitions, to make it more safe (better output)

Location:
orxonox/trunk/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r4038 r4106  
    140140  this->currentGroup = this->firstGroup = new ModelGroup;
    141141  this->groupCount = 0;
     142  this->vertexCount = 0;
     143  this->normalCount = 0;
     144  this->texCoordCount = 0;
    142145 
    143146  this->scaleFactor = 1;
     
    355358Material* Model::addMaterial(const char* materialName)
    356359{
    357  
    358360  Material* newMat = new Material();
    359361  newMat->setName(materialName);
     
    424426  PRINTF(5)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3);
    425427  this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor);
     428  this->vertexCount++;
    426429  return true;
    427430}
     
    438441  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
    439442  this->vertices->addEntry(x*scaleFactor, y*scaleFactor, z*scaleFactor);
     443  this->vertexCount++;
    440444  return true;
    441445}
     
    455459  PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
    456460  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
     461  this->normalCount++;
    457462  return true;
    458463}
     
    470475  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
    471476  this->normals->addEntry(x, y, z);
     477  this->normalCount++;
     478  return true;
    472479}
    473480
     
    487494  this->vTexture->addEntry(subbuffer1);
    488495  this->vTexture->addEntry(subbuffer2);
     496  this->texCoordCount++;
    489497  return true;
    490498}
     
    502510  this->vTexture->addEntry(u);
    503511  this->vTexture->addEntry(v);
     512  this->texCoordCount++;
     513  return true;
    504514}
    505515
     
    583593  for (int i = 0; i < faceElemCount; i++)
    584594    {
    585       if (this->currentGroup->currentFace->vertexCount>0)
     595      if (this->currentGroup->currentFace->vertexCount > 0)
    586596        tmpElem = tmpElem->next = new ModelFaceElement;
    587597
     
    592602        tmpElem->normalNumber = va_arg(itemlist, int) -1;
    593603      this->currentGroup->currentFace->vertexCount++;
     604
     605      if (unlikely(tmpElem->vertexNumber > this->vertexCount))
     606        PRINTF(1)("VERTEX %d IS NOT IN THE LIST -> DANGER OF SEGFAULT (max is: %d)\n", tmpElem->vertexNumber, this->vertexCount);
     607      if (unlikely(tmpElem->normalNumber > this->normalCount))
     608        PRINTF(1)("VERTEX %d IS NOT IN THE LIST -> DANGER OF SEGFAULT (max is: %d)\n", tmpElem->normalNumber, this->normalCount);
     609      if (unlikely(tmpElem->texCoordNumber > this->texCoordCount))
     610        PRINTF(1)("VERTEX %d IS NOT IN THE LIST -> DANGER OF SEGFAULT (max is: %d)\n", tmpElem->texCoordNumber, this->texCoordCount);
    594611    }
    595612  va_end(itemlist);
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r4038 r4106  
    9999  bool finalized;             //!< Sets the Object to be finalized.
    100100
     101  int vertexCount;            //!< A modelwide Counter for vertices.
     102  int normalCount;            //!< A modelwide Counter for the normals.
     103  int texCoordCount;          //!< A modelwide Counter for the texCoord.
    101104  Array* vertices;            //!< The Array that handles the Vertices.
    102   int verticesCount;          //!< A global Counter for vertices.
    103105  Array* normals;             //!< The Array that handles the Normals.
    104106  Array* vTexture;            //!< The Array that handles the VertexTextureCoordinates.
     
    158160  bool setMaterial(Material* mtl);
    159161  void finalize(void);
     162
     163  /** \returns The number of Vertices of the Model */
     164  inline int getVertexCount(void) const {return this->vertexCount;}
     165  /** \returns The number of Normals of the Model */
     166  inline int getNormalCount(void) const {return this->normalCount;}
     167  /** \returns The number of Texture Coordinates of the Model*/
     168  inline int getTexCoordCount(void) const {return this->texCoordCount;}
    160169};
    161170
Note: See TracChangeset for help on using the changeset viewer.