Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9785 in orxonox.OLD for branches/new_class_id/src


Ignore:
Timestamp:
Sep 22, 2006, 3:40:06 PM (18 years ago)
Author:
bensch
Message:

some implementations of the new self sustained Resources. It works, but does not yet load the correct stuff

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  
    2525#include "loading/load_param.h"
    2626
    27 #include "util/loading/resource_manager.h"
     27#include "resource_texture.h"
     28//#include "util/loading/resource_manager.h"
    2829
    2930ObjectListDefinition(Material);
     
    9192{
    9293  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);
    9894
    9995  if (this == Material::selectedMaterial)
     
    297293void Material::addTexturePath(const std::string& pathName)
    298294{
    299   ResourceManager::getInstance()->addImageDir(pathName);
     295  printf("HUPS\n");
     296  //ResourceManager::getInstance()->addImageDir(pathName);
    300297}
    301298
     
    351348  if (!dMap.empty())
    352349  {
    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;
    356354    else
    357       this->textures[textureNumber] = Texture();
     355      this->textures[textureNumber] = Texture();*/
    358356  }
    359357  else
  • branches/new_class_id/src/lib/graphics/importer/resource_texture.cc

    r9784 r9785  
    66
    77ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target)
     8    : Resource(&ResourceTexture::type)
    89{
    9   Resource::Pointer* ptr = this->acquireResource(ResourceTexture::type, imageName + ',' + "TEST");
     10  Resource::Pointer* ptr = this->acquireResource(imageName + ',' + "TEST");
    1011
    1112  if (ptr)
     
    1314  else
    1415  {
    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()));
    1619  }
    1720}
     
    2427
    2528
    26 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, TextureData* data)
     29ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resource::KeepLevel& keepLevel, const TextureData::Pointer& data)
    2730    : Resource::Pointer(loadString, keepLevel) , pointer(data)
    28 {
    29 }
     31{}
    3032
    3133
  • branches/new_class_id/src/lib/graphics/importer/resource_texture.h

    r9784 r9785  
    1414class ResourceTexture : public Texture, public Resource
    1515{
     16public:
    1617  ResourceTexture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    1718
    1819
    1920private:
    20   class TextureResourcePointer : public Resource::Pointer
     21class TextureResourcePointer : public Resource::Pointer
    2122  {
    2223  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);
    2425    inline const TextureData::Pointer& ptr() const { return pointer; }
    2526  private:
     
    2728  };
    2829
    29   private:
    30     static Resource::Type type;
     30private:
     31  static Resource::Type type;
    3132};
    3233
  • branches/new_class_id/src/lib/util/filesys/directory.cc

    r9719 r9785  
    212212
    213213}
     214
     215File 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  
    7777};
    7878
     79File operator+(const Directory& dir, const File& file);
     80
    7981#endif /* __DIRECTORY_H_ */
    8082
  • branches/new_class_id/src/lib/util/loading/resource.cc

    r9784 r9785  
    1717
    1818#include "resource.h"
     19#include "filesys/file.h"
    1920
    2021ObjectListDefinition(Resource);
     22
     23
     24std::vector<Resource::Type*>    Resource::_resourceTypes;
     25
     26//! GLOBALS
     27Directory Resource::_mainGlobalPath;
     28std::vector<Directory>        Resource::_globalPaths;
    2129
    2230
     
    2432 * standard constructor
    2533*/
    26 Resource::Resource ()
    27     : _pointer(NULL)
     34Resource::Resource (Resource::Type* type)
     35    : _pointer(NULL), _type(type)
    2836{
    2937  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  }
    3044
    3145}
     
    4054
    4155
     56std::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();
    4262
    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
     69Resource::Pointer* Resource::acquireResource(const std::string& loadString)
    4470{
    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()];
    5172
    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;
    5576
    5677  return NULL;
    5778}
     79
     80void Resource::setMainGlobalPath(const Directory& directory)
     81{
     82  Resource::_mainGlobalPath = directory;
     83  Resource::_mainGlobalPath.open();
     84}
     85
     86void 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
     95void Resource::addResource(Resource::Pointer* pointer)
     96{}
     97
     98
     99
     100
    58101
    59102
     
    68111  _keepLevelName[level] = name;
    69112}
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123Resource::Pointer::Pointer(const std::string& loadString, const Resource::KeepLevel& keeplevel)
     124{
     125}
     126
     127void Resource::Type::setID(int id)
     128{
     129  this->_id = id;
     130}
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9784 r9785  
    1212#include <vector>
    1313#include <set>
     14
     15#include "filesys/directory.h"
    1416
    1517//! A Resource is an Object, that can be loaded from Disk
     
    4850
    4951    void setID(int id);
     52    void addResource(Resource* resource);
    5053
    5154  private:
     
    7376
    7477public:
    75   Resource();
     78  Resource(Resource::Type* type);
    7679  virtual ~Resource();
    7780
    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
    8091
    8192protected:
    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);
    8395
    8496private:
    8597  Resource::Pointer*       _pointer;                //!< Virtual Pointer to the ResourceData.
     98  Resource::Type*          _type;                   //!< Type of the Resource.
    8699
    87100
     
    89102
    90103  //! GLOBALS
    91   static std::string                     _mainGlobalPath;
    92   static std::vector<std::string>        _globalPaths;
     104  static Directory                       _mainGlobalPath;
     105  static std::vector<Directory>          _globalPaths;
    93106};
    94107
  • branches/new_class_id/src/world_entities/WorldEntities.am

    r9761 r9785  
    9191                world_entities/weather_effects/atmospheric_engine.cc \
    9292                world_entities/weather_effects/weather_effect.cc \
     93                world_entities/weather_effects/cloud_effect.cc \
    9394                world_entities/weather_effects/sun_effect.cc \
    9495                world_entities/weather_effects/fog_effect.cc \
     
    9697                world_entities/weather_effects/rain_effect.cc \
    9798                world_entities/weather_effects/snow_effect.cc \
    98                 world_entities/weather_effects/cloud_effect.cc \
    9999                world_entities/weather_effects/lightning_effect.cc \
    100100                world_entities/weather_effects/lense_flare.cc
Note: See TracChangeset for help on using the changeset viewer.