Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3068 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Dec 3, 2004, 4:27:42 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: cleanup-procedure created, that deletes all the unneded stuff like faces, faceElements (does not really delete faceElements :( )

Location:
orxonox/trunk/importer
Files:
3 edited

Legend:

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

    r2988 r3068  
    11#include "framework.h"
    22
    3 int verbose = 1;
     3int verbose = 4;
    44
    55void DrawGLScene()
  • orxonox/trunk/importer/object.cc

    r3066 r3068  
    208208
    209209  group->firstFace = new Face;
     210  initFace (group->firstFace);
    210211  group->currentFace = group->firstFace;
    211212}
     
    233234bool Object::cleanup(void)
    234235{
    235   //  if (verbose >=3)
    236     printf("finalizing the 3D-Object\n");
     236  if (verbose >=2)
     237    printf("cleaning up the 3D-Object to save Memory.\n");
    237238
    238239  if (vertices != NULL)
     
    245246  if (material != NULL)
    246247    delete material;
     248
     249  cleanupGroup(firstGroup);
    247250  return true;
     251}
     252
     253/**
     254   \brief Cleans up all groups starting from group.
     255   \param group the first Group to clean
     256*/
     257bool Object::cleanupGroup (Group* group)
     258{
     259  if (verbose>=4)
     260    printf ("Cleaning up group\n");
     261  if (group->firstFace != NULL)
     262    {
     263      cleanupFace (group->firstFace);
     264      delete group->firstFace;
     265    }
     266
     267  if (group->next !=NULL)
     268    cleanupGroup (group->next);
     269  return true;
     270}
     271
     272/**
     273   \brief Cleans up all Faces starting from face.
     274   \param face the first face to clean
     275*/
     276bool Object::cleanupFace (Face* face)
     277{
     278  if (verbose>=4)
     279    printf ("Cleaning up Face\n");
     280
     281  if (face->materialString != NULL)
     282      delete face->materialString;
     283  if (face->firstElem != NULL)
     284    {
     285      cleanupFaceElement(face->firstElem);
     286      delete face->firstElem;
     287    }
     288     
     289  if (face->next != NULL)
     290    {
     291      cleanupFace (face->next);
     292      delete face->next;
     293    }
     294     
     295}
     296
     297
     298/**
     299   \brief Cleans up all FaceElements starting from faceElem.
     300   \param faceElem the first FaceElement to clean.
     301*/
     302bool Object::cleanupFaceElement(FaceElement* faceElem)
     303{
     304  if (faceElem->value != NULL)
     305    if (verbose>=4)
     306      printf ("Cleaning up faceElement %s\n", faceElem->value);
     307    //delete faceElem->value;
     308
     309  if (faceElem->next != NULL)
     310    {
     311      cleanupFaceElement (faceElem->next);
     312      //      delete faceElem->next;
     313    }
    248314}
    249315
     
    350416  if (groupCount != 0 && currentGroup->faceCount>0)
    351417    {
    352       Group* newGroup = new Group;
    353418      //      finalizeGroup(currentGroup);
    354       currentGroup->next = newGroup;
    355       initGroup(newGroup);
    356       currentGroup = newGroup; // must be after init see initGroup for more info
     419      currentGroup = currentGroup->next = new Group;
     420      initGroup(currentGroup);
    357421    }
    358422
     
    391455
    392456  FaceElement* tmpElem = currentGroup->currentFace->firstElem = new FaceElement;
    393 
     457  tmpElem->next = NULL;
     458  tmpElem->value = NULL;
    394459  while(strcmp (faceString, "\0"))
    395460    {
     
    397462          tmpElem = tmpElem->next = new FaceElement;
    398463      tmpElem->next = NULL;
     464      tmpElem->value = NULL;
    399465
    400466      char tmpValue [50];
     
    647713  if (verbose >=3)
    648714    printf ("importing grafical Element to openGL: %s\n", elementString);
    649   char* vertex = elementString;
     715  char vertex [100];
     716  strcpy (vertex, elementString);
    650717
    651718  char* texture;
  • orxonox/trunk/importer/object.h

    r3066 r3068  
    9393  bool cleanupGroup(Group* group);
    9494  bool cleanupFace(Face* face);
     95  bool cleanupFaceElement(FaceElement* faceElem);
    9596
    9697  ///// readin ///
Note: See TracChangeset for help on using the changeset viewer.