Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2005, 9:29:41 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/physics: merged with trunk - with command svn merge -r 3866:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/lib/graphics/importer/material.cc

    r3803 r3953  
    3434   \param mtlName Name of the Material to be added to the Material List
    3535*/
    36 Material::Material (char* mtlName)
     36Material::Material (const char* mtlName)
    3737{
    3838   PRINTF(4)("initializing new Material.\n");
    39   this->nextMat = NULL;
    40   this->name ="";
     39  this->name = NULL;
    4140  this->setIllum(3);
    4241  this->setDiffuse(0,0,0);
     
    5554  this->specularTextureSet = false;
    5655
    57   if (mtlName)
    58     this->setName (mtlName);
    59   else
    60     this->setName("");
     56  this->setName(mtlName);
    6157}
    6258
     
    7167  if (this->diffuseTexture)
    7268    ResourceManager::getInstance()->unload(this->diffuseTexture);
    73   if (this->nextMat)
    74     delete this->nextMat;
    75 }
    76 
    77 /**
    78    \brief adds a new Material to the List.
    79    this Function will append a new Material to the end of a Material List.
    80    \param mtlName The name of the Material to be added.
    81 */
    82 Material* Material::addMaterial(char* mtlName)
    83 {
    84   PRINTF(4)("adding Material %s.\n", mtlName);
    85    Material* tmpMat = this;
    86   while (tmpMat->nextMat != NULL)
    87     {
    88       tmpMat = tmpMat->nextMat;
    89     }
    90   tmpMat->nextMat = new Material(mtlName);
    91   return tmpMat->nextMat;
    92  
    93 }
    94 
    95 /**
    96    \brief Search for a Material called mtlName
    97    \param mtlName the Name of the Material to search for
    98    \returns Material named mtlName if it is found. NULL otherwise.
    99 */
    100 Material* Material::search(char* mtlName)
    101 {
    102   PRINTF(5)("Searching for material %s", mtlName);
    103   Material* searcher = this;
    104   while (searcher != NULL)
    105     {
    106       PRINT(5)(".");
    107       if (!strcmp (searcher->getName(), mtlName))
    108         {
    109           PRINT(5)("found.\n");
    110           return searcher;
    111         }
    112       searcher = searcher->nextMat;
    113     }
    114   PRINT(2)("material %s not found\n", mtlName);
    115   return NULL;
    11669}
    11770
     
    168121   \param mtlName the Name of the Material to be set.
    169122*/
    170 void Material::setName (char* mtlName)
    171 {
    172   PRINTF(4)("setting Material Name to %s.\n", this->name);
    173   this->name = new char [strlen(mtlName)+1];
    174   strcpy(this->name, mtlName);
     123void Material::setName (const char* mtlName)
     124{
     125  if (this->name)
     126    delete this->name;
     127  if (mtlName)
     128    {
     129      this->name = new char [strlen(mtlName)+1];
     130      strcpy(this->name, mtlName);
     131    }
     132  else
     133    {
     134      this->name = new char[2];
     135      strcpy(this->name, "");
     136    }
    175137}
    176138
Note: See TracChangeset for help on using the changeset viewer.