Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2866 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Nov 16, 2004, 2:07:07 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged importer to src again

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

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

    r2853 r2866  
    6969    printf ("Finalizing array.\n"); 
    7070  if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
     71  //  if ((array = new GLfloat [entryCount]) == NULL)
    7172    printf ("could not allocate %i data Blocks\n", entryCount);
    7273  Entry* walker = firstEntry;
     
    7778    }
    7879  finalized = true;
     80
    7981  return;
    8082}
     
    9193        printf ("adding new Entry to Array: %f\n", entry);
    9294     
    93       entryCount++;
    9495      currentEntry->value = entry;
    9596      currentEntry->next = new Entry;
    9697      currentEntry = currentEntry->next;
    9798      currentEntry->next = NULL;
     99      ++entryCount;
    98100    }
    99101  else
  • orxonox/trunk/src/object.cc

    r2853 r2866  
    119119
    120120/**
    121    \brief finalizes an Object.
     121  \brief finalizes an Object.
    122122   This funcion is needed, to close the glList and all the other lists.
    123123*/
     
    226226  if (verbose >= 2)
    227227    printf("Adding new Group\n");
     228  group->name = "";
    228229  group->faceMode = -1;
    229   group->name = "";
     230  group->faceCount =0; 
    230231  if ((group->listNumber = glGenLists(1)) == 0 )
    231232    {
     
    246247      group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2;
    247248    }
    248 
     249  if (verbose >=2)
     250    printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal);
    249251  group->vertices = new Array();
    250252  group->normals = new Array();
     
    256258/**
    257259   \brief finalizes a Group.
     260   \param group the group to finalize.
    258261*/
    259262bool Object::finalizeGroup(Group* group)
    260263{
     264  if (verbose >=2)
     265    printf ("Finalize group %s.\n", group->name);
    261266  glEnd();
    262267  glEndList();
     268}
     269/**
     270   \brief deletes the Arrays of the Group to save space.
     271   \param group the group to delete the arrays from.
     272*/
     273bool Object::cleanupGroup(Group* group)
     274{
     275  if (verbose >=2)
     276    printf ("cleaning up group %s.\n", group->name);
    263277 
    264278  delete group->vertices;
     
    266280  delete group->vTexture;
    267281}
     282
    268283/**
    269284   \brief Reads in the .obj File and sets all the Values.
     
    330345    }
    331346  OBJ_FILE->close();
     347  return true;
    332348
    333349}
     
    370386
    371387  readingVertices = false;
     388  currentGroup->faceCount++;
    372389  char subbuffer1[20];
    373390  char subbuffer2[20];
     
    423440{
    424441  if (verbose >=3)
    425     printf ("importing grafical Element.... including to openGL\n");
     442    printf ("importing grafical Element to openGL\n");
    426443  char* vertex = elementString;
    427444
     
    430447  texture[0] = '\0';
    431448  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());
    432451  glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
    433452
     
    440459      glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
    441460    }
     461  if (verbose>=3)
     462    printf ("includeing vertex #%i, and mapping it to group vertex #%i, vertexArray has %i entries.\n", atoi(vertex), (atoi(vertex)-1 - currentGroup->firstVertex)*3, currentGroup->vertices->getCount());
    442463  glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3);
    443464
     
    488509bool Object::readGroup (char* groupString)
    489510{
    490   //  printf ("test\n");
    491   if (!strcmp(groupString, "default"))
    492     {
    493       if (groupCount != 0)
    494         {
    495           Group* newGroup = new Group;
    496           finalizeGroup(currentGroup);
    497           currentGroup->nextGroup = newGroup;
    498           initGroup(newGroup);
    499           currentGroup = newGroup; // must be after init see initGroup for more info
    500         }
    501       ++groupCount;
    502     }
    503   else
    504     {
    505      
    506       currentGroup->name = new char [strlen(groupString)];     
     511  // setting the group name if not default.
     512  if (strcmp(currentGroup->name, "default"))
     513    {
     514      currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char));
    507515      strcpy(currentGroup->name, groupString);
    508516    }
     517  if (groupCount != 0 && currentGroup->faceCount>0)
     518    {
     519      Group* newGroup = new Group;
     520      finalizeGroup(currentGroup);
     521      currentGroup->nextGroup = newGroup;
     522      initGroup(newGroup);
     523      cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup.
     524      currentGroup = newGroup; // must be after init see initGroup for more info
     525    }
     526
     527  ++groupCount;
     528
    509529}
    510530
  • orxonox/trunk/src/object.h

    r2853 r2866  
    4949    Array* vTexture;
    5050    int faceMode;
     51    int faceCount;
    5152
    5253    int firstVertex;
     
    7475  bool initGroup(Group* group);
    7576  bool finalizeGroup (Group* group);
     77  bool cleanupGroup(Group* group);
    7678
    7779
Note: See TracChangeset for help on using the changeset viewer.