Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6089 in orxonox.OLD for branches/objectmanager/src


Ignore:
Timestamp:
Dec 13, 2005, 2:58:57 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: objectManager first implementation

Location:
branches/objectmanager/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/objectmanager/src/util/object_manager.cc

    r5828 r6089  
    1919#include "class_list.h"
    2020
    21 #include "p_node.h"
    2221#include "world_entity.h"
    23 #include "list.h"
    2422
    2523using namespace std;
     
    4947  ObjectManager::singletonRef = NULL;
    5048}
     49
     50
     51/**
     52 * @brief moves an Entity from an old list to a new One
     53 * @param entity the entity to move.
     54 * @param omList the new List to move the entity to.
     55 *
     56 * this will erase the entity from the old list
     57 */
     58void ObjectManager::toList (WorldEntity* entity, OM_LIST omList)
     59{
     60  if (likely(entity->getOMListNumber() != OM_INIT))
     61    this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());
     62
     63  if (likely(omList != OM_INIT))
     64  {
     65    this->objectList[omList].push_back(entity);
     66    entity->getOMListNumber() = omList;
     67  }
     68}
     69
     70
     71/**
     72 * @see ObjectManager::toList(WorldEntity* OM_LIST)
     73 * @param entity the entity to move.
     74 * @param omList the new List to move the entity to.
     75 *
     76 * this function also does a transformation from omList as char* to OM_LIST.
     77 */
     78void ObjectManager::toList (WorldEntity* entity, const char* omList)
     79{
     80  this->toList(entity, ObjectManager::StringToOMList( omList));
     81}
     82
     83
    5184
    5285/**
     
    68101  return NULL;
    69102}
     103
     104
     105
     106
     107
     108/**
     109 * @brief transforms an omList into a String (usefull for debugging).
     110 * @param omList the OM_LIST to be transformed into a String.
     111 * @returns the String transformed from omList.
     112 */
     113const char* ObjectManager::StringToOMList(OM_LIST omList)
     114{
     115  switch (omList)
     116  {
     117    case OM_DEAD:
     118      return "dead";
     119    case OM_ENVIRON_NOTICK:
     120      return "environ-notick";
     121    case OM_ENVIRON:
     122      return "environ";
     123    case OM_COMMON:
     124      return "common";
     125    case OM_GROUP_00:
     126      return "group00";
     127    case OM_GROUP_00_PROJ:
     128      return "group00-proj";
     129    case OM_GROUP_01:
     130      return "group01";
     131    case OM_GROUP_01_PROJ:
     132      return "group01-proj";
     133    case OM_GROUP_02:
     134      return "group02";
     135    case OM_GROUP_02_PROJ:
     136      return "group02-proj";
     137    case OM_GROUP_03:
     138      return "group03";
     139    case OM_GROUP_03_PROJ:
     140      return "group03-proj";
     141    case OM_GROUP_04:
     142      return "group04";
     143    case OM_GROUP_04_PROJ:
     144      return "group04-proj";
     145    case OM_GROUP_05:
     146      return "group05";
     147    case OM_GROUP_05_PROJ:
     148      return "group05-proj";
     149    case OM_GROUP_06:
     150      return "group06";
     151    case OM_GROUP_06_PROJ:
     152      return "group06-proj";
     153    case OM_GROUP_07:
     154      return "group07";
     155    case OM_GROUP_07_PROJ:
     156      return "group07-proj";
     157    case OM_GROUP_08:
     158      return "group08";
     159    case OM_GROUP_08_PROJ:
     160      return "group08-proj";
     161    case OM_GROUP_09:
     162      return "group09";
     163    case OM_GROUP_09_PROJ:
     164      return "group09-proj";
     165    case OM_GROUP_10:
     166      return "group10";
     167    case OM_GROUP_10_PROJ:
     168      return "group10-proj";
     169    case OM_GROUP_11:
     170      return "group11";
     171    case OM_GROUP_11_PROJ:
     172      return "group11-proj";
     173    case OM_GROUP_12:
     174      return "group11";
     175    case OM_GROUP_12_PROJ:
     176      return "group12-proj";
     177    case OM_GROUP_13:
     178      return "group03";
     179    case OM_GROUP_13_PROJ:
     180      return "group13-proj";
     181    case OM_GROUP_14:
     182      return "group14";
     183    case OM_GROUP_14_PROJ:
     184      return "group14-proj";
     185    case OM_GROUP_15:
     186      return "group15";
     187    case OM_GROUP_15_PROJ:
     188      return "group15-proj";
     189    default:
     190      return "null";
     191  }
     192
     193}
     194
     195
     196
     197OM_LIST ObjectManager::StringToOMList(const char* listName)
     198{
     199  if (unlikely(listName == NULL)) return OM_DEFAULT_LIST;
     200
     201  if (!strcmp(listName, "dead")) return OM_DEAD;
     202  if (!strcmp(listName, "environ-notick")) return OM_ENVIRON_NOTICK;
     203  if (!strcmp(listName, "environ")) return OM_ENVIRON;
     204  if (!strcmp(listName, "common")) return OM_COMMON;
     205
     206  if (!strcmp(listName, "group00")) return OM_GROUP_00;
     207  if (!strcmp(listName, "group00-proj")) return OM_GROUP_00_PROJ;
     208  if (!strcmp(listName, "group01")) return OM_GROUP_01;
     209  if (!strcmp(listName, "group01-proj")) return OM_GROUP_01_PROJ;
     210  if (!strcmp(listName, "group02")) return OM_GROUP_02;
     211  if (!strcmp(listName, "group02-proj")) return OM_GROUP_02_PROJ;
     212  if (!strcmp(listName, "group03")) return OM_GROUP_03;
     213  if (!strcmp(listName, "group03-proj")) return OM_GROUP_03_PROJ;
     214  if (!strcmp(listName, "group04")) return OM_GROUP_04;
     215  if (!strcmp(listName, "group04-proj")) return OM_GROUP_04_PROJ;
     216  if (!strcmp(listName, "group05")) return OM_GROUP_05;
     217  if (!strcmp(listName, "group05-proj")) return OM_GROUP_05_PROJ;
     218  if (!strcmp(listName, "group06")) return OM_GROUP_06;
     219  if (!strcmp(listName, "group06-proj")) return OM_GROUP_06_PROJ;
     220  if (!strcmp(listName, "group07")) return OM_GROUP_07;
     221  if (!strcmp(listName, "group07-proj")) return OM_GROUP_07_PROJ;
     222  if (!strcmp(listName, "group08")) return OM_GROUP_08;
     223  if (!strcmp(listName, "group08-proj")) return OM_GROUP_08_PROJ;
     224  if (!strcmp(listName, "group09")) return OM_GROUP_09;
     225  if (!strcmp(listName, "group09-proj")) return OM_GROUP_09_PROJ;
     226  if (!strcmp(listName, "group10")) return OM_GROUP_10;
     227  if (!strcmp(listName, "group10-proj")) return OM_GROUP_10_PROJ;
     228  if (!strcmp(listName, "group11")) return OM_GROUP_11;
     229  if (!strcmp(listName, "group11-proj")) return OM_GROUP_11_PROJ;
     230  if (!strcmp(listName, "group12")) return OM_GROUP_12;
     231  if (!strcmp(listName, "group12-proj")) return OM_GROUP_12_PROJ;
     232  if (!strcmp(listName, "group13")) return OM_GROUP_13;
     233  if (!strcmp(listName, "group13-proj")) return OM_GROUP_13_PROJ;
     234  if (!strcmp(listName, "group14")) return OM_GROUP_14;
     235  if (!strcmp(listName, "group14-proj")) return OM_GROUP_14_PROJ;
     236  if (!strcmp(listName, "group15")) return OM_GROUP_15;
     237  if (!strcmp(listName, "group15-proj")) return OM_GROUP_15_PROJ;
     238
     239  return OM_DEFAULT_LIST;
     240}
     241
  • branches/objectmanager/src/util/object_manager.h

    r5795 r6089  
    99#include "base_object.h"
    1010#include <list>
     11#include <vector>
     12
     13/// Enumerator for Managed Object Lists
     14typedef enum {
     15  OM_NULL             =  0,
     16  OM_DEAD,
     17  OM_ENVIRON_NOTICK,
     18  OM_ENVIRON,
     19  OM_COMMON,
     20
     21  OM_GROUP_00,
     22  OM_GROUP_00_PROJ,
     23  OM_GROUP_01,
     24  OM_GROUP_01_PROJ,
     25  OM_GROUP_02,
     26  OM_GROUP_02_PROJ,
     27  OM_GROUP_03,
     28  OM_GROUP_03_PROJ,
     29  OM_GROUP_04,
     30  OM_GROUP_04_PROJ,
     31  OM_GROUP_05,
     32  OM_GROUP_05_PROJ,
     33  OM_GROUP_06,
     34  OM_GROUP_06_PROJ,
     35  OM_GROUP_07,
     36  OM_GROUP_07_PROJ,
     37  OM_GROUP_08,
     38  OM_GROUP_08_PROJ,
     39  OM_GROUP_09,
     40  OM_GROUP_09_PROJ,
     41  OM_GROUP_10,
     42  OM_GROUP_10_PROJ,
     43  OM_GROUP_11,
     44  OM_GROUP_11_PROJ,
     45  OM_GROUP_12,
     46  OM_GROUP_12_PROJ,
     47  OM_GROUP_13,
     48  OM_GROUP_13_PROJ,
     49  OM_GROUP_14,
     50  OM_GROUP_14_PROJ,
     51  OM_GROUP_15,
     52  OM_GROUP_15_PROJ,
     53
     54  OM_SIZE,
     55
     56
     57  OM_INIT             = -1, //!< DO NOT USE THIS. (WorldEntity Internal).
     58} OM_LIST;
     59
     60#define OM_DEFAULT_LIST  OM_NULL
     61
    1162
    1263// FORWARD DECLARATION
    1364class PNode;
    1465class WorldEntity;
    15 
    16 class ObjectGroupList
    17 {
    18 
    19 
    20 
    21 };
    22 
    2366
    2467//! A default singleton class.
     
    2871  virtual ~ObjectManager(void);
    2972  /** @returns a Pointer to the only object of this Class */
    30   inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager();  return ObjectManager::singletonRef; };
     73  inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager();  return ObjectManager::singletonRef; }
    3174
     75
     76  void toList (WorldEntity* entity, OM_LIST omList = OM_DEFAULT_LIST);
     77  void toList (WorldEntity* entity, const char* omList);
     78
     79
     80  std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) { return this->objectLists[listNumber]; }
     81  const std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) const { return this->objectLists[listNumber]; }
    3282
    3383  static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID);
    3484
    35   ObjectGroupList* getGroupList( );
     85
     86  static OM_LIST StringToOMList(const char* listName);
     87  static const char* StringToOMList(OM_LIST omList);
    3688
    3789 private:
     
    3991  static ObjectManager* singletonRef;
    4092
    41   std::list<ObjectGroupList>           groupList;
     93  const std::list<BaseObject>*            pNodeList;
    4294
    43   const std::list<BaseObject>*         pNodeList;
    4495
     96  std::list<WorldEntity*>                 objectLists[OM_SIZE];
    4597
    4698};
  • branches/objectmanager/src/world_entities/world_entity.cc

    r6005 r6089  
    5353
    5454  this->setVisibiliy(true);
     55
     56  this->objectListNumber = OM_INIT;
     57  this->objectListIterator = NULL;
     58
     59  ObjectManager::getInstance()->toList(this, OM_NULL);
    5560}
    5661
     
    6772  for (unsigned int i = 0; i < this->models.size(); i++)
    6873    this->setModel(NULL, i);
     74
     75  ObjectManager::getInstance()->toList(this, OM_INIT);
    6976}
    7077
     
    95102{
    96103  if (fileName != NULL)
    97   { 
     104  {
    98105    // search for the special character # in the LoadParam
    99106    if (strchr(fileName, '#') != NULL)
  • branches/objectmanager/src/world_entities/world_entity.h

    r6005 r6089  
    1111#include "model.h"
    1212
     13#include "object_manager.h"
    1314#include "glincl.h"
    1415#include <vector>
     
    6566  //  CharacterAttributes* getCharacterAttributes();
    6667
    67 
     68  /** @returns a Reference to the objectListNumber to set. */
     69  OM_LIST& getOMListNumber() { return this->objectListNumber; }
     70  /** @returns a Reference to the Iterator */
     71  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
    6872 protected:
    6973  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
    7074
    7175 private:
    72   std::vector<Model*>     models;            //!< The model that should be loaded for this entity.
    73   BVTree*                 obbTree;          //!< this is the obb tree reference needed for collision detection
     76  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
     77  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
    7478
    75   bool                    bCollide;         //!< If it should be considered for the collisiontest.
    76   bool                    bVisible;         //!< If it should be visible.
     79  bool                    bCollide;           //!< If it should be considered for the collisiontest.
     80  bool                    bVisible;           //!< If it should be visible.
     81
     82  OM_LIST                           objectListNumber;   //!< The ObjectList from ObjectManager this Entity is in.
     83  std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
     84
    7785};
    7886
Note: See TracChangeset for help on using the changeset viewer.