Changeset 3953 in orxonox.OLD for orxonox/branches/physics/src/lib/graphics/importer/material.cc
- Timestamp:
- Apr 25, 2005, 9:29:41 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/lib/graphics/importer/material.cc
r3803 r3953 34 34 \param mtlName Name of the Material to be added to the Material List 35 35 */ 36 Material::Material (c har* mtlName)36 Material::Material (const char* mtlName) 37 37 { 38 38 PRINTF(4)("initializing new Material.\n"); 39 this->nextMat = NULL; 40 this->name =""; 39 this->name = NULL; 41 40 this->setIllum(3); 42 41 this->setDiffuse(0,0,0); … … 55 54 this->specularTextureSet = false; 56 55 57 if (mtlName) 58 this->setName (mtlName); 59 else 60 this->setName(""); 56 this->setName(mtlName); 61 57 } 62 58 … … 71 67 if (this->diffuseTexture) 72 68 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 mtlName97 \param mtlName the Name of the Material to search for98 \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;116 69 } 117 70 … … 168 121 \param mtlName the Name of the Material to be set. 169 122 */ 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); 123 void 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 } 175 137 } 176 138
Note: See TracChangeset
for help on using the changeset viewer.