Changeset 9785 in orxonox.OLD
- Timestamp:
- Sep 22, 2006, 3:40:06 PM (18 years ago)
- Location:
- branches/new_class_id/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/importer/material.cc
r9718 r9785 25 25 #include "loading/load_param.h" 26 26 27 #include "util/loading/resource_manager.h" 27 #include "resource_texture.h" 28 //#include "util/loading/resource_manager.h" 28 29 29 30 ObjectListDefinition(Material); … … 91 92 { 92 93 PRINTF(5)("delete Material %s.\n", this->getCName()); 93 94 if (this->ambientTexture != NULL)95 ResourceManager::getInstance()->unload(this->ambientTexture);96 if (this->specularTexture != NULL)97 ResourceManager::getInstance()->unload(this->specularTexture);98 94 99 95 if (this == Material::selectedMaterial) … … 297 293 void Material::addTexturePath(const std::string& pathName) 298 294 { 299 ResourceManager::getInstance()->addImageDir(pathName); 295 printf("HUPS\n"); 296 //ResourceManager::getInstance()->addImageDir(pathName); 300 297 } 301 298 … … 351 348 if (!dMap.empty()) 352 349 { 353 Texture* tex = dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target)); 354 if (tex != NULL) 355 this->textures[textureNumber] = *tex; 350 this->textures[textureNumber] = ResourceTexture(dMap); 351 //dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target)); 352 /* if (tex != NULL) 353 this->textures[textureNumber] = tex; 356 354 else 357 this->textures[textureNumber] = Texture(); 355 this->textures[textureNumber] = Texture();*/ 358 356 } 359 357 else -
branches/new_class_id/src/lib/graphics/importer/resource_texture.cc
r9784 r9785 6 6 7 7 ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target) 8 : Resource(&ResourceTexture::type) 8 9 { 9 Resource::Pointer* ptr = this->acquireResource( ResourceTexture::type,imageName + ',' + "TEST");10 Resource::Pointer* ptr = this->acquireResource(imageName + ',' + "TEST"); 10 11 11 12 if (ptr) … … 13 14 else 14 15 { 15 this->loadImage(imageName, target); 16 std::string fileName = this->Resource::locateFile(imageName); 17 this->Texture::loadImage(fileName, target); 18 this->Resource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", KeepLevel(), this->Texture::dataPointer())); 16 19 } 17 20 } … … 24 27 25 28 26 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, TextureData*data)29 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, const TextureData::Pointer& data) 27 30 : Resource::Pointer(loadString, keepLevel) , pointer(data) 28 { 29 } 31 {} 30 32 31 33 -
branches/new_class_id/src/lib/graphics/importer/resource_texture.h
r9784 r9785 14 14 class ResourceTexture : public Texture, public Resource 15 15 { 16 public: 16 17 ResourceTexture(const std::string& imageName, GLenum target = GL_TEXTURE_2D); 17 18 18 19 19 20 private: 20 21 class TextureResourcePointer : public Resource::Pointer 21 22 { 22 23 public: 23 TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, TextureData*data);24 TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, const TextureData::Pointer& data); 24 25 inline const TextureData::Pointer& ptr() const { return pointer; } 25 26 private: … … 27 28 }; 28 29 29 30 30 private: 31 static Resource::Type type; 31 32 }; 32 33 -
branches/new_class_id/src/lib/util/filesys/directory.cc
r9719 r9785 212 212 213 213 } 214 215 File operator+(const Directory& dir, const File& file) 216 { 217 return File(dir.name() + '/' + file.name()); 218 } -
branches/new_class_id/src/lib/util/filesys/directory.h
r9719 r9785 77 77 }; 78 78 79 File operator+(const Directory& dir, const File& file); 80 79 81 #endif /* __DIRECTORY_H_ */ 80 82 -
branches/new_class_id/src/lib/util/loading/resource.cc
r9784 r9785 17 17 18 18 #include "resource.h" 19 #include "filesys/file.h" 19 20 20 21 ObjectListDefinition(Resource); 22 23 24 std::vector<Resource::Type*> Resource::_resourceTypes; 25 26 //! GLOBALS 27 Directory Resource::_mainGlobalPath; 28 std::vector<Directory> Resource::_globalPaths; 21 29 22 30 … … 24 32 * standard constructor 25 33 */ 26 Resource::Resource ( )27 : _pointer(NULL) 34 Resource::Resource (Resource::Type* type) 35 : _pointer(NULL), _type(type) 28 36 { 29 37 this->registerObject(this, Resource::_objectList); 38 39 if(this->_type->id() == -1) 40 { 41 Resource::_resourceTypes.push_back(this->_type); 42 this->_type->setID(Resource::_resourceTypes.size()-1); 43 } 30 44 31 45 } … … 40 54 41 55 56 std::string Resource::locateFile(const std::string& fileName) 57 { 58 if (File(fileName).exists()) 59 return fileName; 60 else if ((Resource::_mainGlobalPath+File(fileName)) . exists() ) 61 return (Resource::_mainGlobalPath + File(fileName)).name(); 42 62 43 Resource::Pointer* Resource::acquireResource(Resource::Type& resourceType, const std::string& loadString) 63 64 return std::string("/home/bensch/svn/orxonox/data/") + fileName; 65 66 } 67 68 69 Resource::Pointer* Resource::acquireResource(const std::string& loadString) 44 70 { 45 if(resourceType.id() == -1) 46 { 47 Resource::_resourceTypes.push_back(&resourceType); 48 resourceType.setID(Resource::_resourceTypes.size()); 49 } 50 const Resource::Type* const type = Resource::_resourceTypes[resourceType.id()]; 71 //const Resource::Type* const type = Resource::_resourceTypes[this->_type->id()]; 51 72 52 for (unsigned int i = 0; i < type->storedResources().size(); ++i)53 if ( type->storedResources()[i]->_pointer->loadString() == loadString)54 return type->storedResources()[i]->_pointer;73 for (unsigned int i = 0; i < _type->storedResources().size(); ++i) 74 if (_type->storedResources()[i]->_pointer->loadString() == loadString) 75 return _type->storedResources()[i]->_pointer; 55 76 56 77 return NULL; 57 78 } 79 80 void Resource::setMainGlobalPath(const Directory& directory) 81 { 82 Resource::_mainGlobalPath = directory; 83 Resource::_mainGlobalPath.open(); 84 } 85 86 void Resource::addGlobalPath(const Directory& directory) 87 { 88 std::vector<Directory>::const_iterator it = std::find(Resource::_globalPaths.begin(), Resource::_globalPaths.end(), directory); 89 if (it == Resource::_globalPaths.end()) 90 Resource::_globalPaths.push_back(directory); 91 } 92 93 94 95 void Resource::addResource(Resource::Pointer* pointer) 96 {} 97 98 99 100 58 101 59 102 … … 68 111 _keepLevelName[level] = name; 69 112 } 113 114 115 116 117 118 119 120 121 122 123 Resource::Pointer::Pointer(const std::string& loadString, const Resource::KeepLevel& keeplevel) 124 { 125 } 126 127 void Resource::Type::setID(int id) 128 { 129 this->_id = id; 130 } -
branches/new_class_id/src/lib/util/loading/resource.h
r9784 r9785 12 12 #include <vector> 13 13 #include <set> 14 15 #include "filesys/directory.h" 14 16 15 17 //! A Resource is an Object, that can be loaded from Disk … … 48 50 49 51 void setID(int id); 52 void addResource(Resource* resource); 50 53 51 54 private: … … 73 76 74 77 public: 75 Resource( );78 Resource(Resource::Type* type); 76 79 virtual ~Resource(); 77 80 78 virtual bool reload(); 79 virtual bool unload(); 81 virtual bool reload() { return false; }; 82 virtual bool unload() { return false; }; 83 84 std::string locateFile(const std::string& fileName); 85 86 87 public: 88 static void setMainGlobalPath(const Directory& directory); 89 static void addGlobalPath(const Directory& directory); 90 80 91 81 92 protected: 82 Resource::Pointer* acquireResource(Resource::Type& resourceType, const std::string& loadString); 93 Resource::Pointer* acquireResource(const std::string& loadString); 94 void addResource(Resource::Pointer* pointer); 83 95 84 96 private: 85 97 Resource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData. 98 Resource::Type* _type; //!< Type of the Resource. 86 99 87 100 … … 89 102 90 103 //! GLOBALS 91 static std::string_mainGlobalPath;92 static std::vector< std::string>_globalPaths;104 static Directory _mainGlobalPath; 105 static std::vector<Directory> _globalPaths; 93 106 }; 94 107 -
branches/new_class_id/src/world_entities/WorldEntities.am
r9761 r9785 91 91 world_entities/weather_effects/atmospheric_engine.cc \ 92 92 world_entities/weather_effects/weather_effect.cc \ 93 world_entities/weather_effects/cloud_effect.cc \ 93 94 world_entities/weather_effects/sun_effect.cc \ 94 95 world_entities/weather_effects/fog_effect.cc \ … … 96 97 world_entities/weather_effects/rain_effect.cc \ 97 98 world_entities/weather_effects/snow_effect.cc \ 98 world_entities/weather_effects/cloud_effect.cc \99 99 world_entities/weather_effects/lightning_effect.cc \ 100 100 world_entities/weather_effects/lense_flare.cc
Note: See TracChangeset
for help on using the changeset viewer.