Changeset 3915 in orxonox.OLD for orxonox/trunk/src/lib/graphics/importer
- Timestamp:
- Apr 21, 2005, 1:59:59 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/model.cc
r3914 r3915 48 48 this->initGroup (this->currentGroup); 49 49 this->scaleFactor = 1; 50 this->material = new Material();51 50 52 51 this->vertices = new Array(); … … 83 82 } 84 83 84 // deleting the MaterialList 85 85 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; 90 95 delete materialList; 91 96 } -
orxonox/trunk/src/lib/graphics/importer/model.h
r3913 r3915 94 94 bool cleanupFaceElement(FaceElement* faceElem); 95 95 96 97 96 tList<Material>* materialList; 98 97 99 98 protected: 100 99 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(..)102 100 103 101 Material* findMaterialByName(const char* materialName); -
orxonox/trunk/src/lib/graphics/importer/objModel.cc
r3914 r3915 25 25 26 26 #include "debug.h" 27 #include "compiler.h" 27 28 28 29 /** … … 100 101 101 102 this->setName(name); 102 if (this->material) 103 this->material->addTexturePath(this->objPath); 103 104 104 this->objFileName = new char[strlen(name)+1]; 105 105 strcpy (this->objFileName, name); … … 208 208 209 209 char buffer[PARSELINELENGTH]; 210 Material* tmpMat = material;210 Material* tmpMat = NULL; 211 211 212 212 while(fgets(buffer, PARSELINELENGTH, stream)) … … 226 226 else if (!strncmp(buffer, "illum ", 6)) 227 227 { 228 tmpMat->setIllum(buffer+6); 228 if (likely(tmpMat != NULL)) 229 tmpMat->setIllum(buffer+6); 229 230 230 231 } … … 232 233 else if (!strncmp(buffer, "Kd ", 3)) 233 234 { 234 tmpMat->setDiffuse(buffer+3); 235 if (likely(tmpMat != NULL)) 236 tmpMat->setDiffuse(buffer+3); 235 237 } 236 238 // setting Ambient Color 237 239 else if (!strncmp(buffer, "Ka ", 3)) 238 240 { 239 tmpMat->setAmbient(buffer+3); 241 if (likely(tmpMat != NULL)) 242 tmpMat->setAmbient(buffer+3); 240 243 } 241 244 // setting Specular Color 242 245 else if (!strncmp(buffer, "Ks ", 3)) 243 246 { 244 tmpMat->setSpecular(buffer+3); 247 if (likely(tmpMat != NULL)) 248 tmpMat->setSpecular(buffer+3); 245 249 } 246 250 // setting The Specular Shininess 247 251 else if (!strncmp(buffer, "Ns ", 3)) 248 252 { 249 tmpMat->setShininess(buffer+3); 253 if (likely(tmpMat != NULL)) 254 tmpMat->setShininess(buffer+3); 250 255 } 251 256 // setting up transparency 252 257 else if (!strncmp(buffer, "d ", 2)) 253 258 { 254 tmpMat->setTransparency(buffer+2); 259 if (likely(tmpMat != NULL)) 260 tmpMat->setTransparency(buffer+2); 255 261 } 256 262 else if (!strncmp(buffer, "Tf ", 3)) 257 263 { 258 tmpMat->setTransparency(buffer+3); 264 if (likely(tmpMat != NULL)) 265 tmpMat->setTransparency(buffer+3); 259 266 } 260 267 261 268 else if (!strncmp(buffer, "map_Kd ", 7)) 262 269 { 263 tmpMat->setDiffuseMap(buffer+7); 270 if (likely(tmpMat != NULL)) 271 tmpMat->setDiffuseMap(buffer+7); 264 272 } 265 273 else if (!strncmp(buffer, "map_Ka ", 7)) 266 274 { 267 tmpMat->setAmbientMap(buffer+7); 275 if (likely(tmpMat != NULL)) 276 tmpMat->setAmbientMap(buffer+7); 268 277 } 269 278 else if (!strncmp(buffer, "map_Ks ", 7)) 270 279 { 271 tmpMat->setSpecularMap(buffer+7); 280 if (likely(tmpMat != NULL)) 281 tmpMat->setSpecularMap(buffer+7); 272 282 } 273 283 else if (!strncmp(buffer, "bump ", 5)) 274 284 { 275 tmpMat->setBump(buffer+7); 285 if (likely(tmpMat != NULL)) 286 tmpMat->setBump(buffer+7); 276 287 } 277 288
Note: See TracChangeset
for help on using the changeset viewer.