Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 19, 2005, 6:48:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Material, and Model update, some const-issues

File:
1 edited

Legend:

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

    r3803 r3894  
    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");
    3939  this->nextMat = NULL;
    40   this->name ="";
     40  this->name = NULL;
    4141  this->setIllum(3);
    4242  this->setDiffuse(0,0,0);
     
    5555  this->specularTextureSet = false;
    5656
    57   if (mtlName)
    58     this->setName (mtlName);
    59   else
    60     this->setName("");
     57  this->setName(mtlName);
    6158}
    6259
     
    8077   \param mtlName The name of the Material to be added.
    8178*/
    82 Material* Material::addMaterial(char* mtlName)
     79Material* Material::addMaterial(const char* mtlName)
    8380{
    8481  PRINTF(4)("adding Material %s.\n", mtlName);
     
    9895   \returns Material named mtlName if it is found. NULL otherwise.
    9996*/
    100 Material* Material::search(char* mtlName)
     97Material* Material::search(const char* mtlName)
    10198{
    10299  PRINTF(5)("Searching for material %s", mtlName);
     
    168165   \param mtlName the Name of the Material to be set.
    169166*/
    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);
     167void Material::setName (const char* mtlName)
     168{
     169  if (this->name)
     170    delete this->name;
     171  if (mtlName)
     172    {
     173      this->name = new char [strlen(mtlName)+1];
     174      strcpy(this->name, mtlName);
     175    }
     176  else
     177    {
     178      this->name = new char[2];
     179      strcpy(this->name, "");
     180    }
    175181}
    176182
Note: See TracChangeset for help on using the changeset viewer.