Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9823 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Sep 25, 2006, 11:28:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: now it should also be possible, to cache the resources, by suppling a LoadString.
This is vital to loading Resources, when you only know the TypeName and a LoadString, but not the c++-type and the LoadParameters as is the case when loading over the internet.

Location:
branches/new_class_id/src/lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/importer/material.cc

    r9785 r9823  
    9999
    100100const Material* Material::selectedMaterial = NULL;
    101 
    102 
    103 /// TODO FIX THIS
    104 // Material& Material::operator=(const Material& m)
    105 // {
    106 //   this->setIllum(m.illumModel);
    107 //   this->setDiffuse(m.diffuse[0],m.diffuse[1],m.diffuse[2]);
    108 //   this->setAmbient(m.ambient[0],m.ambient[1],m.ambient[2]);
    109 //   this->setSpecular(m.specular[0],m.specular[1],m.specular[2]);
    110 //   this->setShininess(m.shininess);
    111 //   this->setTransparency(m.transparency);
    112 //
    113 //   if (this->diffuseTexture != NULL)
    114 //     ResourceManager::getInstance()->unload(this->diffuseTexture);
    115 //   if (m.diffuseTexture != NULL)
    116 //     this->diffuseTexture = (Texture*)ResourceManager::getInstance()->copy(m.diffuseTexture);
    117 //   this->ambientTexture = NULL; /// FIXME
    118 //   this->specularTexture = NULL; /// FIXME
    119 //
    120 //   this->setName(m.getName());
    121 // }
    122 
    123 
    124101
    125102/**
     
    296273  //ResourceManager::getInstance()->addImageDir(pathName);
    297274}
    298 
    299 // MAPPING //
    300 
    301275
    302276/**
  • branches/new_class_id/src/lib/graphics/importer/material.h

    r9718 r9823  
    2929  virtual ~Material ();
    3030
     31  Material& operator=(const Material& material);
     32
    3133  void loadParams(const TiXmlElement* root);
    32 
    33   Material& operator=(const Material& material);
    3434
    3535  bool select () const;
  • branches/new_class_id/src/lib/graphics/importer/resource_texture.cc

    r9793 r9823  
    11
    22#include "resource_texture.h"
     3#include "substring.h"
     4#include "multi_type.h"
    35#include "debug.h"
    46
     
    2325}
    2426
     27ResourceTexture ResourceTexture::createFromString(const std::string& loadString)
     28{
     29  SubString loadValues(loadString, ',');
     30  std::string imageName;
     31  GLenum target = GL_TEXTURE_2D;
     32  if (loadValues.size() > 0)
     33    imageName = loadValues[0];
     34  if (loadValues.size() > 1)
     35    target = (GLenum)MultiType(loadValues[2]).getInt();
    2536
    26 Resources::Type ResourceTexture::type("Texture");
     37  return ResourceTexture(imageName, target);
     38}
     39
     40
     41
     42Resources::tType<ResourceTexture> ResourceTexture::type("Texture");
    2743
    2844
  • branches/new_class_id/src/lib/graphics/importer/resource_texture.h

    r9800 r9823  
    1616public:
    1717  ResourceTexture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    18 
     18  static ResourceTexture createFromString(const std::string& loadString);
    1919
    2020private:
     
    2424    TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data);
    2525    inline const TextureData::Pointer& ptr() const { return pointer; }
    26   private:
     26private:
    2727    TextureData::Pointer pointer;
    2828  };
    2929
    3030private:
    31   static Resources::Type type;
     31  static Resources::tType<ResourceTexture> type;
    3232};
    3333
  • branches/new_class_id/src/lib/graphics/resource_shader.cc

    r9820 r9823  
    22#include "resource_shader.h"
    33#include "debug.h"
    4 
     4#include "substring.h"
    55
    66ResourceShader::ResourceShader(const std::string& vertexShaderName, const std::string& fragmentShaderName)
    77    : NewResource(&ResourceShader::type)
    88{
    9   Resources::StorePointer* ptr = this->acquireResource(vertexShaderName +'|'+fragmentShaderName);
     9  Resources::StorePointer* ptr = this->acquireResource(vertexShaderName +','+fragmentShaderName);
    1010
    1111  if (ptr)
     
    2323
    2424    this->Shader::load(vertexFileName, fragmentFileName);
    25     this->NewResource::addResource(new ResourceShader::ShaderResourcePointer(vertexShaderName+'|'+fragmentShaderName, Resources::KeepLevel(0), this->Shader::dataPointer()));
     25    this->NewResource::addResource(new ResourceShader::ShaderResourcePointer(vertexShaderName+','+fragmentShaderName, Resources::KeepLevel(0), this->Shader::dataPointer()));
    2626  }
    2727}
    2828
     29ResourceShader ResourceShader::createFromString(const std::string& loadString)
     30{
     31  std::string vertexShaderName;
     32  std::string fragmentShaderName;
    2933
    30 Resources::Type ResourceShader::type("Shader");
     34  SubString shaderNames(loadString, ',');
     35  if (shaderNames.size() > 0)
     36    vertexShaderName = shaderNames[0];
     37  if (shaderNames.size() > 1)
     38    fragmentShaderName = shaderNames[1];
    3139
     40  return ResourceShader(vertexShaderName, fragmentShaderName);
     41}
    3242
    33 
    34 
     43Resources::tType<ResourceShader> ResourceShader::type("Shader");
    3544
    3645ResourceShader::ShaderResourcePointer::ShaderResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const ShaderData::Pointer& data)
  • branches/new_class_id/src/lib/graphics/resource_shader.h

    r9820 r9823  
    1616public:
    1717  ResourceShader(const std::string& vertexShaderName, const std::string& fragmentShaderName);
    18 
     18  static ResourceShader createFromString(const std::string& loadString);
    1919
    2020private:
     
    2929
    3030private:
    31   static Resources::Type type;
     31  static Resources::tType<ResourceShader> type;
    3232};
    3333
  • branches/new_class_id/src/lib/sound/resource_sound_buffer.cc

    r9811 r9823  
    99
    1010  ResourceSoundBuffer::ResourceSoundBuffer(const std::string& soundName)
    11   : SoundBuffer(), NewResource(&ResourceSoundBuffer::type)
     11      : SoundBuffer(), NewResource(&ResourceSoundBuffer::type)
    1212  {
    1313    this->registerObject(this, ResourceSoundBuffer::_objectList);
     
    3030
    3131
    32   Resources::Type ResourceSoundBuffer::type("SoundBuffer");
     32  Resources::tType<ResourceSoundBuffer> ResourceSoundBuffer::type("SoundBuffer");
    3333
    3434  ResourceSoundBuffer::SoundBufferResourcePointer::SoundBufferResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const SoundBufferData::Pointer& data)
    3535      : Resources::StorePointer(loadString, keepLevel) , pointer(data)
    36 {}
    37 }
     36{}}
  • branches/new_class_id/src/lib/sound/resource_sound_buffer.h

    r9811 r9823  
    1818  public:
    1919    ResourceSoundBuffer(const std::string& soundName);
     20    static ResourceSoundBuffer createFromString(const std::string& loadString) { return ResourceSoundBuffer(loadString); };
    2021
    2122  private:
     
    3031
    3132  private:
    32     static Resources::Type type;
     33    static Resources::tType<ResourceSoundBuffer> type;
    3334  };
    3435}
  • branches/new_class_id/src/lib/util/filesys/directory.cc

    r9785 r9823  
    215215File operator+(const Directory& dir, const File& file)
    216216{
    217    return File(dir.name() + '/' + file.name());
    218 }
     217  return File(dir.name() + Directory::delimiter + file.name());
     218}
  • branches/new_class_id/src/lib/util/filesys/directory.h

    r9785 r9823  
    6565  const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; };
    6666  /** @returns a formated string containing the FileName, prepended with the directory-Name */
    67   std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + "/" + _fileNames[fileNumber]; };
     67  std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + Directory::delimiter + _fileNames[fileNumber]; };
    6868  /** @returns a File pointing to the File @param fileNumber the fileNumber (must not bigger than fileCount()) */
    6969  File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); };
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9801 r9823  
    6161  public:
    6262    Type(const std::string& typeName);
    63     ~Type();
     63    virtual ~Type();
    6464    /** @returns true if the names match @param resourceName the Name to compare. @brief compare the Type with a Name */
    6565    bool operator==(const std::string& resourceName) const { return this->_typeName == resourceName; };
     
    8282    const std::vector<Resources::StorePointer*>& storedResources() const { return _storedResources; };
    8383
     84    virtual void createFromString(const std::string& loadString) = 0;
     85
    8486    void setID(int id);
    8587    void addResource(Resources::StorePointer* resource);
     
    9597
    9698    std::vector<Resources::StorePointer*> _storedResources;   //!< An array of all the stored Resources.
     99  };
     100
     101  template<class T> class tType : public Type
     102  {
     103  public:
     104    tType(const std::string& typeName) : Type(typeName) {};
     105    virtual void createFromString(const std::string& loadString) { T::createFromString(loadString); }
    97106  };
    98107
Note: See TracChangeset for help on using the changeset viewer.