Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2863 in orxonox.OLD for orxonox/trunk/importer/object.cc


Ignore:
Timestamp:
Nov 16, 2004, 1:19:54 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: now imports more than 3 different objects, but there is an error with the groupname, this will be resolved. also added toDo (do not inject into trunksvn add toDo )

File:
1 edited

Legend:

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

    r2852 r2863  
    117117
    118118/**
    119    \brief finalizes an Object.
     119  \brief finalizes an Object.
    120120   This funcion is needed, to close the glList and all the other lists.
    121121*/
     
    224224  if (verbose >= 2)
    225225    printf("Adding new Group\n");
     226  group->name = "";
    226227  group->faceMode = -1;
    227   group->name = "";
     228  group->faceCount =0; 
    228229  if ((group->listNumber = glGenLists(1)) == 0 )
    229230    {
     
    244245      group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2;
    245246    }
    246 
     247  if (verbose >=2)
     248    printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal);
    247249  group->vertices = new Array();
    248250  group->normals = new Array();
     
    254256/**
    255257   \brief finalizes a Group.
     258   \param group the group to finalize.
    256259*/
    257260bool Object::finalizeGroup(Group* group)
    258261{
     262  if (verbose >=2)
     263    printf ("Finalize group %s.\n", group->name);
    259264  glEnd();
    260265  glEndList();
     266}
     267/**
     268   \brief deletes the Arrays of the Group to save space.
     269   \param group the group to delete the arrays from.
     270*/
     271bool Object::cleanupGroup(Group* group)
     272{
     273  if (verbose >=2)
     274    printf ("cleaning up group %s.\n", group->name);
    261275 
    262276  delete group->vertices;
     
    264278  delete group->vTexture;
    265279}
     280
    266281/**
    267282   \brief Reads in the .obj File and sets all the Values.
     
    328343    }
    329344  OBJ_FILE->close();
     345  return true;
    330346
    331347}
     
    368384
    369385  readingVertices = false;
     386  currentGroup->faceCount++;
    370387  char subbuffer1[20];
    371388  char subbuffer2[20];
     
    421438{
    422439  if (verbose >=3)
    423     printf ("importing grafical Element.... including to openGL\n");
     440    printf ("importing grafical Element to openGL\n");
    424441  char* vertex = elementString;
    425442
     
    428445  texture[0] = '\0';
    429446  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());
    430449  glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
    431450
     
    438457      glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
    439458    }
     459  if (verbose>=3)
     460    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());
    440461  glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3);
    441462
     
    486507bool Object::readGroup (char* groupString)
    487508{
    488   //  printf ("test\n");
    489   if (!strcmp(groupString, "default"))
    490     {
    491       if (groupCount != 0)
    492         {
    493           Group* newGroup = new Group;
    494           finalizeGroup(currentGroup);
    495           currentGroup->nextGroup = newGroup;
    496           initGroup(newGroup);
    497           currentGroup = newGroup; // must be after init see initGroup for more info
    498         }
    499       ++groupCount;
    500     }
    501   else
    502     {
    503      
    504       currentGroup->name = new char [strlen(groupString)];     
     509  // setting the group name if not default.
     510  if (strcmp(currentGroup->name, "default"))
     511    {
     512      currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char));
    505513      strcpy(currentGroup->name, groupString);
    506514    }
     515  if (groupCount != 0 && currentGroup->faceCount>0)
     516    {
     517      Group* newGroup = new Group;
     518      finalizeGroup(currentGroup);
     519      currentGroup->nextGroup = newGroup;
     520      initGroup(newGroup);
     521      cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup.
     522      currentGroup = newGroup; // must be after init see initGroup for more info
     523    }
     524
     525  ++groupCount;
     526
    507527}
    508528
Note: See TracChangeset for help on using the changeset viewer.