- Timestamp:
- Oct 8, 2005, 12:32:52 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/glmenu/glmenu_imagescreen.cc
r5300 r5308 284 284 SDL_GL_SwapBuffers(); 285 285 } 286 287 -
trunk/src/lib/graphics/importer/material.cc
r5306 r5308 57 57 Material::~Material() 58 58 { 59 PRINTF( 4)("delete Material %s.\n", this->getName());59 PRINTF(5)("delete Material %s.\n", this->getName()); 60 60 61 61 if (this->diffuseTexture != NULL) 62 { 62 63 ResourceManager::getInstance()->unload(this->diffuseTexture); 64 } 63 65 if (this->ambientTexture != NULL) 64 66 ResourceManager::getInstance()->unload(this->ambientTexture); … … 69 71 /** 70 72 * sets the material with which the following Faces will be painted 71 */72 bool Material::select () 73 */ 74 bool Material::select () const 73 75 { 74 76 // setting diffuse color … … 127 129 * Sets the Material Illumination Model. 128 130 * illu illumination Model in int form 129 */131 */ 130 132 void Material::setIllum (int illum) 131 133 { … … 133 135 this->illumModel = illum; 134 136 } 137 135 138 /** 136 139 * Sets the Material Illumination Model. 137 140 * illu illumination Model in char* form 138 */void Material::setIllum (char* illum) 141 */ 142 void Material::setIllum (char* illum) 139 143 { 140 144 this->setIllum (atoi(illum)); … … 146 150 * @param g Green Color Channel. 147 151 * @param b Blue Color Channel. 148 */152 */ 149 153 void Material::setDiffuse (float r, float g, float b) 150 154 { … … 156 160 157 161 } 162 158 163 /** 159 164 * Sets the Material Diffuse Color. 160 165 * @param rgb The red, green, blue channel in char format (with spaces between them) 161 */166 */ 162 167 void Material::setDiffuse (char* rgb) 163 168 { … … 181 186 this->ambient[3] = 1.0; 182 187 } 188 183 189 /** 184 190 * Sets the Material Ambient Color. 185 191 * @param rgb The red, green, blue channel in char format (with spaces between them) 186 */192 */ 187 193 void Material::setAmbient (char* rgb) 188 194 { … … 197 203 * @param g Green Color Channel. 198 204 * @param b Blue Color Channel. 199 */205 */ 200 206 void Material::setSpecular (float r, float g, float b) 201 207 { … … 206 212 this->specular[3] = 1.0; 207 213 } 214 208 215 /** 209 216 * Sets the Material Specular Color. … … 269 276 void Material::setDiffuseMap(const char* dMap) 270 277 { 271 PRINTF( 4)("setting Diffuse Map %s\n", dMap);278 PRINTF(5)("setting Diffuse Map %s\n", dMap); 272 279 if (this->diffuseTexture != NULL) 273 280 ResourceManager::getInstance()->unload(this->diffuseTexture); -
trunk/src/lib/graphics/importer/material.h
r4836 r5308 26 26 public: 27 27 Material (const char* mtlName = NULL); 28 ~Material ();28 virtual ~Material (); 29 29 30 bool select () ;30 bool select () const; 31 31 32 32 void setIllum (int illum); … … 58 58 float shininess; //!< The shininess of the Material. 59 59 float transparency; //!< The transperency of the Material. 60 60 public: 61 61 Texture* diffuseTexture; //!< The diffuse texture of the Material. 62 62 Texture* ambientTexture; //!< The ambient texture of the Material. -
trunk/src/lib/graphics/importer/model.cc
r5304 r5308 65 65 66 66 this->next = NULL; 67 68 67 } 69 68 … … 383 382 ////////// 384 383 /** 385 * 384 * adds a new Material to the Material List 386 385 * @param material the Material to add 387 386 * @returns the added material … … 392 391 Material* Model::addMaterial(Material* material) 393 392 { 393 if (material == NULL) 394 return NULL; 394 395 ModelMaterial* modMat = new ModelMaterial; 395 396 modMat->external = true; … … 408 409 ModelMaterial* modMat = new ModelMaterial; 409 410 modMat->external = false; 410 modMat->material = new Material(); 411 modMat->material->setName(materialName); 411 modMat->material = new Material(materialName); 412 412 413 413 // adding material to the List of materials … … 474 474 float subbuffer3; 475 475 sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3); 476 PRINTF(5)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3);477 476 this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor); 478 477 this->vertexCount++; … … 507 506 float subbuffer3; 508 507 sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3); 509 PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);510 508 this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3); 511 509 this->normalCount++; … … 543 541 float subbuffer2; 544 542 sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2); 545 PRINTF(5)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2);546 543 this->vTexture->addEntry(subbuffer1); 547 544 this->vTexture->addEntry(1 - subbuffer2); … … 659 656 660 657 /** 661 * 658 * Function that selects a material, if changed in the obj file. 662 659 * @param matString the Material that will be set. 663 660 */ … … 674 671 675 672 /** 676 * 673 * Function that selects a material, if changed in the obj file. 677 674 * @param mtl the Material that will be set. 678 675 */ … … 1106 1103 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,16, 7,10,17, 5,11,18, 3,3,19); 1107 1104 this->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,12,20, 0,0,21, 2,2,22, 4,13,23); 1108 1109 } 1105 } -
trunk/src/lib/graphics/importer/texture.h
r5304 r5308 21 21 22 22 //! A Class, that reads in Textures from different fileformats. 23 class Texture : public 23 class Texture : public BaseObject 24 24 { 25 25 public: -
trunk/src/util/resource_manager.cc
r5307 r5308 251 251 { 252 252 PRINTF(4)("not loading cached resource %s\n", tmpResource->name); 253 // printf("adding %s count: %d\n", tmpResource->pointer->getName(), tmpResource->count);254 253 tmpResource->count++; 255 254 if(tmpResource->prio < prio) … … 409 408 } 410 409 else 411 unload(tmpResource, prio);410 return unload(tmpResource, prio); 412 411 } 413 412 … … 416 415 * @param resource: The resource to unloade 417 416 * @param prio the PriorityLevel to unload this resource 417 * @returns true on success, false otherwise. 418 418 */ 419 419 bool ResourceManager::unload(Resource* resource, ResourcePriority prio) … … 421 421 if (resource == NULL) 422 422 return false; 423 // printf("removing %s count: %d\n", resource->pointer->getName(), resource->count);424 423 if (resource->count > 0) 425 424 resource->count--; … … 427 426 if (resource->prio <= prio) 428 427 { 429 if (resource->count <= 0)428 if (resource->count == 0) 430 429 { 431 430 // deleting the Resource … … 480 479 481 480 /** 482 * 481 * unloads all alocated Memory of Resources with a pririty lower than prio 483 482 * @param prio The priority to delete 484 483 */ … … 486 485 { 487 486 tIterator<Resource>* iterator = resourceList->getIterator(); 488 Resource* enumRes = iterator-> firstElement();487 Resource* enumRes = iterator->lastElement(); 489 488 while (enumRes) 490 489 { … … 496 495 enumRes->name, enumRes->count); 497 496 //enumRes = resourceList->nextElement(); 498 enumRes = iterator-> nextElement();497 enumRes = iterator->prevElement(); 499 498 } 500 499 delete iterator; -
trunk/src/util/resource_manager.h
r5306 r5308 66 66 { 67 67 BaseObject* pointer; //!< Pointer to the Resource. 68 intcount; //!< How many times this Resource has been loaded.68 unsigned int count; //!< How many times this Resource has been loaded. 69 69 70 70 char* name; //!< Name of the Resource. … … 85 85 //! The ResourceManager is a class, that decides if a file/resource should be loaded 86 86 /** 87 If a file/resource was already loaded the resourceManager will 88 return a void pointer to the desired resource. 89 Otherwise it will instruct the corresponding resource-loader to load, 90 and receive the pointer to it. 91 92 It does it by looking, if a desired file has already been loaded. 93 */ 87 * If a file/resource was already loaded the resourceManager will 88 * return a pointer to the desired resource. 89 * Otherwise it will instruct the corresponding resource-loader to load, 90 * and receive the pointer to it. 91 * 92 * It does it by looking, if a desired file has already been loaded. 93 * There is also the possibility to check for some variables 94 */ 94 95 class ResourceManager : public BaseObject 95 96 { … … 101 102 bool setDataDir(const char* dataDir); 102 103 /** @returns the Name of the data directory */ 103 inline const char* getDataDir() const { return this->dataDir;}104 inline const char* getDataDir() const { return this->dataDir; }; 104 105 105 106 bool checkDataDir(const char* fileInside); … … 135 136 static ResourceManager* singletonRef; //!< singleton Reference 136 137 138 char* dataDir; //!< The Data Directory, where all relevant Data is stored. 137 139 tList<Resource>* resourceList; //!< The List of Resources, that has already been loaded. 138 char* dataDir; //!< The Data Directory, where all relevant Data is stored.139 140 tList<char>* imageDirs; //!< A list of directories in which images are stored. 140 141 -
trunk/src/world_entities/environment.cc
r5285 r5308 34 34 { 35 35 this->setClassID(CL_ENVIRONMENT, "Environment"); 36 this-> model = (Model*)ResourceManager::getInstance()->load("models/ships/bolido.obj", OBJ, RP_CAMPAIGN);36 this->loadModel("models/ships/bolido.obj"); 37 37 38 38 /* if(this->obbTree == NULL) -
trunk/src/world_entities/skybox.cc
r5302 r5308 101 101 for (int i = 0; i < 6; i++) 102 102 delete this->material[i]; 103 delete []this->material;103 delete[] this->material; 104 104 delete this->model; 105 105 this->model = NULL; //< so that WorldEntity does not try to delete it again. -
trunk/src/world_entities/terrain.cc
r5143 r5308 39 39 this->loadParams(root); 40 40 41 this->ssp = new SpatialSeparation((AbstractModel*)this->model, 10.0f); 41 // if (this->model != NULL) 42 //this->ssp = new SpatialSeparation((AbstractModel*)this->model, 10.0f); 42 43 } 43 44 … … 53 54 this->init(); 54 55 55 if ( strstr(fileName, ".obj") || strstr(fileName, ".OBJ"))56 { 57 this-> model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_LEVEL);56 if (!strcasestr(fileName, ".obj") ) 57 { 58 this->loadModel(fileName); 58 59 } 59 60 else … … 65 66 /** 66 67 * a Constructor for the Debug-Worlds 67 68 @todo make it not compileable when not in debug-mode 69 */ 68 */ 70 69 Terrain::Terrain(DebugTerrain debugTerrain) 71 70 { … … 92 91 93 92 this->objectList = 0; 93 this->ssp = NULL; 94 94 } 95 95 … … 122 122 123 123 /* THIS IS ONLY FOR DEBUGGING INFORMATION */ 124 this->ssp->drawQuadtree(); 124 if (this->ssp != NULL) 125 this->ssp->drawQuadtree(); 125 126 } 126 127 … … 289 290 */ 290 291 } 291 292 } 292 } -
trunk/src/world_entities/terrain.h
r5039 r5308 42 42 private: 43 43 int objectList; 44 45 44 }; 46 45
Note: See TracChangeset
for help on using the changeset viewer.