Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4798 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Jul 6, 2005, 2:22:11 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some more stability in triangle count calculation

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

Legend:

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

    r4797 r4798  
    148148  this->texCoordCount = 0;
    149149  this->faceCount = 0;
     150  this->triangleCount = 0;
     151  this->triangles = NULL;
    150152
    151153  this->scaleFactor = 1;
     
    303305  if (this->normals)
    304306    delete this->normals;
     307  if (this->triangles)
     308    delete this->triangles;
    305309
    306310  this->vertices = NULL;
    307311  this->vTexture = NULL;
    308312  this->normals = NULL;
     313  this->triangles = NULL; this->triangleCount = 0;
    309314}
    310315
     
    819824bool Model::buildTriangleList()
    820825{
     826  if( unlikely(this->triangles != NULL))
     827    return true;
    821828  /* make sure, that all the arrays are finalized */
    822829  if( unlikely(!this->vertices->isFinalized()))
     
    836843  /* count the number of triangles */
    837844  /* now iterate through all groups and build up the triangle list */
     845  this->triangleCount = 0;
    838846  this->currentGroup = this->firstGroup;
    839847  while( this->currentGroup != NULL)
    840848  {
    841       // Putting Faces to GL
    842849    tmpFace = this->currentGroup->firstFace;
    843850    while( tmpFace != NULL)
    844851    {
    845       tmpElem = tmpFace->firstElem;
    846852
    847853      /* if its a triangle just add it to the list */
     
    854860        this->triangleCount += 2;
    855861      }
     862      else if( tmpFace->vertexCount > 4)
     863      {
     864        PRINTF(0)("NASTY NASTY: More than 4 vertices for a face, there will be errors in the triangles information!\n");
     865      //exit(0);
     866      }
     867      tmpFace = tmpFace->next;
    856868    }
    857869    this->currentGroup = this->currentGroup->next;
    858870  }
    859871
    860   PRINTF(0)("***************************************GOT %i triangles\n", this->triangleCount);
     872  PRINTF(0)("***************************************GOT %i triangles, %i vertices\n", this->triangleCount, this->vertexCount);
     873
    861874
    862875  /* allocate memory for the new triangle structures */
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r4796 r4798  
    175175  unsigned int     texCoordCount;   //!< A modelwide Counter for the texCoord.
    176176  unsigned int     faceCount;       //!< A modelwide Counter for the faces
    177   unsigned int     triangleCount;   //!< Number of triangles <= faceCount
     177  unsigned int     triangleCount;   //!< Number of triangles >= faceCount
    178178  Array<GLfloat>*  vertices;        //!< The Array that handles the Vertices.
    179179  Array<GLfloat>*  normals;         //!< The Array that handles the Normals.
Note: See TracChangeset for help on using the changeset viewer.