Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 6, 2005, 12:50:31 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: some comments, started implementing the Model::buildTriangleList() function, Array::getIndex now makes a value not reference comparison

File:
1 edited

Legend:

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

    r4791 r4793  
    1212   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
     14
     15   2005-07-06: (Patrick) added new function buildTriangleList()
    1416*/
    1517
     
    817819bool Model::buildTriangleList()
    818820{
    819 
     821  /* make sure, that all the arrays are finalized */
     822  this->vertices->finalizeArray();
     823  this->vTexture->finalizeArray();
     824  if( normals->getCount() == 0) // vertices-Array must be built for this
     825    this->buildVertexNormals();
     826  this->normals->finalizeArray();
     827
     828  if( unlikely((this->triangles = new sTriangle[this->vertices->getCount()]) == 0));
     829  {
     830    PRINTF(2)("Could not allocate memory for triangle list\n");
     831    return false;
     832  }
     833
     834  int i = 0;                       //!< the counter for the triangle array
     835  ModelFaceElement* tmpElem;       //!< the temporary face element
     836
     837  /* now iterate through all groups and build up the triangle list */
     838  this->currentGroup = this->firstGroup;
     839  while( this->currentGroup != NULL)
     840  {
     841      // Putting Faces to GL
     842    ModelFace* tmpFace = this->currentGroup->firstFace;
     843    while (tmpFace != NULL)
     844    {
     845      tmpElem = tmpFace->firstElem;
     846
     847      /* if its a triangle just add it to the list */
     848      if (tmpFace->vertexCount == 3)
     849      {
     850        for(int j = 0; j < 3; ++j)
     851        {
     852          //this->triangles[i].indexToVertices[j] = this->vertices->getIndex(tmpElem);
     853          tmpElem = tmpElem->next;
     854        }
     855      }
     856
     857      ModelFaceElement* tmpElem = tmpFace->firstElem;
     858      while (tmpElem != NULL)
     859      {
     860              //      PRINTF(2)("%s\n", tmpElem->value);
     861        this->addGLElement(tmpElem);
     862        tmpElem = tmpElem->next;
     863      }
     864      tmpFace = tmpFace->next;
     865    }
     866    glEnd();
     867    glEndList();
     868
     869    this->currentGroup = this->currentGroup->next;
     870  }
    820871}
    821872
Note: See TracChangeset for help on using the changeset viewer.