Changeset 3672 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Mar 30, 2005, 3:02:58 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/defs/debug.h
r3668 r3672 58 58 // DEFINE MODULES \\ 59 59 #define DEBUG_MODULE_ORXONOX 0 60 #define DEBUG_MODULE_WORLD 360 #define DEBUG_MODULE_WORLD 2 61 61 #define DEBUG_MODULE_PNODE 0 62 62 #define DEBUG_MODULE_WORLD_ENTITY 0 63 63 #define DEBUG_MODULE_COMMAND_NODE 0 64 64 #define DEBUG_MODULE_GRAPHICS 0 65 #define DEBUG_MODULE_LOAD 065 #define DEBUG_MODULE_LOAD 4 66 66 67 67 #define DEBUG_MODULE_IMPORTER 0 -
orxonox/trunk/src/lib/graphics/importer/material.cc
r3658 r3672 62 62 delete []this->name; 63 63 if (this->diffuseTexture) 64 ResourceManager:: unload(this->diffuseTexture);64 ResourceManager::getInstance()->unload(this->diffuseTexture); 65 65 if (this->nextMat) 66 66 delete this->nextMat; … … 339 339 //! \todo check if RESOURCE MANAGER is availiable 340 340 //! \todo Textures from .mtl-file need special care. 341 this->diffuseTextureSet = this->diffuseTexture = (Texture*)ResourceManager:: load(dMap, IMAGE);341 this->diffuseTextureSet = this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE); 342 342 } 343 343 -
orxonox/trunk/src/lib/util/resource_manager.cc
r3667 r3672 11 11 ### File Specific: 12 12 main-programmer: Benjamin Grauer 13 co-programmer: ...13 co-programmer: Patrick Boenzli 14 14 */ 15 15 … … 38 38 { 39 39 this->setClassName ("ResourceManager"); 40 dataDir = NULL;41 imageDirs = new tList<char>();42 resourceList = new tList<Resource>();40 this->dataDir = "./"; 41 this->imageDirs = new tList<char>(); 42 this->resourceList = new tList<Resource>(); 43 43 } 44 44 … … 55 55 //! Singleton Reference to the ResourceManager 56 56 ResourceManager* ResourceManager::singletonRef = NULL; 57 //! The List of Resources, that has already been loaded.58 tList<Resource>* ResourceManager::resourceList = NULL;59 //! The Data Directory, where all relevant Data is stored.60 char* ResourceManager::dataDir = NULL;61 //! A list of directories in which images are stored.62 tList<char>* ResourceManager::imageDirs = NULL;63 57 64 58 /** … … 68 62 { 69 63 // deleting the Resources-List 70 unloadAllByPriority(RP_GAME); 71 delete resourceList; 72 resourceList = NULL; 64 this->unloadAllByPriority(RP_GAME); 65 delete this->resourceList; 73 66 // deleting the Directorie Lists 74 char* tmpDir = imageDirs->enumerate(); 67 tIterator<char>* tmpIt = imageDirs->getIterator(); 68 char* tmpDir = tmpIt->nextElement(); 75 69 while(tmpDir) 76 70 { 77 71 delete []tmpDir; 78 tmpDir = imageDirs->nextElement(); 79 } 80 81 delete imageDirs; 82 imageDirs = NULL; 72 tmpDir = tmpIt->nextElement(); 73 } 74 delete tmpIt; 75 76 delete this->imageDirs; 77 83 78 ResourceManager::singletonRef = NULL; 84 79 } … … 92 87 if (isDir(dataDir)) 93 88 { 94 ResourceManager::dataDir = new char[strlen(dataDir)+1];95 strcpy( ResourceManager::dataDir, dataDir);89 this->dataDir = new char[strlen(dataDir)+1]; 90 strcpy(this->dataDir, dataDir); 96 91 } 97 92 else … … 113 108 { 114 109 // check if the Directory has been added before 115 char* tmpDir = imageDirs->enumerate(); 110 tIterator<char>* tmpImageDirs = imageDirs->getIterator(); 111 char* tmpDir = tmpImageDirs->nextElement(); 116 112 while(tmpDir) 117 113 { … … 119 115 { 120 116 PRINTF(4)("Path %s already loaded\n", imageDir); 117 delete tmpImageDirs; 121 118 return true; 122 119 } 123 tmpDir = imageDirs->nextElement(); 124 } 120 tmpDir = tmpImageDirs->nextElement(); 121 } 122 delete tmpImageDirs; 123 125 124 // adding the directory to the List 126 125 tmpDir = new char[strlen(imageDir)+1]; 127 126 strcpy(tmpDir, imageDir); 128 imageDirs->add(tmpDir);127 this->imageDirs->add(tmpDir); 129 128 return true; 130 129 } … … 162 161 tmpType = IMAGE; 163 162 164 return ResourceManager::load(fileName, tmpType, prio);163 return this->load(fileName, tmpType, prio); 165 164 } 166 165 … … 175 174 { 176 175 // searching if the resource was loaded before. 177 Resource* tmpResource = ResourceManager::locateResourceByName(fileName);176 Resource* tmpResource = this->locateResourceByName(fileName); 178 177 if (!tmpResource) // if the resource was not loaded before. 179 178 { … … 189 188 // creating the full name. (directoryName + FileName) 190 189 char* fullName = new char[strlen(dataDir)+strlen(fileName)+1]; 191 sprintf(fullName, "%s%s", dataDir, fileName);190 sprintf(fullName, "%s%s", this->dataDir, fileName); 192 191 193 192 // Checking for the type of resource \see ResourceType … … 251 250 tmpResource->pointer = NULL; 252 251 } 253 resourceList->add(tmpResource);252 this->resourceList->add(tmpResource); 254 253 delete []fullName; 255 254 } … … 274 273 { 275 274 // if pointer is existent. and only one resource of this type exists. 276 Resource* tmpResource = ResourceManager::locateResourceByPointer(pointer);275 Resource* tmpResource = this->locateResourceByPointer(pointer); 277 276 if (!tmpResource) 278 277 { … … 310 309 PRINTF(4)("Resource %s safely removed.\n", resource->name); 311 310 delete []resource->name; 312 resourceList->remove(resource);311 this->resourceList->remove(resource); 313 312 } 314 313 else … … 327 326 bool ResourceManager::unloadAllByPriority(ResourcePriority prio) 328 327 { 329 330 328 tIterator<Resource>* iterator = resourceList->getIterator(); 331 329 Resource* enumRes = iterator->nextElement(); -
orxonox/trunk/src/lib/util/resource_manager.h
r3660 r3672 56 56 virtual ~ResourceManager(); 57 57 58 staticbool setDataDir(char* dataDir);59 staticbool addImageDir(char* imageDir);60 staticvoid* load(const char* fileName, ResourcePriority prio = RP_NO);61 staticvoid* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO);62 staticbool unload(void* pointer, ResourcePriority prio = RP_NO);63 staticbool unload(Resource* resource, ResourcePriority = RP_NO);64 staticbool unloadAllByPriority(ResourcePriority prio);58 bool setDataDir(char* dataDir); 59 bool addImageDir(char* imageDir); 60 void* load(const char* fileName, ResourcePriority prio = RP_NO); 61 void* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO); 62 bool unload(void* pointer, ResourcePriority prio = RP_NO); 63 bool unload(Resource* resource, ResourcePriority = RP_NO); 64 bool unloadAllByPriority(ResourcePriority prio); 65 65 66 66 private: … … 68 68 static ResourceManager* singletonRef; 69 69 70 static tList<Resource>* resourceList;71 static char* dataDir;72 static tList<char>* imageDirs;70 tList<Resource>* resourceList; //!< The List of Resources, that has already been loaded. 71 char* dataDir; //!< The Data Directory, where all relevant Data is stored. 72 tList<char>* imageDirs; //!< A list of directories in which images are stored. 73 73 74 static Resource* locateResourceByName(const char* fileName); 75 static Resource* locateResourceByPointer(const void* pointer); 74 75 Resource* locateResourceByName(const char* fileName); 76 Resource* locateResourceByPointer(const void* pointer); 76 77 77 staticbool isDir(const char* directory);78 staticbool isFile(const char* directory);78 bool isDir(const char* directory); 79 bool isFile(const char* directory); 79 80 }; 80 81 -
orxonox/trunk/src/story_entities/world.cc
r3670 r3672 146 146 cn->reset(); 147 147 148 ResourceManager:: unloadAllByPriority(RP_LEVEL);148 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 149 149 150 150 delete WorldInterface::getInstance(); -
orxonox/trunk/src/world_entities/environment.cc
r3658 r3672 29 29 Environment::Environment () : WorldEntity() 30 30 { 31 this->model = (Model*) ResourceManager:: load("models/reaplow.obj", OBJ);31 this->model = (Model*) ResourceManager::getInstance()->load("models/reaplow.obj", OBJ); 32 32 // this->model = new OBJModel("../data/models/fighter.obj"); 33 33 } -
orxonox/trunk/src/world_entities/player.cc
r3660 r3672 45 45 the player.cc for debug also 46 46 */ 47 this->model = (Model*)ResourceManager:: load("models/reaplow.obj", OBJ, RP_CAMPAIGN);47 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 48 48 travelSpeed = 15.0; 49 49 velocity = new Vector(); -
orxonox/trunk/src/world_entities/projectile.cc
r3670 r3672 33 33 Projectile::Projectile () : WorldEntity() 34 34 { 35 //this->model = new OBJModel("");36 this->projectileModel = new Primitive(P_SPHERE);35 this->model = (Model*)ResourceManager::getInstance()->load("cube", PRIM, RP_LEVEL); 36 // this->projectileModel = new Primitive(P_SPHERE); 37 37 this->flightDirection = NULL; 38 38 this->currentLifeTime = 0.0f; … … 137 137 this->getAbsDir().matrix (matrix); 138 138 glMultMatrixf((float*)matrix); 139 //this->model->draw();140 this->projectileModel->draw();139 this->model->draw(); 140 //this->projectileModel->draw(); 141 141 142 142 glPopMatrix(); -
orxonox/trunk/src/world_entities/world_entity.cc
r3658 r3672 51 51 { 52 52 // if( collisioncluster != NULL) delete collisioncluster; 53 ResourceManager::unload(this->model); 53 if (this->model) 54 ResourceManager::getInstance()->unload(this->model); 54 55 } 55 56
Note: See TracChangeset
for help on using the changeset viewer.