Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2935 in orxonox.OLD for orxonox/trunk/src


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

orxonox/trunk/src: merged importer into src again

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

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

    r2866 r2935  
    297297    }
    298298  objFileName = fileName;
    299   char Buffer[500];
     299  char Buffer[10000];
    300300  while(!OBJ_FILE->eof())
    301301    {
    302       OBJ_FILE->getline(Buffer, 500);
     302      OBJ_FILE->getline(Buffer, 10000);
    303303      if (verbose >=4)
    304304        printf ("Read input line: %s\n",Buffer);
     
    379379    {
    380380      currentGroup->vertices->finalizeArray();
    381       glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
     381      //      glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
    382382      currentGroup->normals->finalizeArray();
    383       glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
     383      //      glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
    384384      currentGroup->vTexture->finalizeArray();
    385385    }
     
    387387  readingVertices = false;
    388388  currentGroup->faceCount++;
    389   char subbuffer1[20];
    390   char subbuffer2[20];
    391   char subbuffer3[20];
    392   char subbuffer4[20] ="";
    393   sscanf (faceString, "%s %s %s %s", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    394   if (!strcmp(subbuffer4, ""))
     389
     390  int elemCount = 0;
     391 
     392  FaceElement* firstElem = new FaceElement;
     393  FaceElement* tmpElem = firstElem;
     394
     395 
     396  while(strcmp (faceString, "\0"))
     397    {
     398      if (elemCount>0)
     399          tmpElem = tmpElem->next = new FaceElement;
     400      tmpElem->next = NULL;
     401
     402
     403      sscanf (faceString, "%s", tmpElem->value);
     404      faceString += strlen(tmpElem->value);
     405      if (strcmp (faceString, "\0"))
     406        faceString++;
     407      elemCount++;
     408
     409
     410    }
     411 
     412 
     413  if (elemCount == 3)
    395414    {
    396415      if (currentGroup->faceMode != 3)
     
    403422      currentGroup->faceMode = 3;
    404423      if (verbose >=3)
    405         printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3);
    406       addGLElement(subbuffer1);
    407       addGLElement(subbuffer2);
    408       addGLElement(subbuffer3);
    409       return true;
    410     }
    411   else
     424        printf ("found triag.\n");
     425    }
     426 
     427  else if (elemCount == 4)
    412428    {
    413429      if (currentGroup->faceMode != 4)
     
    419435      currentGroup->faceMode = 4;
    420436      if (verbose >=3 )
    421         printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
    422       addGLElement(subbuffer1);
    423       addGLElement(subbuffer2);
    424       addGLElement(subbuffer3);
    425       addGLElement(subbuffer4);
    426       return true;
    427     }
     437        printf ("found quad.\n");
     438    }
     439 
     440  else if (elemCount > 4)
     441    {
     442      if (currentGroup->faceMode != -1)
     443        glEnd();
     444      glBegin(GL_POLYGON);
     445      if (verbose >=3)
     446        printf ("Polygon with %i faces found.", elemCount);
     447      currentGroup->faceMode = elemCount;
     448    }
     449
     450  tmpElem = firstElem;
     451  while (tmpElem != NULL)
     452    {
     453      //      printf ("%s\n", tmpElem->value);
     454      addGLElement(tmpElem->value);
     455      tmpElem = tmpElem->next;
     456    }
     457
    428458}
    429459
     
    444474
    445475  char* texture;
    446   texture = strstr (vertex, "/");
    447   texture[0] = '\0';
    448   texture ++;
    449   if (verbose>=3)
    450     printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount());
    451   glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
    452 
    453   char* normal;
    454   if ((normal = strstr (texture, "/")) !=NULL)
    455     {
    456       normal[0] = '\0';
    457       normal ++;
    458       //glArrayElement(atoi(vertex)-1);
    459       glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
     476  if ((texture = strstr (vertex, "/")) != NULL)
     477    {
     478      texture[0] = '\0';
     479      texture ++;
     480      if (verbose>=3)
     481        printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount());
     482      glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
     483
     484      char* normal;
     485      if ((normal = strstr (texture, "/")) !=NULL)
     486        {
     487          normal[0] = '\0';
     488          normal ++;
     489          //glArrayElement(atoi(vertex)-1);
     490          glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
     491        }
    460492    }
    461493  if (verbose>=3)
  • orxonox/trunk/src/object.h

    r2866 r2935  
    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.