Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2863 in orxonox.OLD for orxonox


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 )

Location:
orxonox/trunk/importer
Files:
1 added
4 edited

Legend:

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

    r2848 r2863  
    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/importer/framework.cc

    r2850 r2863  
    22#include "object.h"
    33
    4 int verbose = 2;
     4int verbose = 1;
    55WindowHandler wHandler;  // Create an instance of the whandler basecode class
    66Object* obj;
     
    7474      switch (event.type) {
    7575        // If a quit event was recieved
    76         case SDL_QUIT:
    77           // then we're done and we'll end this program
     76      case SDL_QUIT:
     77        // then we're done and we'll end this program
    7878          done=TRUE;
    7979          break;
    80         default:
     80      default:
    8181          break;
    8282      }
  • 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
  • orxonox/trunk/importer/object.h

    r2852 r2863  
    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.