Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3915 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Apr 21, 2005, 1:59:59 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: material is now only dependent on tList<Material>* in model

Location:
orxonox/trunk/src/lib/graphics/importer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r3914 r3915  
    4848  this->initGroup (this->currentGroup);
    4949  this->scaleFactor = 1;
    50   this->material = new Material();
    5150
    5251  this->vertices = new Array();
     
    8382    }
    8483
     84  // deleting the MaterialList
    8585  PRINTF(5)("Deleting Materials.\n");
    86   if (this->material)
    87     delete this->material;
    88 
    89   // deleting the MaterialList
     86
     87  tIterator<Material>* tmpIt = this->materialList->getIterator();
     88  Material* material = tmpIt->nextElement();
     89  while(material)
     90    {
     91      delete material;
     92      material = tmpIt->nextElement();
     93    }
     94  delete tmpIt;
    9095  delete materialList;
    9196}
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3913 r3915  
    9494  bool cleanupFaceElement(FaceElement* faceElem);
    9595
    96 
    9796  tList<Material>* materialList;
    9897
    9998 protected:
    10099  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
    101   Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
    102100
    103101  Material* findMaterialByName(const char* materialName);
  • orxonox/trunk/src/lib/graphics/importer/objModel.cc

    r3914 r3915  
    2525
    2626#include "debug.h"
     27#include "compiler.h"
    2728
    2829/**
     
    100101 
    101102  this->setName(name);
    102   if (this->material)
    103     this->material->addTexturePath(this->objPath);
     103
    104104  this->objFileName = new char[strlen(name)+1];
    105105  strcpy (this->objFileName, name);
     
    208208
    209209  char buffer[PARSELINELENGTH];
    210   Material* tmpMat = material;
     210  Material* tmpMat = NULL;
    211211
    212212  while(fgets(buffer, PARSELINELENGTH, stream))
     
    226226      else if (!strncmp(buffer, "illum ", 6))
    227227        {
    228           tmpMat->setIllum(buffer+6);
     228          if (likely(tmpMat != NULL))
     229            tmpMat->setIllum(buffer+6);
    229230
    230231        }
     
    232233      else if (!strncmp(buffer, "Kd ", 3))
    233234        {
    234           tmpMat->setDiffuse(buffer+3);
     235          if (likely(tmpMat != NULL))
     236            tmpMat->setDiffuse(buffer+3);
    235237        }
    236238      // setting Ambient Color
    237239      else if (!strncmp(buffer, "Ka ", 3))
    238240        {
    239           tmpMat->setAmbient(buffer+3);
     241          if (likely(tmpMat != NULL))
     242            tmpMat->setAmbient(buffer+3);
    240243        }
    241244      // setting Specular Color
    242245      else if (!strncmp(buffer, "Ks ", 3))
    243246        {
    244           tmpMat->setSpecular(buffer+3);
     247          if (likely(tmpMat != NULL))
     248            tmpMat->setSpecular(buffer+3);
    245249        }
    246250      // setting The Specular Shininess
    247251      else if (!strncmp(buffer, "Ns ", 3))
    248252        {
    249           tmpMat->setShininess(buffer+3);
     253          if (likely(tmpMat != NULL))
     254            tmpMat->setShininess(buffer+3);
    250255        }
    251256      // setting up transparency
    252257      else if (!strncmp(buffer, "d ", 2))
    253258        {
    254           tmpMat->setTransparency(buffer+2);
     259          if (likely(tmpMat != NULL))
     260            tmpMat->setTransparency(buffer+2);
    255261        }
    256262      else if (!strncmp(buffer, "Tf ", 3))
    257263        {
    258           tmpMat->setTransparency(buffer+3);
     264          if (likely(tmpMat != NULL))
     265            tmpMat->setTransparency(buffer+3);
    259266        }
    260267     
    261268      else if (!strncmp(buffer, "map_Kd ", 7))
    262269        {
    263           tmpMat->setDiffuseMap(buffer+7);
     270          if (likely(tmpMat != NULL))
     271            tmpMat->setDiffuseMap(buffer+7);
    264272        }
    265273      else if (!strncmp(buffer, "map_Ka ", 7))
    266274        {
    267           tmpMat->setAmbientMap(buffer+7);
     275          if (likely(tmpMat != NULL))
     276            tmpMat->setAmbientMap(buffer+7);
    268277        }
    269278      else if (!strncmp(buffer, "map_Ks ", 7))
    270279        {
    271           tmpMat->setSpecularMap(buffer+7);
     280          if (likely(tmpMat != NULL))
     281            tmpMat->setSpecularMap(buffer+7);
    272282        }
    273283      else if (!strncmp(buffer, "bump ", 5))
    274284        {
    275           tmpMat->setBump(buffer+7);
     285          if (likely(tmpMat != NULL))
     286            tmpMat->setBump(buffer+7);
    276287        }
    277288     
Note: See TracChangeset for help on using the changeset viewer.