Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Sep 1, 2006, 11:56:54 PM (18 years ago)
Author:
bensch
Message:

more thoughts on Resources, and soon going to adapt… i think i've got a clue :)

Location:
branches/new_class_id/src
Files:
20 edited

Legend:

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

    r9715 r9718  
    324324 * @param textureNumber The Texture-Number from 0 to GL_MAX_TEXTURE_UNITS
    325325 */
    326 void Material::setDiffuseMap(const TextureDataPointer& textureDataPointer, unsigned int textureNumber)
     326void Material::setDiffuseMap(const TextureData::Pointer& textureDataPointer, unsigned int textureNumber)
    327327{
    328328  assert(textureNumber < Material::getMaxTextureUnits());
  • branches/new_class_id/src/lib/graphics/importer/material.h

    r9715 r9718  
    5454  // MAPPING //
    5555  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
    56   void setDiffuseMap(const TextureDataPointer& texturePointer, unsigned int textureNumber = 0);
     56  void setDiffuseMap(const TextureData::Pointer& texturePointer, unsigned int textureNumber = 0);
    5757  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    5858  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
  • branches/new_class_id/src/lib/graphics/importer/texture.cc

    r9715 r9718  
    151151  this->registerObject(this, Texture::_objectList);
    152152
    153   this->data = TextureDataPointer(new TextureData());
     153  this->data = TextureData::Pointer(new TextureData());
    154154
    155155  this->priority = 0.5;
     
    176176}
    177177
    178 Texture& Texture::operator=(const TextureDataPointer& textureDataPointer)
     178Texture& Texture::operator=(const TextureData::Pointer& textureDataPointer)
    179179{
    180180  this->data = textureDataPointer;
  • branches/new_class_id/src/lib/graphics/importer/texture.h

    r9715 r9718  
    2929
    3030  Texture& operator=(const Texture& texture);
    31   Texture& operator=(const TextureDataPointer& textureDataPointer);
     31  Texture& operator=(const TextureData::Pointer& textureDataPointer);
    3232
    3333  virtual ~Texture();
     
    6363
    6464private:
    65   TextureDataPointer            data;               //!< The TextureData
     65  TextureData::Pointer          data;               //!< The TextureData
    6666  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
    6767
  • branches/new_class_id/src/lib/graphics/importer/texture_data.h

    r8761 r9718  
    1818class TextureData
    1919{
     20  public:
     21    typedef CountPointer<TextureData> Pointer;
    2022  public:
    2123    TextureData();
     
    4345};
    4446
    45 typedef CountPointer<TextureData> TextureDataPointer;
    46 
    4747#endif /* _TEXTURE_DATA_H */
  • branches/new_class_id/src/lib/graphics/text_engine/font.cc

    r9715 r9718  
    139139}
    140140
    141 FontDataPointer Font::defaultFontData(NULL);
     141FontData::Pointer Font::defaultFontData(NULL);
    142142
    143143/**
     
    147147{
    148148  // temporarily create a Font.
    149   Font::defaultFontData = FontDataPointer(new FontData);
     149  Font::defaultFontData = FontData::Pointer(new FontData);
    150150  // apply the Data.
    151151  Font::defaultFontData = Font(font_xpm).data;
     
    160160bool Font::loadFontFromTTF(const std::string& fontFile, unsigned int renderSize)
    161161{
    162   this->data = FontDataPointer (new FontData());
     162  this->data = FontData::Pointer (new FontData());
    163163  bool retVal = this->data->loadFontFromTTF(fontFile, renderSize);
    164164  if (!retVal)
     
    175175bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
    176176{
    177   this->data = FontDataPointer (new FontData());
     177  this->data = FontData::Pointer (new FontData());
    178178  bool retVal = this->data->loadFontFromSDL_Surface(surface);
    179179  if (!retVal)
     
    197197
    198198
    199 void Font::setTexture(const TextureDataPointer& texDataPointer)
     199void Font::setTexture(const TextureData::Pointer& texDataPointer)
    200200{
    201201  this->setDiffuseMap(texDataPointer);
  • branches/new_class_id/src/lib/graphics/text_engine/font.h

    r9715 r9718  
    2020{
    2121  ObjectListDeclaration(Font);
    22 
     22public:
     23  typedef FontData::Glyph Glyph;
    2324public:
    2425  Font();
     
    4041
    4142  /** @returns a Pointer to the Array of Glyphs */
    42   inline Glyph** getGlyphArray() const { return this->data->getGlyphArray(); };
     43  inline const Glyph* const * const getGlyphArray() const { return this->data->getGlyphArray(); };
    4344
    4445  inline int getMaxHeight() const { return data->getMaxHeight(); };
     
    5556  static void initDefaultFont();
    5657
    57   void setTexture(const TextureDataPointer& texDataPointer);
     58  void setTexture(const TextureData::Pointer& texDataPointer);
    5859
    5960private:
    60   FontDataPointer           data;                //!< A Data-Pointer to a Font.
     61  FontData::Pointer         data;                //!< A Data-Pointer to a Font.
    6162
    62   static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
     63  static FontData::Pointer  defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
    6364};
    6465
  • branches/new_class_id/src/lib/graphics/text_engine/font_data.h

    r8768 r9718  
    2626#define FONT_DEFAULT_RENDER_SIZE     50            //!< At what Resolution to render fonts.
    2727
     28class FontData
     29{
     30
     31
     32public:
     33
    2834//! A struct for handling glyphs
    2935/**
    3036 * a Glyph is one letter of a certain font
    3137 */
    32 struct Glyph
    33 {
     38  struct Glyph
     39  {
    3440  // Glyph-specific (size and so on)
    35   Uint16   character;         //!< The character
    36   float    minX;              //!< The minimum distance from the origin in X
    37   float    maxX;              //!< The maximum distance from the origin in X
    38   float    minY;              //!< The minimum distance from the origin in Y
    39   float    maxY;              //!< The maximum distance from the origin in Y
    40   float    width;             //!< The width of the Glyph
    41   float    height;            //!< The height of the Glyph
    42   float    bearingX;          //!< How much is right of the Origin
    43   float    bearingY;          //!< How much is above the Origin
    44   float    advance;           //!< How big a Glyph would be in monospace-mode
     41    Uint16   character;         //!< The character
     42    float    minX;              //!< The minimum distance from the origin in X
     43    float    maxX;              //!< The maximum distance from the origin in X
     44    float    minY;              //!< The minimum distance from the origin in Y
     45    float    maxY;              //!< The maximum distance from the origin in Y
     46    float    width;             //!< The width of the Glyph
     47    float    height;            //!< The height of the Glyph
     48    float    bearingX;          //!< How much is right of the Origin
     49    float    bearingY;          //!< How much is above the Origin
     50    float    advance;           //!< How big a Glyph would be in monospace-mode
    4551
    46   GLfloat texCoord[4];        //!< Texture coordinates: 0:left, 1:right, 2: top, 3: bottom.
    47 };
     52    GLfloat texCoord[4];        //!< Texture coordinates: 0:left, 1:right, 2: top, 3: bottom.
     53  };
    4854
    49 
    50 class FontData
    51 {
     55  typedef CountPointer<FontData> Pointer;
    5256public:
    5357  FontData();
     
    6165
    6266  /** @returns a Pointer to the Array of Glyphs */
    63   inline Glyph** getGlyphArray() const { return this->glyphArray; };
     67  inline const Glyph* const * const getGlyphArray() const { return this->glyphArray; };
    6468
    6569  int getMaxHeight() const { return maxHeight; };
     
    6872
    6973  /** @returns the Texture-Data of this FontData */
    70   const TextureDataPointer& textureData() const { return texData; };
     74  const TextureData::Pointer& textureData() const { return texData; };
    7175
    7276  bool rebuild() { return texData->rebuild(); };
     
    9195  int           maxDescent;          //!< Max Desent of the Font.
    9296
    93   TextureDataPointer   texData;
     97  TextureData::Pointer   texData;
    9498};
    9599
    96 typedef CountPointer<FontData> FontDataPointer;
    97 
    98100#endif /* _FONT_DATA_H */
  • branches/new_class_id/src/lib/graphics/text_engine/limited_width_text.cc

    r9715 r9718  
    7676  glRotatef(this->getAbsDir2D(), 0, 0, 1);
    7777
    78   Glyph* tmpGlyph;
     78  const Font::Glyph* tmpGlyph;
    7979  float posX = 0.0f;
    8080  glBegin(GL_QUADS);
  • branches/new_class_id/src/lib/graphics/text_engine/multi_line_text.cc

    r9715 r9718  
    8080  glRotatef(this->getAbsDir2D(), 0, 0, 1);
    8181
    82   Glyph* tmpGlyph;
     82  const Font::Glyph* tmpGlyph;
    8383  float posX = 0.0f;
    8484  float posY = 0.0f;
  • branches/new_class_id/src/lib/graphics/text_engine/text.cc

    r9715 r9718  
    235235  glRotatef(this->getAbsDir2D(), 0, 0, 1);
    236236
    237   Glyph* tmpGlyph;
     237  const Font::Glyph* tmpGlyph;
    238238  float posX = 0.0f;
    239239  glBegin(GL_QUADS);
  • branches/new_class_id/src/lib/lang/base_object.cc

    r9715 r9718  
    2828 */
    2929BaseObject::BaseObject(const std::string& objectName)
    30   : _leafClassID(&BaseObject::classID())
    3130{
    3231  this->className = "BaseObject";
  • branches/new_class_id/src/lib/lang/base_object.h

    r9716 r9718  
    4848  inline const std::string& getClassName() const { return _classes.front()._objectList->name(); };
    4949
    50   inline const ClassID& getClassID() const { return *_leafClassID; }
     50  inline const ClassID& getClassID() const { return _classes.front()._objectList->identity(); }
    5151  /** @returns the ID of the Topmost object of the ClassStack */
    52   inline const int& getLeafClassID() const { return _leafClassID->id(); }
     52  inline const int& getLeafClassID() const { return _classes.front()._objectList->identity().id(); }
    5353
    5454  bool isA(const ObjectListBase& objectList) const;
     
    8989  std::string                         className;    //!< the name of the class
    9090  ClassList                           _classes;     //!< All Classes this object is part of.
    91   const ClassID*                       _leafClassID;  //!< Topmost ClassID.
    9291};
    9392
     
    105104inline void BaseObject::registerObject(T* object, ObjectList<T>& objectList)
    106105{
    107   this->_leafClassID = &objectList.identity();
    108106  this->_classes.push_front(ClassEntry(&objectList, objectList.registerObject(object)));
    109107}
  • branches/new_class_id/src/lib/lang/object_list.h

    r9716 r9718  
    7272  virtual void                          getBaseObjectList(base_list* list) const = 0;
    7373
    74   static const ClassID&              retrieveIdentity(int id);
    75   static const ClassID&              retrieveIdentity(const std::string& name);
    76 
    77   static const ObjectListBase* const getObjectList(int classID);
    78   static const ObjectListBase* const getObjectList(const std::string& className);
    79   static const ObjectListBase* const getObjectList(const ClassID& classID);
     74  static const ClassID&                 retrieveIdentity(int id);
     75  static const ClassID&                 retrieveIdentity(const std::string& name);
     76
     77  static const ObjectListBase* const    getObjectList(int classID);
     78  static const ObjectListBase* const    getObjectList(const std::string& className);
     79  static const ObjectListBase* const    getObjectList(const ClassID& classID);
    8080
    8181  static BaseObject*                    getBaseObject(int classID, const std::string& objectName);
     
    115115
    116116private:
    117   int                           _id;
     117  int                           _id;                //!< The Unique ID of the Class.
    118118  const std::string             _name;              //!< The Name of the Class.
    119   ClassID                    _identity;          //!< The Identity of the Class. (equal to _id and _name)
     119  ClassID                       _identity;          //!< The Identity of the Class. (equal to _id and _name)
    120120
    121121private:
     
    169169{
    170170public:
    171   typedef std::list<T*>                  list;
    172   typedef typename list::iterator        iterator;
    173   typedef typename list::const_iterator  const_iterator;
    174 
    175 
     171  typedef std::list<T*>                  list;             //!< The list of Type T* (used for Objects in this ObjectList)
     172  typedef typename list::iterator        iterator;         //!< The iterator for the List of type T (use with ObjectList<Type>::iterator)
     173  typedef typename list::const_iterator  const_iterator;   //!< A constant iterator for the List of type T (use with ObjectList<Type>::const_iterator)
     174
     175
     176  //! An iterator to store Objects in the BaseObject, and remove Objects fast.
    176177class Iterator : public ObjectListBase::IteratorBase
    177178  {
    178179  public:
    179     Iterator(iterator it) { _it = it; }
     180    /** @brief creates an Iterator fast. @param it the Iterator. */
     181    inline Iterator(iterator it) { _it = it; }
     182    /** @returns the Iterator */
    180183    inline iterator& it() { return _it; }
    181     typename ObjectList::iterator _it;
     184  private:
     185    typename ObjectList::iterator _it;  //!< Stored Iterator
    182186  };
    183187
     
    210214
    211215
    212   ObjectListBase::IteratorBase*   registerObject(T* object);
     216  ObjectListBase::IteratorBase*      registerObject(T* object);
    213217  virtual void                       unregisterObject(IteratorBase* iterator);
    214218
     
    288292 */
    289293template <class T>
    290     bool ObjectList<T>::exists(const T* const object) const
     294bool ObjectList<T>::exists(const T* const object) const
    291295{
    292296  return (std::find(_objects.begin(), _objects.end(), object) != _objects.end());
  • branches/new_class_id/src/lib/util/loading/resource.cc

    r9406 r9718  
    1818#include "resource.h"
    1919
    20 
     20ObjectListDefinition(Resource);
    2121
    2222
     
    2626Resource::Resource (const std::string& fileName)
    2727{
    28 //   this->setClassID(CL_RESOURCE, "Resource");
     28  this->registerObject(this, Resource::_objectList);
    2929
    3030}
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9715 r9718  
    1919class Resource : virtual public BaseObject
    2020{
     21  ObjectListDeclaration(Resource);
    2122public:
    22   class Priority
     23  class KeepLevel
    2324  {
    2425  public:
    25     void setPriorityName(unsigned int level, const std::string& name)
     26    void setKeepLevelName(unsigned int level, const std::string& name)
    2627    {
    27       if (_priorityName.size() <= level)
    28         _priorityName.resize(level+1);
    29       _priorityName[level] = name;
     28      if (_keepLevelName.size() <= level)
     29        _keepLevelName.resize(level+1);
     30      _keepLevelName[level] = name;
    3031    }
    3132  private:
    32     std::vector<std::string>     _priorityName;
     33    std::vector<std::string>     _keepLevelName;
    3334  };
    3435
     
    4647    std::vector<std::string>      _resourceSubPaths;
    4748    std::vector<std::string>      _fileExtensions;
    48 
    4949  };
    50 
    5150
    5251public:
     
    6059
    6160private:
     61  std::string              _fileName;
     62  MultiType                _parameters[3];          //!< The Parameters given to this Resource.
     63  Resource::KeepLevel      _keepLevel;              //!< The Priority of this resource. (can only be increased, so noone else will delete this)
    6264
    63   static std::vector<std::vector<std::string> >     _resourcePaths;
    6465
    65   static std::vector<std::string>                   _resourceClassNames;
     66  static std::vector<Resource::Type>     _resourceTypes;
    6667
    6768  //! GLOBALS
    68   static std::string                                _mainGlobalPath;
    69   static std::vector<std::string>                   _globalPaths;
    70 
    71   std::string       fileName;
    72 
    73   unsigned int      referenceCount;    //!< How many times this Resource has been loaded.
    74   /// TODO REMOVE THIS:   ResourceType      type;              //!< ResourceType of this Resource.
    75   Resource::Priority  prio;              //!< The Priority of this resource. (can only be increased, so noone else will delete this)
    76 
    77   MultiType         param[3];          //!< The Parameters given to this Resource.
     69  static std::string                     _mainGlobalPath;
     70  static std::vector<std::string>        _globalPaths;
    7871};
    7972
  • branches/new_class_id/src/proto/proto_class.cc

    r9406 r9718  
    1717
    1818#include "proto_class.h"
     19ObjectListDefinition(ProtoClass);
    1920
    2021
     
    2728ProtoClass::ProtoClass ()
    2829{
    29    this->setClassID(CL_PROTO_ID, "ProtoClass");
     30  this->registerObject(this, ProtoClass::_objectList);
    3031
    3132   /* If you make a new class, what is most probably the case when you write this file
    3233      don't forget to:
    3334       1. Add the new file new_class.cc to the ./src/Makefile.am
    34        2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
    3535
    3636      Advanced Topics:
  • branches/new_class_id/src/proto/proto_class.h

    r4838 r9718  
    1515//! A class for ...
    1616class ProtoClass : public BaseObject {
    17 
     17  ObjectListDeclaration(ProtoClass);
    1818 public:
    1919  ProtoClass();
  • branches/new_class_id/src/proto/proto_singleton.cc

    r9406 r9718  
    1717
    1818#include "proto_singleton.h"
    19 
    20 
    21 
     19ObjectListDefinition(ProtoSingleton);
    2220
    2321/**
     
    2624ProtoSingleton::ProtoSingleton ()
    2725{
    28    this->setClassID(CL_PROTO_ID, "ProtoSingleton");
    29    this->setName("ProtoSingleton");
    30 
    31    /* If you make a new class, what is most probably the case when you write this file
    32       don't forget to:
    33        1. Add the new file new_class.cc to the ./src/Makefile.am
    34        2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
    35    !!!!!!!!!! IMPORTANT FOR SINGLETON !!!!!!!!!!!!!!!!
    36         3. SingleTon MUST be CL_NEW_CLASS = 0x00000fxx
    37 
    38       Advanced Topics:
    39       - if you want to let your object be managed via the ObjectManager make sure to read
    40         the object_manager.h header comments. You will use this most certanly only if you
    41         make many objects of your class, like a weapon bullet.
    42    */
     26  this->registerObject(this, ProtoSingleton::_objectList);
     27  this->setName("ProtoSingleton");
    4328}
    4429
  • branches/new_class_id/src/proto/proto_singleton.h

    r5405 r9718  
    1313//! A default singleton class.
    1414class ProtoSingleton : public BaseObject {
     15  ObjectListDeclaration(ProtoSingleton);
     16
    1517
    1618 public:
Note: See TracChangeset for help on using the changeset viewer.