Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4795 in orxonox.OLD


Ignore:
Timestamp:
Jul 6, 2005, 1:39:33 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: now the model handles triangles and quads

File:
1 edited

Legend:

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

    r4794 r4795  
    833833
    834834  int i = 0;                       //!< the counter for the triangle array
    835   ModelFaceElement* tmpElem;       //!< the temporary face element
     835  ModelFaceElement* tmpElem;       //!< the temporary faceelement reference
     836  ModelFace* tmpFace;              //!< the temporary face referece
    836837
    837838  /* now iterate through all groups and build up the triangle list */
     
    840841  {
    841842      // Putting Faces to GL
    842     ModelFace* tmpFace = this->currentGroup->firstFace;
    843     while (tmpFace != NULL)
     843    tmpFace = this->currentGroup->firstFace;
     844    while( tmpFace != NULL)
    844845    {
    845846      tmpElem = tmpFace->firstElem;
    846847
    847848      /* if its a triangle just add it to the list */
    848       if (tmpFace->vertexCount == 3)
     849      if( tmpFace->vertexCount == 3)
    849850      {
    850         for(int j = 0; j < 3; ++j)
     851        for( int j = 0; j < 3; ++j)
    851852        {
    852853          this->triangles[i].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber;
     
    854855          tmpElem = tmpElem->next;
    855856        }
     857        ++i;
     858      } /* if the polygon is a quad */
     859      else if( tmpFace->vertexCount == 4)
     860      {
     861
     862        this->triangles[i].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
     863        this->triangles[i].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
     864        tmpElem = tmpElem->next;
     865
     866        this->triangles[i].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
     867        this->triangles[i].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
     868        tmpElem = tmpElem->next;
     869
     870        this->triangles[i].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
     871        this->triangles[i].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
     872        ++i;
     873
     874        this->triangles[i].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
     875        this->triangles[i].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
     876        tmpElem = tmpElem->next;
     877
     878        this->triangles[i].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
     879        this->triangles[i].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
     880        tmpElem = tmpElem->next;
     881
     882        this->triangles[i].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
     883        this->triangles[i].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
     884        ++i;
    856885      }
    857 
    858       ModelFaceElement* tmpElem = tmpFace->firstElem;
    859       while (tmpElem != NULL)
    860       {
    861               //      PRINTF(2)("%s\n", tmpElem->value);
    862         this->addGLElement(tmpElem);
    863         tmpElem = tmpElem->next;
    864       }
    865       tmpFace = tmpFace->next;
    866     }
    867     glEnd();
    868     glEndList();
    869 
     886    }
    870887    this->currentGroup = this->currentGroup->next;
    871888  }
Note: See TracChangeset for help on using the changeset viewer.