Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9685 in orxonox.OLD for branches/new_class_id


Ignore:
Timestamp:
Aug 22, 2006, 1:16:23 PM (18 years ago)
Author:
bensch
Message:

adapted many classes to the new ClassID System, now comes the hard part… Scripting… then Network… wow this will be so bad :/

Location:
branches/new_class_id/src
Files:
57 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/effects/atmospheric_engine.cc

    r9406 r9685  
    2222#include "util/loading/load_param.h"
    2323#include "util/loading/factory.h"
    24 #include "class_list.h"
    2524
    26 
    27 
     25NewObjectListDefinition(AtmosphericEngine);
    2826
    2927/**
    3028 * @param root The XML-element to load the AtmosphericEngine from
    3129 */
    32 AtmosphericEngine::AtmosphericEngine() {
    33     this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine");
     30AtmosphericEngine::AtmosphericEngine()
     31{
     32  this->registerObject(this, AtmosphericEngine::_objectList);
    3433}
    3534
     
    4342 *  destroys a AtmosphericEngine
    4443 */
    45 AtmosphericEngine::~AtmosphericEngine() {
    46     AtmosphericEngine::singletonRef = NULL;
     44AtmosphericEngine::~AtmosphericEngine()
     45{
     46  AtmosphericEngine::singletonRef = NULL;
    4747
    48     const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    49 
    50     if (weatherEffects != NULL) {
    51         while(!weatherEffects->empty())
    52             delete weatherEffects->front();
    53     }
     48  while(!WeatherEffect::objectList().empty())
     49    delete WeatherEffect::objectList().front();
    5450}
    5551
     
    5753 * @param root The XML-element to load the AtmosphericEngine from
    5854 */
    59 void AtmosphericEngine::loadParams(const TiXmlElement* root) {
    60     LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
    61     LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
     55void AtmosphericEngine::loadParams(const TiXmlElement* root)
     56{
     57  LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
     58  LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
    6259}
    6360
     
    6562 * @param root The XML-element to load WeatherEffects from
    6663 */
    67 void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root) {
    68     LOAD_PARAM_START_CYCLE(root, element);
    69     {
    70         PRINTF(4)("element is: %s\n", element->Value());
    71         // Factory::fabricate(element);
     64void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root)
     65{
     66  LOAD_PARAM_START_CYCLE(root, element);
     67  {
     68    PRINTF(4)("element is: %s\n", element->Value());
     69    // Factory::fabricate(element);
    7270
    73         BaseObject* bo = Factory::fabricate(element);
    74         if( bo == NULL)
    75             PRINTF(0)(" Could not create Element %s\n", element->Value());
    76     }
    77     LOAD_PARAM_END_CYCLE(element);
     71    BaseObject* bo = Factory::fabricate(element);
     72    if( bo == NULL)
     73      PRINTF(0)(" Could not create Element %s\n", element->Value());
     74  }
     75  LOAD_PARAM_END_CYCLE(element);
    7876}
    7977
     
    8179 * @param root The XML-element to load SunEffects from
    8280 */
    83 void AtmosphericEngine::loadSunEffect(const TiXmlElement* root) {
    84     LOAD_PARAM_START_CYCLE(root, element);
    85     {
    86         PRINTF(4)("element is: %s\n", element->Value());
    87     }
    88     LOAD_PARAM_END_CYCLE(element);
     81void AtmosphericEngine::loadSunEffect(const TiXmlElement* root)
     82{
     83  LOAD_PARAM_START_CYCLE(root, element);
     84  {
     85    PRINTF(4)("element is: %s\n", element->Value());
     86  }
     87  LOAD_PARAM_END_CYCLE(element);
    8988}
    9089
     
    9392 * draws the effect, if needed
    9493 */
    95 void AtmosphericEngine::draw() const {
    96     const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    97 
    98     // draw the weather effects
    99     if (weatherEffects != NULL) {
    100         std::list<BaseObject*>::const_iterator it;
    101         for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
    102             dynamic_cast<WeatherEffect*>(*it)->draw();
    103     }
     94void AtmosphericEngine::draw() const
     95{
     96  for (NewObjectList<WeatherEffect>::const_iterator it = WeatherEffect::objectList().begin();
     97       it != WeatherEffect::objectList().end();
     98       ++it)
     99    (*it)->draw();
    104100}
    105101
     
    109105 * ticks the effect if there is any time dependancy
    110106 */
    111 void AtmosphericEngine::tick(float dt) {
    112     const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
     107void AtmosphericEngine::tick(float dt)
     108{
    113109
    114     // tick the weather effects
    115     if (weatherEffects != NULL) {
    116         std::list<BaseObject*>::const_iterator it;
    117         for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) {
    118             /*      printf("%s::%s \n", (*it)->getClassCName(), (*it)->getName());*/
    119             dynamic_cast<WeatherEffect*>(*it)->tick(dt);
    120         }
    121     }
     110  for (NewObjectList<WeatherEffect>::const_iterator it = WeatherEffect::objectList().begin();
     111       it != WeatherEffect::objectList().end();
     112       ++it)
     113    (*it)->tick(dt);
    122114}
  • branches/new_class_id/src/lib/graphics/effects/atmospheric_engine.h

    r7810 r9685  
    11/*!
    22 * @file atmospheric_engine.h
    3  * 
     3 *
    44 */
    55
     
    1414class AtmosphericEngine : public BaseObject
    1515{
     16  NewObjectListDeclaration(AtmosphericEngine);
    1617  public:
    1718    ~AtmosphericEngine();
  • branches/new_class_id/src/lib/graphics/effects/graphics_effect.cc

    r9406 r9685  
    2222#include "util/loading/load_param.h"
    2323
    24 
    25 
    26 
    27 
     24NewObjectListDefinition(GraphicsEffect);
    2825
    2926/**
     
    3330 */
    3431GraphicsEffect::GraphicsEffect(const TiXmlElement* root) {
    35     this->setClassID(CL_GRAPHICS_EFFECT, "GraphicsEffect");
     32  this->registerObject(this, GraphicsEffect::_objectList);
    3633    this->bActivated = false;
    3734}
  • branches/new_class_id/src/lib/graphics/effects/graphics_effect.h

    r8495 r9685  
    1313//! A class that handles GraphicsEffects. The GraphicsEffectManager operates on this.
    1414class GraphicsEffect : public BaseObject {
    15 public:
     15  NewObjectListDeclaration(GraphicsEffect);
     16  public:
    1617    GraphicsEffect(const TiXmlElement* root = NULL);
    1718    virtual ~GraphicsEffect();
  • branches/new_class_id/src/lib/graphics/effects/weather_effect.cc

    r9406 r9685  
    2020#include "util/loading/load_param.h"
    2121
    22 
    23 
    24 
     22NewObjectListDefinition(WeatherEffect);
    2523
    2624/**
     
    2927WeatherEffect::WeatherEffect(const TiXmlElement* root)
    3028{
    31   this->setClassID(CL_WEATHER_EFFECT, "WeatherEffect");
     29  this->registerObject(this, WeatherEffect::_objectList);
    3230  this->bActivated = false;
    3331}
  • branches/new_class_id/src/lib/graphics/effects/weather_effect.h

    r8495 r9685  
    1212class WeatherEffect : public BaseObject
    1313{
     14  NewObjectListDeclaration(WeatherEffect);
     15
    1416  public:
    1517    WeatherEffect(const TiXmlElement* root = NULL);
  • branches/new_class_id/src/lib/graphics/graphics_engine.cc

    r9406 r9685  
    4545#include "util/loading/load_param.h"
    4646#include "util/loading/factory.h"
    47 #include "class_list.h"
    4847
    4948#ifdef __WIN32__
     
    5453SHELL_COMMAND(fps, GraphicsEngine, toggleFPSdisplay);
    5554
     55NewObjectListDefinition(GraphicsEngine);
     56
    5657/**
    5758 * @brief standard constructor
     
    5960GraphicsEngine::GraphicsEngine ()
    6061{
    61   this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");
     62  this->registerObject(this, GraphicsEngine::_objectList);
    6263  this->setName("GraphicsEngine");
    6364
     
    590591
    591592  // tick the graphics effects
    592   if (this->graphicsEffects != NULL || (this->graphicsEffects = ClassList::getList(CL_GRAPHICS_EFFECT)) != NULL)
    593   {
    594     std::list<BaseObject*>::const_iterator it;
    595     for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
    596       dynamic_cast<GraphicsEffect*>(*it)->tick(dt);
    597   }
     593  for (NewObjectList<GraphicsEffect>::const_iterator it = GraphicsEffect::objectList().begin();
     594       it != GraphicsEffect::objectList().end();
     595       ++it)
     596    (*it)->tick(dt);
    598597}
    599598
     
    688687  {
    689688    case EV_VIDEO_RESIZE:
    690       this->resolutionChanged(event.resize);
    691       break;
    692   }
    693 }
     689    this->resolutionChanged(event.resize);
     690    break;
     691  }
     692}
  • branches/new_class_id/src/lib/graphics/graphics_engine.h

    r9406 r9685  
    3030class GraphicsEngine : public EventListener
    3131{
     32  NewObjectListDeclaration(GraphicsEngine);
    3233  public:
    3334    virtual ~GraphicsEngine();
  • branches/new_class_id/src/lib/graphics/importer/material.cc

    r9406 r9685  
    2727#include "util/loading/resource_manager.h"
    2828
     29NewObjectListDefinition(Material);
     30
    2931/**
    3032 * @brief creates a Material.
     
    3335Material::Material (const std::string& mtlName)
    3436{
    35   this->setClassID(CL_MATERIAL, "Material");
     37  this->registerObject(this, Material::_objectList);
    3638
    3739  this->setIllum(3);
  • branches/new_class_id/src/lib/graphics/importer/material.h

    r8761 r9685  
    2424class Material : public BaseObject
    2525{
     26  NewObjectListDeclaration(Material);
    2627public:
    2728  Material (const std::string& mtlName = "");
  • branches/new_class_id/src/lib/graphics/importer/md2/md2Model.cc

    r9406 r9685  
    2222
    2323
    24 
     24NewObjectListDefinition(MD2Model);
    2525
    2626//! the model anorms
     
    7878MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale)
    7979{
    80   this->setClassID(CL_MD2_MODEL, "MD2Model");
     80  this->registerObject(this, MD2Model::_objectList);
    8181  /* this creates the data container via ressource manager */
    8282  if (!modelFileName.empty())
  • branches/new_class_id/src/lib/graphics/importer/md2/md2Model.h

    r9235 r9685  
    149149//! This is a MD2 Model class
    150150class MD2Model : public InteractiveModel {
    151 
     151  NewObjectListDeclaration(MD2Model);
    152152public:
    153153  MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
  • branches/new_class_id/src/lib/graphics/importer/media_container.cc

    r8316 r9685  
    3030#include "debug.h"
    3131
     32NewObjectListDefinition(MediaContainer);
    3233
    3334/**
     
    3738{
    3839  // set the class id for the base object
    39   this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
     40  this->registerObject(this, MediaContainer::_objectList);
    4041
    4142  fps = 0;
  • branches/new_class_id/src/lib/graphics/importer/media_container.h

    r7221 r9685  
    2424class MediaContainer : public TextureSequence
    2525{
    26 
     26  NewObjectListDeclaration(MediaContainer);
    2727private:
    2828
  • branches/new_class_id/src/lib/graphics/importer/movie_player.cc

    r7221 r9685  
    3030#include "debug.h"
    3131
     32NewObjectListDefinition(MoviePlayer);
    3233
    3334MoviePlayer::MoviePlayer(const std::string& filename)
    3435{
    3536  // set the class id for the base object
    36   this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
    37 
     37  this->registerObject(this, MoviePlayer::_objectList);
    3838  status = STOP;
    3939  timer = 0;
  • branches/new_class_id/src/lib/graphics/importer/movie_player.h

    r7221 r9685  
    3131class MoviePlayer : public BaseObject
    3232{
     33  NewObjectListDeclaration(MoviePlayer);
    3334
    3435private:
  • branches/new_class_id/src/lib/graphics/importer/texture.cc

    r9406 r9685  
    6464#endif
    6565
    66 
     66NewObjectListDefinition(Texture);
    6767
    6868/**
     
    8686    : data(texture.data)
    8787{
    88   this->setClassID(CL_TEXTURE, "Texture");
     88  this->registerObject(this, Texture::_objectList);
    8989  this->priority = 0.5;
    9090}
     
    149149void Texture::init()
    150150{
    151   this->setClassID(CL_TEXTURE, "Texture");
     151  this->registerObject(this, Texture::_objectList);
    152152
    153153  this->data = TextureDataPointer(new TextureData());
  • branches/new_class_id/src/lib/graphics/importer/texture.h

    r8761 r9685  
    2020class Texture : public BaseObject
    2121{
     22  NewObjectListDeclaration(Texture);
    2223public:
    2324  Texture();
  • branches/new_class_id/src/lib/graphics/importer/texture_sequence.cc

    r9406 r9685  
    2828#endif
    2929
     30NewObjectListDefinition(TextureSequence);
     31
    3032/**
    3133 * @brief Constructor for a Texture
     
    3335TextureSequence::TextureSequence(unsigned int count, ...)
    3436{
    35   this->setClassID(CL_TEXTURE_SEQUENCE, "TextureSequence");
     37  this->registerObject(this, TextureSequence::_objectList);
    3638
    3739  va_list textureNameList;
     
    5456TextureSequence::TextureSequence(const std::vector<std::string>& textureNames, const std::string& prependFolder)
    5557{
    56   this->setClassID(CL_TEXTURE_SEQUENCE, "TextureSequence");
     58  this->registerObject(this, TextureSequence::_objectList);
    5759  this->loadImageSeries(textureNames, prependFolder);
    5860}
  • branches/new_class_id/src/lib/graphics/importer/texture_sequence.h

    r8324 r9685  
    1515class TextureSequence : public Texture
    1616{
     17  NewObjectListDeclaration(TextureSequence);
    1718  public:
    1819    TextureSequence(unsigned int count = 0, ...);
  • branches/new_class_id/src/lib/graphics/light.cc

    r8742 r9685  
    2727#include "debug.h"
    2828
     29#include "class_id.h"
     30
    2931CREATE_FACTORY(Light, CL_LIGHT);
     32NewObjectListDefinitionID(Light, CL_LIGHT);
    3033
    3134//! Definition of the Lights and their Names
     
    5154  PRINTF(4)("initializing Light number %d.\n", this->lightNumber);
    5255
     56  this->registerObject(this, Light::_objectList);
     57
    5358  this->lightNumber = LightManager::getInstance()->registerLight(this);
    5459
    55   this->setClassID(CL_LIGHT, "Light");
    5660  char tmpName[10];
    5761  sprintf(tmpName, "Light[%d]", this->lightNumber);
     
    211215** LIGHT-MANAGER **
    212216******************/
     217NewObjectListDefinition(LightManager);
    213218/**
    214219 *  standard constructor for a Light
     
    216221LightManager::LightManager ()
    217222{
    218   this->setClassID(CL_LIGHT_MANAGER, "LightManager");
     223  this->registerObject(this, LightManager::_objectList);
    219224
    220225  glEnable (GL_LIGHTING);
  • branches/new_class_id/src/lib/graphics/light.h

    r8255 r9685  
    2525class Light : public PNode
    2626{
    27         public:
    28                 Light(const TiXmlElement* root = NULL);
    29                 virtual ~Light();
    30                
    31                 virtual void loadParams(const TiXmlElement* root);
    32                
    33                 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    34                 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
    35                 void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
    36                 void setSpotDirection(const Vector& direction);
    37                 void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); };
    38                 void setSpotCutoff(GLfloat cutoff);
    39                
    40                 /** @returns the lightNumber*/
    41                 int getLightNumber() const {return this->lightNumber;}
    42                
    43                 virtual void draw() const;
    44                
    45                 void debug() const;
    46        
    47         // attributes
    48         private:
    49                 int              lightNumber;               //!< The number of this Light.
    50                 GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
    51                 GLfloat          specularColor[4];          //!< The specular Color of this Light.
    52                 float            constantAttenuation;       //!< The Factor of the the Constant Attenuation.
    53                 float            linearAttenuation;         //!< The Factor of the the Linear Attenuation.
    54                 float            quadraticAttenuation;      //!< The Factor of the the Quadratic Attenuation.
    55                 GLfloat          spotDirection[4];          //!< The direction of the Spot Light.
    56                 GLfloat          spotCutoff;                //!< The cutoff Angle of the Light Source
     27  NewObjectListDeclaration(Light);
     28public:
     29  Light(const TiXmlElement* root = NULL);
     30  virtual ~Light();
     31
     32  virtual void loadParams(const TiXmlElement* root);
     33
     34  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
     35  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     36  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
     37  void setSpotDirection(const Vector& direction);
     38  void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); };
     39  void setSpotCutoff(GLfloat cutoff);
     40
     41  /** @returns the lightNumber*/
     42  int getLightNumber() const {return this->lightNumber;}
     43
     44  virtual void draw() const;
     45
     46  void debug() const;
     47
     48  // attributes
     49private:
     50  int              lightNumber;               //!< The number of this Light.
     51  GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
     52  GLfloat          specularColor[4];          //!< The specular Color of this Light.
     53  float            constantAttenuation;       //!< The Factor of the the Constant Attenuation.
     54  float            linearAttenuation;         //!< The Factor of the the Linear Attenuation.
     55  float            quadraticAttenuation;      //!< The Factor of the the Quadratic Attenuation.
     56  GLfloat          spotDirection[4];          //!< The direction of the Spot Light.
     57  GLfloat          spotCutoff;                //!< The cutoff Angle of the Light Source
    5758};
    58        
    59        
    60        
     59
     60
     61
    6162//! A class that handles Lights
    6263/**
     
    8788*/
    8889class LightManager : public BaseObject
    89         {
    90         friend class Light;
     90{
     91  NewObjectListDeclaration(LightManager);
    9192
    92         public:
    93                 virtual ~LightManager();
    94                 /** @returns a Pointer to the only object of this Class */
    95                 inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
     93  friend class Light;
     94public:
     95  virtual ~LightManager();
     96  /** @returns a Pointer to the only object of this Class */
     97  inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
    9698
    97                 virtual void loadParams(const TiXmlElement* root);
    98                 void loadLights(const TiXmlElement* root);
     99  virtual void loadParams(const TiXmlElement* root);
     100  void loadLights(const TiXmlElement* root);
    99101
    100                 void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
    101                 // HACK: Assuming r = g = b values
    102                 inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
     102  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     103  // HACK: Assuming r = g = b values
     104inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
    103105
    104                 Light* getLight(int lightNumber) const;
    105                 inline Light* getLight() const { return this->currentLight; };
     106  Light* getLight(int lightNumber) const;
     107  inline Light* getLight() const { return this->currentLight; };
    106108
    107                 void draw() const;
     109  void draw() const;
    108110
    109                 void debug() const;
     111  void debug() const;
    110112
    111         private:
    112                 LightManager();
     113private:
     114  LightManager();
    113115
    114                 int  registerLight(Light* light);
    115                 void unregisterLight(Light* light);
     116  int  registerLight(Light* light);
     117  void unregisterLight(Light* light);
    116118
    117         private:
    118                 static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
    119                 GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
     119private:
     120  static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
     121  GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
    120122
    121                 Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
    122                 Light*                  currentLight;       //!< The current Light, we are working with.
     123  Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
     124  Light*                  currentLight;       //!< The current Light, we are working with.
    123125
    124126};
  • branches/new_class_id/src/lib/graphics/render2D/element_2d.cc

    r9406 r9685  
    2929#include "graphics_engine.h"
    3030#include "util/loading/load_param.h"
    31 #include "class_list.h"
    3231
    3332#include "color.h"
     
    3534#include "shell_command.h"
    3635SHELL_COMMAND(debug, Element2D, debug2D);
     36
     37NewObjectListDefinition(Element2D);
    3738
    3839
     
    4647Element2D::Element2D (Element2D* parent, E2D_LAYER layer, short nodeFlags)
    4748{
    48   this->setClassID(CL_ELEMENT_2D, "Element2D");
     49  this->registerObject(this, Element2D::_objectList);
    4950
    5051  this->setVisibility(true);
     
    268269void Element2D::setBindNode(const std::string& bindNode)
    269270{
    270   const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE));
     271  const PNode* tmpBindNode = PNode::objectList().getObject(bindNode);
    271272  if (tmpBindNode != NULL)
    272273    this->bindNode = tmpBindNode;
     
    640641void Element2D::addChild2D (const std::string& childName)
    641642{
    642   Element2D* childNode = dynamic_cast<Element2D*>(ClassList::getObject(childName, CL_ELEMENT_2D));
     643  Element2D* childNode = Element2D::objectList().getObject(childName);
    643644  if (childNode != NULL)
    644645    this->addChild2D(childNode);
     
    718719void Element2D::setParent2D (const std::string& parentName)
    719720{
    720   Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D));
     721  Element2D* parentNode = Element2D::objectList().getObject(parentName);
    721722  if (parentNode != NULL)
    722723    parentNode->addChild2D(this);
     
    771772void Element2D::setParentSoft2D(const std::string& parentName, float bias)
    772773{
    773   Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D));
     774  Element2D* parentNode = Element2D::objectList().getObject(parentName);
    774775  if (parentNode != NULL)
    775776    this->setParentSoft2D(parentNode, bias);
  • branches/new_class_id/src/lib/graphics/render2D/element_2d.h

    r8360 r9685  
    4747
    4848  E2D_PARENT_MOVEMENT                = 0x0004,    //!< Moves all children along with the parent.
    49 // special linkage modes
     49  // special linkage modes
    5050  E2D_PARENT_ALL                     = 0x0003,    //!< Moves all children around the center of their parent, and also rotates their centers
    5151  E2D_PARENT_ROTATE_AND_MOVE         = 0x0005,    //!< Rotates all children around their axis, and moves them as the Parent Moves, but does not rotate around the center of their parent.
     
    5858  E2D_REPARENT_DELETE_CHILDREN       = 0x0040,    //!< Deletes the Children of the node when This Node is Removed. (Use with care).
    5959  /// FIXME
    60    E2D_REPARENT_KEEP_POSITION         = 0x0080,   //!< Tries to keep the Position if the Node is reparented.
     60  E2D_REPARENT_KEEP_POSITION         = 0x0080,   //!< Tries to keep the Position if the Node is reparented.
    6161
    6262
     
    8787 * -> the tree is sorted on insertion of a new Child: @see Element2D::addChild2D()
    8888 */
    89 class Element2D : virtual public BaseObject {
    90 
    91   public:
    92     Element2D(Element2D* parent = Element2D::getNullElement(), E2D_LAYER layer = E2D_DEFAULT_LAYER, short nodeFlags = E2D_PARENT_MODE_DEFAULT);
    93     virtual ~Element2D();
    94 
    95     virtual void loadParams(const TiXmlElement* root);
    96 
    97     // ACTIVATION //
    98     inline void activate2D() { this->bActive = this->bRelCoorChanged = this->bRelDirChanged = true; };
    99     inline void deactivate2D() { this->bActive = false; };
    100     inline bool get2DActiveState() { return this->bActive; };
    101 
    102     // ALIGNMENT //
    103     /** @param alignment the new Alignment of the 2D-Element */
    104     inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
    105     void setAlignment(const std::string& alignment);
    106     inline E2D_ALIGNMENT getAlignment() const { return this->alignment; };
    107 
    108     // LAYERING //
    109     void setLayer(E2D_LAYER layer);
    110     void setLayer(const std::string& layer);
    111     /** @returns the Layer this Element is drawn to */
    112     inline E2D_LAYER getLayer() const { return this->layer; };
    113 
    114     // VISIBILITY //
    115     /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
    116     inline void setVisibility(bool visible) { this->bVisible = visible; };
    117     /** @returns the visibility state */
    118     inline bool isVisible() const { return (this->bVisible && this->bCurrentlyVisible);  };
    119 
    120 
    121     // POSITIONAL (E2D-specials) //
    122     /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
    123     void setBindNode(const PNode* bindNode);
    124     void setBindNode(const std::string& bindNode);
    125     inline const PNode* getBindNode() const { return this->bindNode; };
    126 
    127     inline void setSize2D(float x, float y) { this->size = Vector2D(x, y); };
    128     inline void setSize2D(const Vector2D& size) { this->size = size; };
    129     inline const Vector2D& getSize2D() const { return this->size; };
    130     void setSizeSoft2D(float x, float y, float bias = 1.0);
    131     inline void setSizeX2D(float x) { this->size.x = x; };
    132     inline void setSizeY2D(float y) { this->size.y = y; };
    133     inline float getSizeX2D() const { return this->size.x; };
    134     inline float getSizeY2D() const { return this->size.y; };
    135 
    136   public:
    137     virtual void tick(float dt) {};
    138     virtual void draw() const  {};
    139     void tick2D(float dt);
    140     void draw2D(E2D_LAYER from, E2D_LAYER to) const;
    141     void drawChildren(E2D_LAYER from, E2D_LAYER to) const;
    142 
    143     // LIKE PNODE
    144   public:
    145     void setRelCoor2D (const Vector2D& relCoord);
    146     void setRelCoorX2D(float x);
    147     void setRelCoorY2D(float y);
    148     void setRelCoor2D (float x, float y);
    149     void setRelCoor2Dpx (int x, int y);
    150     void setRelCoorSoft2D (const Vector2D& relCoordSoft, float bias = 1.0);
    151     void setRelCoorSoft2D (float x, float y, float bias = 1.0);
    152     void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0);
    153     /** @returns the relative position */
    154     inline const Vector2D& getRelCoor2D () const { return this->prevRelCoordinate; };
    155     /** @returns the Relative Coordinate Destination */
    156     inline const Vector2D& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; };
    157     const Vector2D& getRelCoor2Dpx() const;
    158     void setAbsCoor2D (const Vector2D& absCoord);
    159     void setAbsCoor2D (float x, float y);
    160     void setAbsCoorX2D(float x);
    161     void setAbsCoorY2D(float y);
    162     void setAbsCoor2Dpx (int x, int y);
    163     void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0);
    164     void setAbsCoorSoft2D (float x, float y, float bias = 1.0);
    165     /** @returns the absolute position */
    166     inline const Vector2D& getAbsCoor2D () const { return this->absCoordinate; };
    167     const Vector2D& getAbsCoor2Dpx () const;
    168 
    169     void shiftCoor2D (const Vector2D& shift);
    170     void shiftCoor2Dpx (int x, int y);
    171 
    172     void setRelDir2D (float relDir);
    173     void setRelDirSoft2D(float relDirSoft, float bias = 1.0);
    174     /** @returns the relative Direction */
    175     inline float getRelDir2D () const { return this->prevRelDirection; };
    176     /** @returns the Relative Directional Destination */
    177     inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; };
    178     void setAbsDir2D (float absDir);
    179     void setAbsDirSoft2D (float absDirSoft, float bias = 1.0);
    180     /** @returns the absolute Direction */
    181     inline float getAbsDir2D () const { return this->absDirection; };
    182     void shiftDir2D (float shiftDir);
    183 
    184     /** @returns the Speed of the Node */
    185     inline float getSpeed() const { return 0; };
    186     /** @returns the Velocity of the Node */
    187     inline const Vector2D& getVelocity() const { return this->velocity; };
    188 
    189 
    190     void addChild2D (Element2D* child);
    191     void addChild2D (const std::string& childName);
    192     void removeChild2D (Element2D* child);
    193     void remove2D();
    194 
    195     /** @param parent the new parent of this Element2D */
    196     void setParent2D (Element2D* parent) { parent->addChild2D(this); };
    197     void setParent2D (const std::string& parentName);
    198     /** @returns the parent of this Element2D */
    199     inline Element2D* getParent2D () const { return this->parent; };
    200     /** @returns the List of Children of this Element2D */
    201     inline const std::list<Element2D*>& getChildren2D() const { return this->children; };
    202 
    203     void setParentSoft2D(Element2D* parentNode, float bias = 1.0);
    204     void setParentSoft2D(const std::string& parentName, float bias = 1.0);
    205 
    206     void setParentMode2D (E2D_PARENT_MODE parentMode);
    207     void setParentMode2D (const std::string& parentingMode);
    208     /** @returns the Parenting mode of this node */
    209     int getParentMode2D() const { return this->parentMode; };
    210 
    211     // NULL_PARENT //
    212     /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
    213     static Element2D* getNullElement()  { return (Element2D::nullElement != NULL)? Element2D::nullElement : Element2D::createNullElement(); };
    214 
    215 
    216     void update2D (float dt);
    217 
    218     void debug2D (unsigned int depth = 1, unsigned int level = 0) const;
    219     void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,0,0), unsigned int level = 0) const;
    220 
    221     // helper functions //
    222     static const char* parentingModeToString2D(int parentingMode);
    223     static E2D_PARENT_MODE stringToParentingMode2D(const std::string& parentingMode);
    224 
    225     static const char* layer2DToChar(E2D_LAYER layer);
    226     static E2D_LAYER charToLayer2D(const std::string& layer);
    227 
    228     static bool layerSortPredicate(const Element2D* elem1, const Element2D* elem2);
    229 
    230   private:
    231     void eraseChild2D(Element2D* child);
    232     /** tells the child that the parent's Coordinate has changed */
    233     inline void parentCoorChanged2D () { this->bRelCoorChanged = true; }
    234     /** tells the child that the parent's Direction has changed */
    235     inline void parentDirChanged2D () { this->bRelDirChanged = true; }
    236     /** @returns the last calculated coordinate */
    237     inline Vector2D getLastAbsCoor2D() { return this->lastAbsCoordinate; }
    238 
    239     void reparent2D();
    240     static Element2D* createNullElement();
    241     bool checkIntegrity(const Element2D* checkParent) const;
    242 
    243 
    244   private:
    245     const PNode*            bindNode;           //!< a node over which to display this 2D-element
    246     Vector2D                size;               //!< The size of the rendered item
    247     Vector2D*               toSize;             //!< The Size to iterate to.
    248 
    249     E2D_ALIGNMENT           alignment;          //!< How the Element is aligned around its Position
    250 
    251     bool                    bVisible;           //!< If the given Element2D is visible.
    252     bool                    bCurrentlyVisible;  //!< Evaluated in the TICK process, to see if the Element is Currently visible.
    253     bool                    bActive;            //!< If the given Element2D is active.
    254     E2D_LAYER               layer;              //!< What layer this Element2D is on.
    255 
    256     bool                    bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
    257     bool                    bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
    258 
    259     Vector2D                relCoordinate;      //!< coordinates relative to the parent
    260     Vector2D                absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
    261     float                   relDirection;       //!< direction relative to the parent
    262     float                   absDirection;       //!< absolute diretion in the world ( from (0,0,1) )
    263 
    264     Vector2D                prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
    265     Vector2D                lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
    266     float                   prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    267 
    268     Vector2D                velocity;           //!< Saves the velocity.
    269 
    270     Vector2D*               toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
    271     float*                  toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
    272     float                   bias;               //!< how fast to iterate to the given position (default is 1)
    273 
    274     Element2D*              parent;             //!< a pointer to the parent node
    275     std::list<Element2D*>   children;           //!< list of the children of this Element2D
    276 
    277     unsigned int            parentMode;         //!< the mode of the binding
    278 
    279     static Element2D*       nullElement;        //!< The top-most Element
     89class Element2D : virtual public BaseObject
     90{
     91  NewObjectListDeclaration(Element2D);
     92
     93public:
     94  Element2D(Element2D* parent = Element2D::getNullElement(), E2D_LAYER layer = E2D_DEFAULT_LAYER, short nodeFlags = E2D_PARENT_MODE_DEFAULT);
     95  virtual ~Element2D();
     96
     97  virtual void loadParams(const TiXmlElement* root);
     98
     99  // ACTIVATION //
     100  inline void activate2D() { this->bActive = this->bRelCoorChanged = this->bRelDirChanged = true; };
     101  inline void deactivate2D() { this->bActive = false; };
     102  inline bool get2DActiveState() { return this->bActive; };
     103
     104  // ALIGNMENT //
     105  /** @param alignment the new Alignment of the 2D-Element */
     106  inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
     107  void setAlignment(const std::string& alignment);
     108  inline E2D_ALIGNMENT getAlignment() const { return this->alignment; };
     109
     110  // LAYERING //
     111  void setLayer(E2D_LAYER layer);
     112  void setLayer(const std::string& layer);
     113  /** @returns the Layer this Element is drawn to */
     114  inline E2D_LAYER getLayer() const { return this->layer; };
     115
     116  // VISIBILITY //
     117  /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
     118  inline void setVisibility(bool visible) { this->bVisible = visible; };
     119  /** @returns the visibility state */
     120  inline bool isVisible() const { return (this->bVisible && this->bCurrentlyVisible);  };
     121
     122
     123  // POSITIONAL (E2D-specials) //
     124  /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
     125  void setBindNode(const PNode* bindNode);
     126  void setBindNode(const std::string& bindNode);
     127  inline const PNode* getBindNode() const { return this->bindNode; };
     128
     129  inline void setSize2D(float x, float y) { this->size = Vector2D(x, y); };
     130  inline void setSize2D(const Vector2D& size) { this->size = size; };
     131  inline const Vector2D& getSize2D() const { return this->size; };
     132  void setSizeSoft2D(float x, float y, float bias = 1.0);
     133  inline void setSizeX2D(float x) { this->size.x = x; };
     134  inline void setSizeY2D(float y) { this->size.y = y; };
     135  inline float getSizeX2D() const { return this->size.x; };
     136  inline float getSizeY2D() const { return this->size.y; };
     137
     138public:
     139  virtual void tick(float dt) {};
     140  virtual void draw() const  {};
     141  void tick2D(float dt);
     142  void draw2D(E2D_LAYER from, E2D_LAYER to) const;
     143  void drawChildren(E2D_LAYER from, E2D_LAYER to) const;
     144
     145  // LIKE PNODE
     146public:
     147  void setRelCoor2D (const Vector2D& relCoord);
     148  void setRelCoorX2D(float x);
     149  void setRelCoorY2D(float y);
     150  void setRelCoor2D (float x, float y);
     151  void setRelCoor2Dpx (int x, int y);
     152  void setRelCoorSoft2D (const Vector2D& relCoordSoft, float bias = 1.0);
     153  void setRelCoorSoft2D (float x, float y, float bias = 1.0);
     154  void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0);
     155  /** @returns the relative position */
     156  inline const Vector2D& getRelCoor2D () const { return this->prevRelCoordinate; };
     157  /** @returns the Relative Coordinate Destination */
     158inline const Vector2D& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; };
     159  const Vector2D& getRelCoor2Dpx() const;
     160  void setAbsCoor2D (const Vector2D& absCoord);
     161  void setAbsCoor2D (float x, float y);
     162  void setAbsCoorX2D(float x);
     163  void setAbsCoorY2D(float y);
     164  void setAbsCoor2Dpx (int x, int y);
     165  void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0);
     166  void setAbsCoorSoft2D (float x, float y, float bias = 1.0);
     167  /** @returns the absolute position */
     168  inline const Vector2D& getAbsCoor2D () const { return this->absCoordinate; };
     169  const Vector2D& getAbsCoor2Dpx () const;
     170
     171  void shiftCoor2D (const Vector2D& shift);
     172  void shiftCoor2Dpx (int x, int y);
     173
     174  void setRelDir2D (float relDir);
     175  void setRelDirSoft2D(float relDirSoft, float bias = 1.0);
     176  /** @returns the relative Direction */
     177  inline float getRelDir2D () const { return this->prevRelDirection; };
     178  /** @returns the Relative Directional Destination */
     179inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; };
     180  void setAbsDir2D (float absDir);
     181  void setAbsDirSoft2D (float absDirSoft, float bias = 1.0);
     182  /** @returns the absolute Direction */
     183  inline float getAbsDir2D () const { return this->absDirection; };
     184  void shiftDir2D (float shiftDir);
     185
     186  /** @returns the Speed of the Node */
     187  inline float getSpeed() const { return 0; };
     188  /** @returns the Velocity of the Node */
     189  inline const Vector2D& getVelocity() const { return this->velocity; };
     190
     191
     192  void addChild2D (Element2D* child);
     193  void addChild2D (const std::string& childName);
     194  void removeChild2D (Element2D* child);
     195  void remove2D();
     196
     197  /** @param parent the new parent of this Element2D */
     198  void setParent2D (Element2D* parent) { parent->addChild2D(this); };
     199  void setParent2D (const std::string& parentName);
     200  /** @returns the parent of this Element2D */
     201  inline Element2D* getParent2D () const { return this->parent; };
     202  /** @returns the List of Children of this Element2D */
     203  inline const std::list<Element2D*>& getChildren2D() const { return this->children; };
     204
     205  void setParentSoft2D(Element2D* parentNode, float bias = 1.0);
     206  void setParentSoft2D(const std::string& parentName, float bias = 1.0);
     207
     208  void setParentMode2D (E2D_PARENT_MODE parentMode);
     209  void setParentMode2D (const std::string& parentingMode);
     210  /** @returns the Parenting mode of this node */
     211  int getParentMode2D() const { return this->parentMode; };
     212
     213  // NULL_PARENT //
     214  /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
     215static Element2D* getNullElement()  { return (Element2D::nullElement != NULL)? Element2D::nullElement : Element2D::createNullElement(); };
     216
     217
     218  void update2D (float dt);
     219
     220  void debug2D (unsigned int depth = 1, unsigned int level = 0) const;
     221  void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,0,0), unsigned int level = 0) const;
     222
     223  // helper functions //
     224  static const char* parentingModeToString2D(int parentingMode);
     225  static E2D_PARENT_MODE stringToParentingMode2D(const std::string& parentingMode);
     226
     227  static const char* layer2DToChar(E2D_LAYER layer);
     228  static E2D_LAYER charToLayer2D(const std::string& layer);
     229
     230  static bool layerSortPredicate(const Element2D* elem1, const Element2D* elem2);
     231
     232private:
     233  void eraseChild2D(Element2D* child);
     234  /** tells the child that the parent's Coordinate has changed */
     235  inline void parentCoorChanged2D () { this->bRelCoorChanged = true; }
     236  /** tells the child that the parent's Direction has changed */
     237  inline void parentDirChanged2D () { this->bRelDirChanged = true; }
     238  /** @returns the last calculated coordinate */
     239  inline Vector2D getLastAbsCoor2D() { return this->lastAbsCoordinate; }
     240
     241  void reparent2D();
     242  static Element2D* createNullElement();
     243  bool checkIntegrity(const Element2D* checkParent) const;
     244
     245
     246private:
     247  const PNode*            bindNode;           //!< a node over which to display this 2D-element
     248  Vector2D                size;               //!< The size of the rendered item
     249  Vector2D*               toSize;             //!< The Size to iterate to.
     250
     251  E2D_ALIGNMENT           alignment;          //!< How the Element is aligned around its Position
     252
     253  bool                    bVisible;           //!< If the given Element2D is visible.
     254  bool                    bCurrentlyVisible;  //!< Evaluated in the TICK process, to see if the Element is Currently visible.
     255  bool                    bActive;            //!< If the given Element2D is active.
     256  E2D_LAYER               layer;              //!< What layer this Element2D is on.
     257
     258  bool                    bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
     259  bool                    bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
     260
     261  Vector2D                relCoordinate;      //!< coordinates relative to the parent
     262  Vector2D                absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
     263  float                   relDirection;       //!< direction relative to the parent
     264  float                   absDirection;       //!< absolute diretion in the world ( from (0,0,1) )
     265
     266  Vector2D                prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
     267  Vector2D                lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
     268  float                   prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
     269
     270  Vector2D                velocity;           //!< Saves the velocity.
     271
     272  Vector2D*               toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
     273  float*                  toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
     274  float                   bias;               //!< how fast to iterate to the given position (default is 1)
     275
     276  Element2D*              parent;             //!< a pointer to the parent node
     277  std::list<Element2D*>   children;           //!< list of the children of this Element2D
     278
     279  unsigned int            parentMode;         //!< the mode of the binding
     280
     281  static Element2D*       nullElement;        //!< The top-most Element
    280282};
    281283
  • branches/new_class_id/src/lib/graphics/render2D/image_plane.cc

    r9406 r9685  
    2121
    2222#include "graphics_engine.h"
    23 #include "glincl.h"
    2423#include "p_node.h"
    2524
    2625
     26#include "class_id.h"
     27CREATE_FACTORY(ImagePlane, CL_IMAGE_ENTITY);
    2728
    28 
    29 
    30 CREATE_FACTORY(ImagePlane, CL_IMAGE_ENTITY);
     29NewObjectListDefinitionID(ImagePlane, CL_IMAGE_ENTITY);
    3130
    3231
     
    5655void ImagePlane::init()
    5756{
    58   this->setClassID(CL_IMAGE_PLANE, "ImagePlane");
     57  this->registerObject(this, ImagePlane::_objectList);
    5958  this->setName("ImagePlane");
    6059
  • branches/new_class_id/src/lib/graphics/render2D/image_plane.h

    r7843 r9685  
    1717class ImagePlane :  public Element2D
    1818{
    19 
     19  NewObjectListDeclaration(ImagePlane);
    2020  public:
    2121    ImagePlane(const TiXmlElement* root = NULL);
  • branches/new_class_id/src/lib/graphics/render2D/render_2d.cc

    r9406 r9685  
    1919
    2020#include "graphics_engine.h"
    21 #include "class_list.h"
    2221#include "element_2d.h"
    2322
     23NewObjectListDefinition(Render2D);
    2424
    2525
     
    2929Render2D::Render2D ()
    3030{
    31    this->setClassID(CL_RENDER_2D, "Render2D");
    32    this->setName("Render2D");
     31  this->registerObject(this, Render2D::_objectList);
     32  this->setName("Render2D");
    3333
    34    this->showNodes = false;
     34  this->showNodes = false;
    3535}
    3636
  • branches/new_class_id/src/lib/graphics/render2D/render_2d.h

    r7840 r9685  
    1212
    1313//! A default singleton class.
    14 class Render2D : public BaseObject {
     14class Render2D : public BaseObject
     15{
     16  NewObjectListDeclaration(Render2D);
     17
    1518  friend class Element2D;
    1619
    17   public:
    18     virtual ~Render2D();
    19     /** @returns a Pointer to the only object of this Class */
    20     inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
     20public:
     21  virtual ~Render2D();
     22  /** @returns a Pointer to the only object of this Class */
     23  inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
    2124
    22     void toggleNodesVisibility() { this->showNodes = !this->showNodes; };
     25void toggleNodesVisibility() { this->showNodes = !this->showNodes; };
    2326
    24     void update(float dt);
    25     void tick(float dt);
    26     void draw(E2D_LAYER from, E2D_LAYER to) const;
     27  void update(float dt);
     28  void tick(float dt);
     29  void draw(E2D_LAYER from, E2D_LAYER to) const;
    2730
    28   private:
    29     Render2D();
    30     static Render2D*              singletonRef;                    //!< Reference to this class.
     31private:
     32  Render2D();
     33  static Render2D*              singletonRef;                    //!< Reference to this class.
    3134
    32     bool                          showNodes;                       //!< If the debug-Nodes should be visible
    33  };
     35  bool                          showNodes;                       //!< If the debug-Nodes should be visible
     36};
    3437
    3538#endif /* _RENDER_2D_H */
  • branches/new_class_id/src/lib/graphics/shader.cc

    r9406 r9685  
    3333
    3434
    35 
     35NewObjectListDefinition(Shader);
    3636
    3737/**
     
    4040Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    4141{
    42    this->setClassID(CL_SHADER, "Shader");
    43 
     42  this->registerObject(this, Shader::_objectList);
    4443   this->shaderProgram = 0;
    4544   this->vertexShader = 0;
  • branches/new_class_id/src/lib/graphics/shader.h

    r8255 r9685  
    1919class Shader : public BaseObject
    2020{
     21  NewObjectListDeclaration(Shader);
    2122public:
    2223  class Uniform
     
    4243      {
    4344        case 1:
    44           glUniform1fv(this->uniform, 1, vv);
    45           break;
     45        glUniform1fv(this->uniform, 1, vv);
     46        break;
    4647        case 2:
    47           glUniform2fv(this->uniform, 2, vv);
    48           break;
     48        glUniform2fv(this->uniform, 2, vv);
     49        break;
    4950        case 3:
    50           glUniform3fv(this->uniform, 3, vv);
    51           break;
     51        glUniform3fv(this->uniform, 3, vv);
     52        break;
    5253        case 4:
    53           glUniform4fv(this->uniform, 4, vv);
    54           break;
     54        glUniform4fv(this->uniform, 4, vv);
     55        break;
    5556      }
    5657    }
     
    6061      {
    6162        case 1:
    62           glUniform1iv(this->uniform, 1, vv);
    63           break;
     63        glUniform1iv(this->uniform, 1, vv);
     64        break;
    6465        case 2:
    65           glUniform2iv(this->uniform, 2, vv);
    66           break;
     66        glUniform2iv(this->uniform, 2, vv);
     67        break;
    6768        case 3:
    68           glUniform3iv(this->uniform, 3, vv);
    69           break;
     69        glUniform3iv(this->uniform, 3, vv);
     70        break;
    7071        case 4:
    71           glUniform4iv(this->uniform, 4, vv);
    72           break;
     72        glUniform4iv(this->uniform, 4, vv);
     73        break;
    7374      }
    7475    }
    75     private:
     76  private:
    7677    GLint uniform;
    7778  };
     
    99100  static void deactivateShader();
    100101
    101   Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
     102Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
    102103
    103104  bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
     
    118119
    119120
    120   GLhandleARB getProgram() const { return this->shaderProgram; }
     121GLhandleARB getProgram() const { return this->shaderProgram; }
    121122  GLhandleARB getVertexS() const { return this->vertexShader; }
    122123  GLhandleARB getFragmentS() const { return this->fragmentShader; }
  • branches/new_class_id/src/lib/graphics/spatial_separation/quadtree.cc

    r9406 r9685  
    2727#define QUADTREE_MATERIAL_COUNT       4
    2828
     29NewObjectListDefinition(Quadtree);
    2930/**
    3031 *  standard constructor
     
    3233Quadtree::Quadtree (const modelInfo* pModelInfo, const int treeDepth)
    3334{
    34   this->setClassID(CL_QUADTREE, "Quadtree");
     35  this->registerObject(this, Quadtree::_objectList);
    3536  this->pModelInfo = pModelInfo;
    3637  this->treeDepth = treeDepth;
  • branches/new_class_id/src/lib/graphics/spatial_separation/quadtree.h

    r6022 r9685  
    2121//! A class for quadtree separation of the world
    2222class Quadtree : public BaseObject {
    23 
     23  NewObjectListDeclaration(Quadtree);
    2424
    2525  public:
  • branches/new_class_id/src/lib/graphics/spatial_separation/quadtree_node.cc

    r9406 r9685  
    2727
    2828
    29 
     29NewObjectListDefinition(QuadtreeNode);
    3030
    3131/**
     
    102102void QuadtreeNode::init()
    103103{
    104   this->setClassID(CL_QUADTREE_NODE, "QuadtreeNode");
     104  this->registerObject(this, QuadtreeNode::_objectList);
    105105
    106106  /* init the rest of the variables for both init types */
  • branches/new_class_id/src/lib/graphics/spatial_separation/quadtree_node.h

    r6617 r9685  
    2626//! A class for a Quadtree Node representation
    2727class QuadtreeNode : public BaseObject {
     28  NewObjectListDeclaration(QuadtreeNode);
    2829
    2930  public:
  • branches/new_class_id/src/lib/graphics/spatial_separation/spatial_separation.cc

    r9406 r9685  
    2424
    2525
    26 
     26NewObjectListDefinition(SpatialSeparation);
    2727
    2828/**
    29  * standard constructor
     29 * @brief standard constructor
    3030 * @param model the model that is to be separated
    3131 * @param overlapSize each box will overlap for a given size
    32 
    33    The boxes are overlaping because this makes collision detection a lot simpler
    34 
     32 *
     33 * The boxes are overlaping because this makes collision detection a lot simpler
     34 *
    3535 */
    3636SpatialSeparation::SpatialSeparation (Model* model, float overlapSize)
     
    3939  PRINT(3)("+-| (Event) Spatial Separation process kicked on\n");
    4040
    41   this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation");
     41  this->registerObject(this, SpatialSeparation::_objectList);
    4242  /* debug vice */
    4343  this->createQuadtree(model);
     
    4646
    4747/**
    48  * standard constructor
     48 * @brief standard constructor
    4949 * @param model the model that is to be separated
    5050 * @param overlapSize each box will overlap for a given size
     
    5454SpatialSeparation::SpatialSeparation (Model* model, Model* playerModel)
    5555{
    56   this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation");
     56  this->registerObject(this, SpatialSeparation::_objectList);
    5757
    5858}
     
    6060
    6161/**
    62  * standard deconstructor
     62 * @brief standard deconstructor
    6363 */
    6464SpatialSeparation::~SpatialSeparation ()
     
    7070
    7171/**
    72  * creates a quadtree
     72 * @brief creates a quadtree
    7373 * @param model the model to do a quadtree on
    7474 * @param minLength the minimal length of a quadtree node
     
    8383
    8484/**
    85  *  brief creates a quadtree
     85 * @brief creates a quadtree
    8686 * @param model the model to do a quadtree on
    8787 * @param minLength the minimal length of a quadtree node
     
    9595
    9696/**
    97  * creates a quadtree
     97 * @brief creates a quadtree
    9898 * @param model the model to do a quadtree on
    9999 * @param minLength the minimal length of a quadtree node
     
    109109
    110110/**
    111  * draws all the quadtrees
     111 * @brief draws all the quadtrees
    112112 */
    113113void SpatialSeparation::drawQuadtree()
     
    118118  this->quadtree->drawTree();
    119119}
    120 
    121 
    122 
    123 
    124 
    125 
    126 
    127 
    128 
    129 
    130 
    131 
  • branches/new_class_id/src/lib/graphics/spatial_separation/spatial_separation.h

    r6022 r9685  
    1919//! A class for spatial separation of vertices based arrays
    2020class SpatialSeparation : public BaseObject {
     21  NewObjectListDeclaration(SpatialSeparation);
    2122
    2223  public:
  • branches/new_class_id/src/lib/graphics/text_engine/font.cc

    r8989 r9685  
    2929#include "compiler.h"
    3030
     31NewObjectListDefinition(Font);
    3132
    3233Font::Font()
     
    130131  this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    131132
    132   this->setClassID(CL_FONT, "Font");
     133  this->registerObject(this, Font::_objectList);
    133134  if (Font::defaultFontData.get() == NULL)
    134135  {
  • branches/new_class_id/src/lib/graphics/text_engine/font.h

    r8766 r9685  
    1919class Font : public Material
    2020{
     21  NewObjectListDeclaration(Font);
    2122
    2223public:
  • branches/new_class_id/src/lib/graphics/text_engine/limited_width_text.cc

    r9406 r9685  
    1919#include "font.h"
    2020
     21NewObjectListDefinition(LimitedWidthText);
    2122/**
    2223 * @brief creates a new Text Element
     
    2728    : Text(fontFile, textSize)
    2829{
    29   this->setClassID(CL_LIMITED_WIDTH_TEXT, "LimitedWidthText");
     30  this->registerObject(this, LimitedWidthText::_objectList);
    3031
    3132  this->_dotsPosition = End;
  • branches/new_class_id/src/lib/graphics/text_engine/limited_width_text.h

    r8980 r9685  
    1414class LimitedWidthText : public Text
    1515{
     16  NewObjectListDeclaration(LimitedWidthText);
    1617  public:
    1718    typedef enum {
  • branches/new_class_id/src/lib/graphics/text_engine/multi_line_text.cc

    r9406 r9685  
    1919#include "font.h"
    2020
     21NewObjectListDefinition(MultiLineText);
     22
    2123/**
    2224 * @brief creates a new Text Element
     
    2729  : Text(fontFile, textSize)
    2830{
    29   this->setClassID(CL_MULTI_LINE_TEXT, "MultiLineText");
     31  this->registerObject(this, MultiLineText::_objectList);
    3032
    3133  this->lineSpacing = 1.0;
  • branches/new_class_id/src/lib/graphics/text_engine/multi_line_text.h

    r7757 r9685  
    1414class MultiLineText : public Text
    1515{
     16  NewObjectListDeclaration(MultiLineText);
    1617  public:
    1718    MultiLineText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, float lineWidth = 100.0);
  • branches/new_class_id/src/lib/graphics/text_engine/text.cc

    r9406 r9685  
    2222#include "debug.h"
    2323
     24NewObjectListDefinition(Text);
     25
    2426/**
    2527 * @brief creates a new Text Element
     
    3032    // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    3133{
    32   this->setClassID(CL_TEXT, "Text");
     34  this->registerObject(this, Text::_objectList);
    3335
    3436  // initialize this Text
     
    4446    : _font()
    4547{
    46   this->setClassID(CL_TEXT, "Text");
     48  this->registerObject(this, Text::_objectList);
    4749
    4850  *this = text;
  • branches/new_class_id/src/lib/graphics/text_engine/text.h

    r8764 r9685  
    2626class Text : public Element2D
    2727{
     28  NewObjectListDeclaration(Text);
    2829  public:
    2930    Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
  • branches/new_class_id/src/lib/graphics/text_engine/text_engine.cc

    r9406 r9685  
    3434#include "graphics_engine.h"
    3535#include "util/loading/resource_manager.h"
    36 #include "class_list.h"
    3736
    3837#include "debug.h"
     
    4039/// TEXT-ENGINE ///
    4140///////////////////
     41NewObjectListDefinition(TextEngine);
    4242/**
    4343 *  standard constructor
     
    4545TextEngine::TextEngine ()
    4646{
    47    this->setClassID(CL_TEXT_ENGINE, "TextEngine");
    48    this->setName("TextEngine");
    49    this->enableFonts();
     47  this->registerObject(this, TextEngine::_objectList);
     48  this->setName("TextEngine");
     49  this->enableFonts();
    5050}
    5151
     
    6262{
    6363  // first remove all the remaining Texts (if any).
    64   const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    65   if (textList != NULL)
    66   {
    67     while(textList->size() > 0)
    68       delete dynamic_cast<Text*>(textList->front());
    69   }
     64  while (!Text::objectList().empty())
     65    delete Text::objectList().front();
    7066  // delete all remaining fonts (There should not be Anything to do here)
    71   const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
    72   if (fontList != NULL)
     67
     68  //const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
     69  //if (fontList != NULL)
    7370  {
    7471    ///FIXME
    75 //    while (fontList->size() > 0)
     72    //    while (fontList->size() > 0)
    7673    {
    77 //      Font* font = dynamic_cast<Font*>(fontList->back());
     74      //      Font* font = dynamic_cast<Font*>(fontList->back());
    7875      //if (likely(font != Font::getDefaultFont()))
    7976      //        ResourceManager::getInstance()->unload(font, RP_GAME);
     
    9188{
    9289  if (!TTF_WasInit())
    93     {
    94       if(TTF_Init()==-1)
    95         PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
     90  {
     91    if(TTF_Init()==-1)
     92      PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
    9693
    97       TextEngine::checkVersion();
    98     }
     94    TextEngine::checkVersion();
     95  }
    9996  else
    10097    PRINTF(4)("Fonts already initialized\n");
     
    107104{
    108105  if (TTF_WasInit())
    109     {
    110 //      Font::removeDefaultFont();
    111       TTF_Quit();
    112     }
     106  {
     107    //      Font::removeDefaultFont();
     108    TTF_Quit();
     109  }
    113110  else
    114111    PRINTF(4)("Fonts were not initialized.\n");
     
    122119void TextEngine::debug() const
    123120{
    124   const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    125   if (textList != NULL)
     121  PRINT(0)("+-------------------------------+\n");
     122  PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
     123  PRINT(0)("+-------------------------------+\n");
     124  PRINT(0)("Reference: %p; Text Counts: %d\n", this, Text::objectList().size());
     125
     126  for (NewObjectList<Text>::const_iterator it = Text::objectList().begin();
     127       it != Text::objectList().end();
     128       ++it)
    126129  {
    127     PRINT(0)("+-------------------------------+\n");
    128     PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
    129     PRINT(0)("+-------------------------------+\n");
    130     PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size());
    131 
    132     std::list<BaseObject*>::const_iterator text;
    133     for ( text = textList->begin(); text != textList->end(); text++)
    134       dynamic_cast<Text*>(*text)->debug();
     130      (*it)->debug();
    135131    PRINT(0)("+---------------------------TE--+\n");
    136132  }
     
    152148      compile_version.minor == link_version.minor &&
    153149      compile_version.patch == link_version.patch)
    154     {
    155       return true;
    156     }
     150  {
     151    return true;
     152  }
    157153  else
    158     {
    159       PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
    160                 compile_version.major,
    161                 compile_version.minor,
    162                 compile_version.patch);
     154  {
     155    PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
     156              compile_version.major,
     157              compile_version.minor,
     158              compile_version.patch);
    163159
    164       PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
    165                 link_version.major,
    166                 link_version.minor,
    167                 link_version.patch);
    168       return false;
    169     }
     160    PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
     161              link_version.major,
     162              link_version.minor,
     163              link_version.patch);
     164    return false;
     165  }
    170166}
  • branches/new_class_id/src/lib/graphics/text_engine/text_engine.h

    r5515 r9685  
    2424class TextEngine : public BaseObject
    2525{
    26  public:
     26  NewObjectListDeclaration(TextEngine);
     27  public:
    2728  virtual ~TextEngine();
    2829  /** @returns a Pointer to the only object of this Class */
  • branches/new_class_id/src/lib/lang/new_class_id.cc

    r9681 r9685  
    1717
    1818#include "new_class_id.h"
    19 #include <cassert>
    20 #include "debug.h"
    21 
    22 ///////////////////////////////////////////////////////////
    23 //// CLASS ID definiton. //////////////////////////////////
    24 ///////////////////////////////////////////////////////////
    25 /**
    26  * @brief standard constructor
    27  */
    28 NewClassID::NewClassID ()
    29 {}
    30 
    31 
    32 /**
    33  * @brief standard deconstructor
    34  */
    35 NewClassID::~NewClassID ()
    36 {
    37   ClassList::iterator it;
    38   for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    39   {
    40     (*it)._objectList->unregisterObject((*it)._iterator);
    41     delete (*it)._iterator;
    42   }
    43 }
    44 
    45 
    46 /**
    47  * @brief Seeks in the Inheritance if it matches objectList.
    48  * @param objectList The ObjectList this should be a member of (by Pointer-comparison).
    49  * @return True if found, false if not.
    50  */
    51 bool NewClassID::isA(const NewObjectListBase& objectList) const
    52 {
    53   ClassList::const_iterator it;
    54   for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    55     if ((*it)._objectList == &objectList)
    56       return true;
    57   return false;
    58 }
    59 
    60 /**
    61  * @brief Seeks in the Inheritance if it matches objectList.
    62  * @param classID The ClassID of the class this should be a member of.
    63  * @return True if found, false if not.
    64  */
    65 bool NewClassID::isA(int classID) const
    66 {
    67   ClassList::const_iterator it;
    68   for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    69     if (*(*it)._objectList == classID)
    70       return true;
    71   return false;
    72 }
    73 
    74 /**
    75  * @brief Seeks in the Inheritance if it matches objectList.
    76  * @param className The ClassName of the class this should be a member of.
    77  * @return True if found, false if not.
    78  */
    79 bool NewClassID::isA(const std::string& className) const
    80 {
    81   ClassList::const_iterator it;
    82   for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    83     if (*(*it)._objectList == className)
    84       return true;
    85   return false;
    86 }
    87 
    88 
    89 void NewClassID::listInheritance() const
    90 {
    91   PRINT(0)("Listing inheritance diagram for ....: ");
    92   ClassList::const_iterator it;
    93   for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    94     PRINT(0)(" -> %s(id:%d)", (*it)._objectList->name().c_str(), (*it)._objectList->id());
    95   PRINT(0)("\n");
    96 
    97 }
  • branches/new_class_id/src/lib/lang/new_class_id.h

    r9682 r9685  
    88#define _NEW_CLASS_ID_H
    99
    10 #include "new_object_list.h"
    11 
    1210#include <string>
    13 #include <list>
    1411
    1512//! A class to dynamically allocate ClassID's and support a isA operator
     
    1714{
    1815public:
    19   NewClassID();
    20   ~NewClassID();
     16  NewClassID() : _id(-1), _name("") { };
     17  NewClassID(int id, const std::string& name) : _id(id), _name(name) { };
     18  // the copy constructor is also defined.
     19  int id() const { return _id; };
     20  const std::string& name() const { return _name; };
    2121
    22   /** @returns the ClassName of the Topmost Object of the ClassStack */
    23   inline const std::string& getClassName() const { return _classes.front()._objectList->name(); }
    24   /** @returns the ID of the Topmost object of the ClassStack */
    25   inline int leafClassID() const { return _classes.front()._objectList->id(); }
    26 
    27   template<class T> void registerObject(T* object, NewObjectList<T>& list);
    28   bool isA(const NewObjectListBase& objectList) const;
    29   bool isA(int classID) const;
    30   bool isA(const std::string& className) const;
    31 
    32   void listInheritance() const;
     22  bool operator==(NewClassID id) const { return _id == id._id || _name == id._name; };
     23  bool operator==(int id) const { return _id == id; };
     24  bool operator==(const std::string& name) const { return _name == name; };
    3325
    3426private:
    35   //////////////////////////////
    36   //// Type Definition Part ////
    37   //////////////////////////////
    38   //! A ClassEntry so we can store Classes inside of Objects
    39   struct ClassEntry
    40   {
    41     /** Simple Constuctor @param objectList the NewObjectList, @param iterator the (intrusive) Iterator inside of the ObjectList */
    42     inline ClassEntry (NewObjectListBase* objectList, NewObjectListBase::IteratorBase* iterator) : _objectList(objectList), _iterator(iterator) {}
    43     NewObjectListBase*                _objectList;  //!< A ObjectList this Object is part of
    44     NewObjectListBase::IteratorBase*  _iterator;    //!< An iterator pointing to the position of the Object inside of the List.
    45   };
    46   typedef std::list<ClassEntry>        ClassList;   //!< Type definition for the List.
    47 
    48   ClassList                           _classes;     //!< All Classes this object is part of.
     27  int            _id;
     28  std::string    _name;
    4929};
    50 
    51 
    52 /**
    53  * @brief Registeres an Object of Type T to objectList
    54  * @param object The Object to append to the objectList.
    55  * @param objectList The ObjectList to append the Object to.
    56  *
    57  * This function is essential to integrate objects into their designated ObjectList.
    58  * Remember if you do not want objects to be stored in Lists (less overhead),
    59  * do not attempt to call this function.
    60  */
    61 template<class T>
    62 inline void NewClassID::registerObject(T* object, NewObjectList<T>& objectList)
    63 {
    64   this->_classes.push_front(ClassEntry(&objectList, objectList.registerObject(object)));
    65 }
    66 
    6730#endif /* _NEW_CLASS_ID_H */
  • branches/new_class_id/src/lib/lang/new_object_list.cc

    r9681 r9685  
    2727 */
    2828NewObjectListBase::NewObjectListBase(const std::string& className, int id)
    29     : _name(className)
    3029{
    3130  if (NewObjectListBase::_classesByID == NULL)
     
    3736  assert(!NewObjectListBase::classNameExists(className) && "Classes should only be included once, and no two classes should have the same name (key value)");
    3837
    39   if (id != -1)
     38  if (id == -1)
    4039  {
    41     this->_id = id;
    42   }
    43   else
    44   {
    45     this->_id = NewObjectListBase::_classesByID->size();
     40    id = NewObjectListBase::_classesByID->size();
    4641    // searching for a free ID
    47     while (NewObjectListBase::classIDExists(_id)) ++id;
     42    while (NewObjectListBase::classIDExists(id)) ++id;
    4843  }
    4944  assert(!NewObjectListBase::classIDExists(id) && "Classes should only be included once, and no two classes should have the same ID (key value)");
     
    5247  //std::cout << "register new ObjectList " << className << " ID: " << this->_id << std::endl;
    5348
    54   (*NewObjectListBase::_classesByID)[this->_id] = this;
    55   (*NewObjectListBase::_classesByName)[this->_name] = this;
     49  this->_identity = NewClassID(id, className);
     50  (*NewObjectListBase::_classesByID)[this->_identity.id()] = this;
     51  (*NewObjectListBase::_classesByName)[this->_identity.name()] = this;
    5652}
    5753
     
    7066  std::cout << "SIZE OF _classByName: " << NewObjectListBase::_classesByName->size() << std::endl;
    7167  */
    72   NewObjectListBase::_classesByName->erase(this->_name);
    73   NewObjectListBase::_classesByID->erase(this->_id);
     68  NewObjectListBase::_classesByID->erase(this->_identity.id());
     69  NewObjectListBase::_classesByName->erase(this->_identity.name());
    7470
    7571  if (NewObjectListBase::_classesByID->empty())
  • branches/new_class_id/src/lib/lang/new_object_list.h

    r9684 r9685  
    88#define _NEW_OBJECT_LIST_H
    99
    10 #include "type_info.h"
     10#include "new_class_id.h"
    1111#include <map>
    1212#include <list>
     
    4040
    4141public:
    42   inline int id() const { return _id; };
    43   inline const std::string& name() const { return _name; };
    44   bool operator==(int id) const { return _id == id; };
    45   bool operator==(const std::string& name) const { return _name == name; };
     42  inline int id() const { return _identity.id(); };
     43  inline const std::string& name() const { return _identity.name(); };
     44  bool operator==(int id) const { return _identity == id; };
     45  bool operator==(const std::string& name) const { return _identity == name; };
    4646
    4747  virtual void debug() const = 0;
     
    6969  typedef std::map<std::string, NewObjectListBase*> classNameMap;//!< The Generic Map.
    7070
    71   int                           _id;                //!< The ID of the class.
    72   std::string                   _name;              //!< The Name of the Class.
     71  NewClassID                    _identity;          //!< The Identity of the Class (ID and Name).
    7372
    7473private:
     
    114113  inline const list&      objects() const { return _objects; };
    115114
     115  inline iterator begin() { return _objects.begin(); };
     116  inline const_iterator begin() const { return _objects.begin(); };
     117  inline iterator  end() { return _objects.end(); };
     118  inline const_iterator  end() const { return _objects.end(); };
     119
     120  inline bool empty() const { return _objects.empty(); };
     121  inline int size() const { return _objects.size(); };
     122  inline T* front() const { return _objects.front(); };
     123  inline T* back() const { return _objects.back(); };
     124
    116125  NewObjectListBase::IteratorBase* registerObject(T* object);
    117126  void unregisterObject(IteratorBase* iterator);
  • branches/new_class_id/src/lib/script_engine/script_class.h

    r9003 r9685  
    3434  virtual void registerClass(Script* script) = 0;
    3535  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) = 0;
    36   virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0; 
     36  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0;
    3737
    3838  const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
  • branches/new_class_id/src/util/object_manager.h

    r9656 r9685  
    9090  const EntityList& getObjectList(OM_LIST listNumber) const { return this->objectLists[listNumber]; }
    9191
    92   static void distanceFromObject(EntityList& entities, const PNode& center, float radius, ClassID classID);
     92  template <class T> static void distanceFromObject(EntityList& entities, const PNode& center, float radius, NewObjectList<T>& list);
    9393
    9494  void debug(OM_LIST omList, unsigned int level = 0) const;
  • branches/new_class_id/src/world_entities/Makefile.am

    r8994 r9685  
    2121                projectiles/projectile.cc \
    2222                \
     23                extendable.cc \
    2324                power_ups/power_up.cc \
    2425                power_ups/param_power_up.cc \
  • branches/new_class_id/src/world_entities/extendable.cc

    r9683 r9685  
    1 /*!
    2  * @file proto_class.h
    3  * @brief Interface for Worldentities that can picku up powerups.
    4 */
     1#include "extendable.h"
    52
    6 #ifndef _EXTENDABLE_H
    7 #define _EXTENDABLE_H
    8 
    9 #include "base_object.h"
    10 
    11 // FORWARD DECLARATION
    12 class PowerUp;
    13 
    14 #include "power_ups/power_up.h"
    15 
    16 //! A class for ...
    17 class Extendable : virtual public BaseObject {
    18 
    19   public:
    20    //   virtual ~Extendable();
    21    virtual bool pickup(PowerUp* powerUp) { return false; };
    22 
    23   protected:
    24     Extendable() { this->setClassID(CL_EXTENDABLE, "Extendable"); };
    25 
    26   private:
    27 
    28 };
    29 
    30 #endif /* _EXTENDABLE_H */
     3NewObjectListDefinition(Extendable);
  • branches/new_class_id/src/world_entities/extendable.h

    r6282 r9685  
    11/*!
    2  * @file proto_class.h
    3  * @brief Interface for Worldentities that can picku up powerups.
     2 * @file extendable.h
     3 * @brief Interface for Worldentities that can pick up powerups.
    44*/
    55
     
    1212class PowerUp;
    1313
     14
    1415#include "power_ups/power_up.h"
    15 
    16 //! A class for ...
     16//! A class for Extendable Entities
    1717class Extendable : virtual public BaseObject {
     18  NewObjectListDeclaration(Extendable);
    1819
    1920  public:
    20    //   virtual ~Extendable();
    2121   virtual bool pickup(PowerUp* powerUp) { return false; };
    2222
    2323  protected:
    24     Extendable() { this->setClassID(CL_EXTENDABLE, "Extendable"); };
    25 
    26   private:
    27 
     24    Extendable() { this->registerObject(this, Extendable::_objectList); };
    2825};
    2926
  • branches/new_class_id/src/world_entities/weapons/ammo_container.h

    r9684 r9685  
    1919
    2020 public:
    21   AmmoContainer(ClassID projectileType, float maxEnergy = DEFAULT_MAX_ENERGY);
     21  AmmoContainer(NewClassID id, float maxEnergy = DEFAULT_MAX_ENERGY);
    2222  virtual ~AmmoContainer();
    2323
    2424  bool operator=(int projectileType) const { return (this->projectileType == projectileType); };
    25   ClassID getProjectileType() const { return this->projectileType; };
     25  NewClassID getProjectileType() const { return this->projectileType; };
    2626
    2727  float increaseEnergy(float energy);
     
    4141   float  maxEnergy;
    4242
    43    ClassID projectileType;
     43   NewClassID projectileType;
    4444};
    4545
  • branches/new_class_id/src/world_entities/weapons/weapon.h

    r8976 r9685  
    8787    Weapon ();
    8888    virtual ~Weapon ();
    89     static Weapon* createWeapon(ClassID weaponID);
     89    static Weapon* createWeapon(NewClassID weaponID);
    9090
    9191    void init();
     
    110110    /** @returns the Capabilities of this Weapon */
    111111    inline long getCapability() const { return this->capability; };
    112     void setProjectileType(ClassID projectile);
     112    void setProjectileType(NewClassID projectile);
    113113    void setProjectileTypeC(const std::string& projectile);
    114114    /** @returns The projectile's classID */
    115     inline ClassID getProjectileType() { return this->projectile; };
     115    inline NewClassID getProjectileType() { return this->projectile; };
    116116    /** @returns the FastFactory, that creates Projectiles of type getProjectile */
    117117    inline FastFactory* getProjectileFactory() { return this->projectileFactory; };
     
    230230    bool                   chargeable;                      //!< if the Weapon is charcheable (if true, the weapon will charge before it fires.)
    231231
    232     ClassID                projectile;                      //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.)
     232    NewClassID                projectile;                      //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.)
    233233    FastFactory*           projectileFactory;               //!< A factory, that produces and handles the projectiles.
    234234  };
  • branches/new_class_id/src/world_entities/weapons/weapon_manager.h

    r8844 r9685  
    8989    void changeWeaponConfig(int weaponConfig);
    9090
    91     float increaseAmmunition(ClassID projectileType, float ammo);
     91    float increaseAmmunition(NewClassID projectileType, float ammo);
    9292    float inclreaseAmmunition(const Weapon* weapon, float ammo);
    9393
     
    106106 // private:
    107107    int getNextFreeSlot(int configID, long capability = WTYPE_ALL);
    108     CountPointer<AmmoContainer>& getAmmoContainer(ClassID projectileType);
     108    CountPointer<AmmoContainer>& getAmmoContainer(NewClassID projectileType);
    109109    CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon);
    110110
Note: See TracChangeset for help on using the changeset viewer.