Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2934 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Nov 21, 2004, 3:21:20 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: reimplemented bool Object::readFace (char* faceString), now it is able also to import polygons.

Location:
orxonox/trunk/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/importer/object.cc

    r2932 r2934  
    377377    {
    378378      currentGroup->vertices->finalizeArray();
    379       glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
     379      //      glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
    380380      currentGroup->normals->finalizeArray();
    381       glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
     381      //      glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
    382382      currentGroup->vTexture->finalizeArray();
    383383    }
     
    385385  readingVertices = false;
    386386  currentGroup->faceCount++;
    387   char subbuffer1[20];
    388   char subbuffer2[20];
    389   char subbuffer3[20];
    390   char subbuffer4[20] ="";
    391   sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    392   if (!strcmp(subbuffer4, ""))
     387
     388  int elemCount = 0;
     389 
     390  FaceElement* firstElem = new FaceElement;
     391  FaceElement* tmpElem = firstElem;
     392
     393 
     394  while(strcmp (faceString, "\0"))
     395    {
     396      if (elemCount>0)
     397          tmpElem = tmpElem->next = new FaceElement;
     398      tmpElem->next = NULL;
     399
     400
     401      sscanf (faceString, "%s", tmpElem->value);
     402      faceString += strlen(tmpElem->value);
     403      if (strcmp (faceString, "\0"))
     404        faceString++;
     405      elemCount++;
     406
     407
     408    }
     409 
     410 
     411  if (elemCount == 3)
    393412    {
    394413      if (currentGroup->faceMode != 3)
     
    401420      currentGroup->faceMode = 3;
    402421      if (verbose >=3)
    403         printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3);
    404       addGLElement(subbuffer1);
    405       addGLElement(subbuffer2);
    406       addGLElement(subbuffer3);
    407       return true;
    408     }
    409   else
     422        printf ("found triag.\n");
     423    }
     424 
     425  else if (elemCount == 4)
    410426    {
    411427      if (currentGroup->faceMode != 4)
     
    417433      currentGroup->faceMode = 4;
    418434      if (verbose >=3 )
    419         printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    420       addGLElement(subbuffer1);
    421       addGLElement(subbuffer2);
    422       addGLElement(subbuffer3);
    423       addGLElement(subbuffer4);
    424       return true;
    425     }
     435        printf ("found quad.\n");
     436    }
     437 
     438  else if (elemCount > 4)
     439    {
     440      if (currentGroup->faceMode != -1)
     441        glEnd();
     442      glBegin(GL_POLYGON);
     443      if (verbose >=3)
     444        printf ("Polygon with %i faces found.", elemCount);
     445      currentGroup->faceMode = elemCount;
     446    }
     447
     448  tmpElem = firstElem;
     449  while (tmpElem != NULL)
     450    {
     451      //      printf ("%s\n", tmpElem->value);
     452      addGLElement(tmpElem->value);
     453      tmpElem = tmpElem->next;
     454    }
     455
    426456}
    427457
  • orxonox/trunk/importer/object.h

    r2863 r2934  
    1818extern int verbose; //!< fill be removed and added again as a verbose-class
    1919
     20
     21struct FaceElement
     22{
     23  char value[20];
     24  FaceElement* next;
     25};
    2026
    2127//! Class that handles 3D-Objects. it can also read them in and display them.
Note: See TracChangeset for help on using the changeset viewer.