Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2977 in orxonox.OLD for orxonox/branches/osX/importer/object.cc


Ignore:
Timestamp:
Nov 24, 2004, 12:50:55 PM (21 years ago)
Author:
bensch
Message:

orxonox/branches/importer: merged back from the trunk again: command: svn merge trunk/ branches/osX -r 2887:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/osX/importer/object.cc

    r2863 r2977  
    4848   \param scaling The factor that the object will be scaled with.
    4949*/
    50 
    5150Object::Object(char* fileName, float scaling)
    5251{
     
    9089  groupCount = 0;
    9190 
    92   initGroup (currentGroup);
     91  initGroup (firstGroup);
    9392  mtlFileName = "";
    9493  scaleFactor = 1;
    9594  material = new Material();
    9695
    97   glEnableClientState (GL_VERTEX_ARRAY);
     96  //  glEnableClientState (GL_VERTEX_ARRAY);
    9897  //  glEnableClientState (GL_NORMAL_ARRAY);
    9998  //  glEnableClientState (GL_TEXTURE_COORD_ARRAY);
     
    226225  group->name = "";
    227226  group->faceMode = -1;
    228   group->faceCount =0; 
     227  group->faceCount = 0; 
    229228  if ((group->listNumber = glGenLists(1)) == 0 )
    230229    {
     
    237236      group->firstVertex = 0;
    238237      group->firstNormal = 0;
    239       group->firstNormal = 0;
     238      group->firstVertexTexture = 0;
    240239    }
    241240  else
     
    265264  glEndList();
    266265}
     266
    267267/**
    268268   \brief deletes the Arrays of the Group to save space.
     
    295295    }
    296296  objFileName = fileName;
    297   char Buffer[500];
     297  char Buffer[10000];
    298298  while(!OBJ_FILE->eof())
    299299    {
    300       OBJ_FILE->getline(Buffer, 500);
     300      OBJ_FILE->getline(Buffer, 10000);
    301301      if (verbose >=4)
    302302        printf ("Read input line: %s\n",Buffer);
     
    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  FaceElement* delElem;
     450  while (tmpElem != NULL)
     451    {
     452      //      printf ("%s\n", tmpElem->value);
     453      addGLElement(tmpElem->value);
     454      delElem = tmpElem;
     455      tmpElem = tmpElem->next;
     456      delete delElem;
     457    }
     458
    426459}
    427460
     
    442475
    443476  char* texture;
    444   texture = strstr (vertex, "/");
    445   texture[0] = '\0';
    446   texture ++;
    447   if (verbose>=3)
    448     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());
    449   glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
    450 
    451   char* normal;
    452   if ((normal = strstr (texture, "/")) !=NULL)
    453     {
    454       normal[0] = '\0';
    455       normal ++;
    456       //glArrayElement(atoi(vertex)-1);
    457       glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
     477  if ((texture = strstr (vertex, "/")) != NULL)
     478    {
     479      texture[0] = '\0';
     480      texture ++;
     481      if (verbose>=3)
     482        printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*2, currentGroup->vTexture->getCount());
     483      glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
     484
     485      char* normal;
     486      if ((normal = strstr (texture, "/")) !=NULL)
     487        {
     488          normal[0] = '\0';
     489          normal ++;
     490          //glArrayElement(atoi(vertex)-1);
     491          glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
     492        }
    458493    }
    459494  if (verbose>=3)
     
    603638   \param matString the Material that will be set.
    604639*/
    605 
    606640bool Object::readUseMtl (char* matString)
    607641{
     
    635669  readVertex ("-0.500000 -0.500000 -0.500000");
    636670  readVertex ("0.500000 -0.500000 -0.500000");
     671
    637672  readVertexTexture ("0.000000 0.000000");
    638673  readVertexTexture ("1.000000 0.000000");
Note: See TracChangeset for help on using the changeset viewer.