Index: trunk/src/util/Makefile.am
===================================================================
--- trunk/src/util/Makefile.am	(revision 6139)
+++ trunk/src/util/Makefile.am	(revision 6142)
@@ -7,5 +7,4 @@
 			object_manager.cc \
                         loading/factory.cc \
-			garbage_collector.cc \
 			state.cc \
 			user_control.cc \
@@ -19,9 +18,8 @@
 			track/pilot_node.cc \
 			track/track_manager.cc \
-			track/track_node.cc 
+			track/track_node.cc
 
 noinst_HEADERS =        fast_factory.h \
 			object_manager.h \
-			garbage_collector.h \
 			state.h \
 			user_control.h \
Index: trunk/src/util/garbage_collector.cc
===================================================================
--- trunk/src/util/garbage_collector.cc	(revision 6139)
+++ 	(revision )
@@ -1,185 +1,0 @@
-/*
-   orxonox - the future of 3D-vertical-scrollers
-
-   Copyright (C) 2004 orx
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   ### File Specific:
-   main-programmer: Patrick Boenzli
-   co-programmer: ...
-*/
-
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GARBAGE_COLLECTOR
-
-#include "garbage_collector.h"
-
-#include "state.h"
-#include "world_entity.h"
-#include "fast_factory.h"
-
-#include "list.h"
-
-using namespace std;
-
-GarbageCollector* GarbageCollector::singletonRef = 0;
-
-/**
- *  standard constructor
-*/
-GarbageCollector::GarbageCollector ()
-{
-   this->setClassID(CL_GARBAGE_COLLECTOR, "GarbageCollector");
-   this->setName("GarbageCollector");
-
-   this->collectedObjects = NULL;
-   this->unusedContainers = NULL;
-
-   this->time = 0;
-   this->delay = 5.0f; /* clean up all 5.0 seconds */
-}
-
-
-/**
- *  standard deconstructor
-*/
-GarbageCollector::~GarbageCollector ()
-{
-  // delete what has to be deleted here
-}
-
-/**
- *  this sets the collection delay
- * @param delay: the delay
-
-   after this delay, the garbage collector starts its work and begins to collect unused object
-   to delete them afterwards. only objects in the worldentity list from the world object are lookded
-   at.
-*/
-void GarbageCollector::setCollectionDelay(float delay)
-{
-  this->delay = delay;
-}
-
-
-/**
- *  this foreces a garbage collection
-
-   if this function is called, the gc tries to initiate the garbage collection routines. actually
-   this should always work.
-*/
-void GarbageCollector::forceCollection()
-{
-  /* just make the time slitely bigger than the delay */
-  this->time = this->delay + 1;
-  /* and update, to get rid of the unused objects */
-  this->update();
-}
-
-
-/**
- * collect an Object, that should be scheduled for clearing.
- * @param object the Object to schedule.
- */
-void GarbageCollector::collect(BaseObject* object)
-{
-  State::getWorldEntityList()->remove(dynamic_cast<WorldEntity*>(object));
-  FastObjectMember* tmpC;
-  if (unlikely(this->unusedContainers == NULL))
-  {
-    tmpC = new FastObjectMember;
-  }
-  else
-  {
-    tmpC = this->unusedContainers;
-    this->unusedContainers = this->unusedContainers->next;
-  }
-
-  tmpC->next = this->collectedObjects;
-  tmpC->objectPointer = object;
-  this->collectedObjects = tmpC;
-}
-
-/**
- *  this ticks the GarbageCollector to give it the time pulse
- * @param time: the time passed since last tick
-
-   like every other tick function eg. worldentity
-*/
-void GarbageCollector::tick(float time)
-{
-  this->time += time;
-}
-
-
-void GarbageCollector::update()
-{
-  if (this->time < this->delay || this->collectedObjects == NULL)
-    return;
-  else
-  {
-    FastObjectMember* tmpC = this->collectedObjects;
-    FastObjectMember* moveC;
-    while (tmpC != NULL)
-    {
-      //WorldEntity* entity = dynamic_cast<WorldEntity*>(tmpC->objectPointer);
-      //State::getWorldEntityList()->remove(entity);
-      //entity->remove();
-      FastFactory::kill(tmpC->objectPointer, true);
-
-      moveC = tmpC->next;
-      tmpC->next = this->unusedContainers;
-      this->unusedContainers = tmpC;
-      tmpC = moveC;
-    }
-    this->collectedObjects = NULL;
-  }
-}
-
-/**
- *  this updated the gargabe collection, if the time is ready
-*/
-// void GarbageCollector::update()
-// {
-//   if( this->time < this->delay)
-//     return;
-//   /* garbage collect */
-//   PRINTF(3)("=============================\n");
-//   PRINTF(3)("Processing Garbage Collection\n");
-//   PRINTF(3)("=============================\n");
-//   int counter = 0;
-//
-//   tList<WorldEntity>* list = State::getWorldEntityList();
-//
-//   tIterator<WorldEntity>* iterator = list->getIterator();
-//   WorldEntity* entity = iterator->firstElement();
-//   while( entity != NULL)
-//     {
-//       if( entity->isFinalized())
-//         {
-//           PRINTF(4)("= finalizing object\n");
-//           ++counter;
-//
-//           /* first remove out of entity list */
-//           list->remove(entity);
-//           /* second remove out of pnode tree */
-//           entity->remove();
-//           /* then finaly delete reference */
-//           //delete entity;
-//           //FastFactory::kill();
-//           //ObjectManager::getInstance()->addToDeadList(entity->getClassID() & CL_MASK_LOWLEVEL_CLASS, entity);
-//         }
-//       entity = iterator->nextElement();
-//     }
-//
-//   PRINTF(3)("= collected %i unused objects\n", counter);
-//   PRINTF(3)("=============================\n");
-//
-//   //ObjectManager::getInstance()->debug();
-//
-//   /* reset time to count again up to this->delay */
-//   this->time = 0;
-// }
Index: trunk/src/util/garbage_collector.h
===================================================================
--- trunk/src/util/garbage_collector.h	(revision 6139)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*!
- * @file garbage_collector.h
- */
-
-#ifndef _GARBAGE_COLLECTOR_H
-#define _GARBAGE_COLLECTOR_H
-
-#include "base_object.h"
-
-// FORWARD DECLARATION
-class FastObjectMember;
-
-//! this class maintains the garbage collection.
-/**
- * you can pass everything to this class that you want to be collected
- * just use GarbageCollector->collect(POINTER); to pass a collectable to the GarbageCollector
- * it will then be handled acording to the class
-*/
-class GarbageCollector : public BaseObject {
-
- public:
-  virtual ~GarbageCollector();
-  /** @returns a Pointer to the only object of this Class */
-  inline static GarbageCollector* getInstance() { if (!singletonRef) singletonRef = new GarbageCollector();  return singletonRef; };
-
-  void setCollectionDelay(float delay);
-
-  void forceCollection();
-
-  void collect(BaseObject* object);
-
-  void tick(float time);
-  void update();
-
- private:
-  GarbageCollector();
-
- private:
-  static GarbageCollector*    singletonRef;           //!< The reference to this class (singleton)
-
-  FastObjectMember*           collectedObjects;       //!< A list of recently collected Objects, that want to be deleted.
-  FastObjectMember*           unusedContainers;       //!< A list of unused containers.
-  float                       delay;                  //!< this is the delay to wait until collection.
-  float                       time;                   //!< the current time
-
-};
-
-#endif /* _GARBAGE_COLLECTOR_H */
Index: trunk/src/util/object_manager.cc
===================================================================
--- trunk/src/util/object_manager.cc	(revision 6139)
+++ trunk/src/util/object_manager.cc	(revision 6142)
@@ -10,5 +10,5 @@
 
    ### File Specific:
-   main-programmer: ...
+   main-programmer: Benjamin Grauer
    co-programmer: ...
 */
@@ -19,13 +19,16 @@
 #include "class_list.h"
 
-#include "p_node.h"
 #include "world_entity.h"
-#include "list.h"
+
+#include "shell_command.h"
+
+#include <assert.h>
 
 using namespace std;
-
-
-/**
- * standard constructor
+SHELL_COMMAND(debug, ObjectManager, debug)
+    ->defaultValues(2, NULL, 0);
+
+/**
+ * @brief standard constructor
  */
 ObjectManager::ObjectManager ()
@@ -37,16 +40,67 @@
 }
 
-/**
- *  the singleton reference to this class
- */
-ObjectManager* ObjectManager::singletonRef = NULL;
-
-/**
-   @brief standard deconstructor
+
+/**
+ * @brief standard deconstructor
+ *
+ * this also removes ALL entitites in existence.
  */
 ObjectManager::~ObjectManager ()
 {
-  ObjectManager::singletonRef = NULL;
-}
+  this->flush();
+}
+
+/**
+ * @brief flushes all entities
+ *
+ * this function deletes all entities that exist within the ObjectManager.
+ * It does this by poping each list from the front, and delete the given object.
+ *
+ * automatically called by a destructor.
+ */
+void ObjectManager::flush()
+{
+  for (unsigned int i = 0; i < OM_SIZE; ++i)
+    while(!this->objectLists[i].empty())
+      delete this->objectLists[i].front();
+}
+
+
+/**
+ * @brief moves an Entity from an old list to a new One
+ * @param entity the entity to move.
+ * @param omList the new List to move the entity to.
+ *
+ * this will erase the entity from the old list
+ */
+void ObjectManager::toList (WorldEntity* entity, OM_LIST omList)
+{
+  assert (omList != OM_SIZE);
+
+  if (likely(entity->getOMListNumber() != OM_INIT))
+    this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());
+
+  if (likely(omList != OM_INIT))
+  {
+    this->objectLists[omList].push_back(entity);
+    entity->getEntityIterator() = --this->objectLists[omList].end();
+    entity->getOMListNumber() = omList;
+  }
+}
+
+
+/**
+ * @see ObjectManager::toList(WorldEntity* OM_LIST)
+ * @param entity the entity to move.
+ * @param omList the new List to move the entity to.
+ *
+ * this function also does a transformation from omList as char* to OM_LIST.
+ */
+void ObjectManager::toList (WorldEntity* entity, const char* omList)
+{
+  this->toList(entity, ObjectManager::StringToOMList(omList));
+}
+
+
 
 /**
@@ -68,2 +122,124 @@
   return NULL;
 }
+
+
+/**
+ * @brief print out nice debug information about Elements in the list OM_LIST
+ * @param omList the List to debug.
+ * @param level: level 0: only show list info; level 1: also show entities and their names.
+ */
+void ObjectManager::debug(OM_LIST omList, unsigned int level) const
+{
+  if (omList != OM_INIT || omList == OM_SIZE)
+  {
+    PRINT(0)(" +ObjectManager-LIST: '%s'==size='%d'==---\n", ObjectManager::OMListToString((OM_LIST)omList), this->objectLists[omList].size());
+  //  if (level >= 1)
+    {
+      std::list<WorldEntity*>::const_iterator entity;
+      for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)
+      {
+        PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName());
+      }
+    }
+  }
+  else
+    PRINTF(2)("Invalid query. for OM_INIT-LIST or OM_SIZE\n");
+}
+
+
+/**
+ * @brief prints out very nice debug information
+ * @param listName the Name of the list to get Debug information from
+ * @param level: level 0: only show list info; level 1: also show entities and their names.
+ */
+void ObjectManager::debug(const char* listName, unsigned int level)
+{
+  PRINT(0)("=================================\n");
+  PRINT(0)("=ObjectManager-DEBUG=============\n");
+  PRINT(0)("=================================\n");
+  if (listName == NULL || listName[0] == '\0')
+    for (unsigned int i = 0; i < OM_SIZE; ++i)
+      debug((OM_LIST) i, level);
+  else
+    debug(ObjectManager::StringToOMList(listName));
+  PRINT(0)("=========================== OM ==\n");
+}
+
+
+
+/**
+ * @brief transforms an omList into a String (usefull for debugging).
+ * @param omList the OM_LIST to be transformed into a String.
+ * @returns the String transformed from omList.
+ */
+const char* ObjectManager::OMListToString(OM_LIST omList)
+{
+  if (omList == OM_INIT || omList == OM_SIZE)
+    return "===invalid===";
+
+  printf("%d\n", omList);
+  return ObjectManager::objectManagerListNames[omList];
+}
+
+
+
+/**
+ * @brief transforms a String into an OM_LIST (usefull for debugging/Loading).
+ * @param listName the OM_LIST-name to be transformed into an OM_LIST.
+ * @returns the OM_LIST transformed from listName. or the default, if not found or NULL.
+ */
+OM_LIST ObjectManager::StringToOMList(const char* listName)
+{
+  if (unlikely(listName == NULL)) return OM_DEFAULT_LIST;
+
+  for(unsigned int i = 0; i < OM_SIZE; ++i) {
+    if(!strcmp(listName, ObjectManager::objectManagerListNames[i])) {
+      return (OM_LIST)i;
+    }
+  }
+  return OM_DEFAULT_LIST;
+}
+
+
+
+const char* ObjectManager::objectManagerListNames[] = {
+    "null",
+    "dead",
+    "dead-tick",
+    "environ-notick",
+    "environ",
+    "common",
+
+    "group00",
+    "group00-proj",
+    "group01",
+    "group01-proj",
+    "group02",
+    "group02-proj",
+    "group03",
+    "group03-proj",
+    "group04",
+    "group04-proj",
+    "group05",
+    "group05-proj",
+    "group06",
+    "group06-proj",
+    "group07",
+    "group07-proj",
+    "group08",
+    "group08-proj",
+    "group09",
+    "group09-proj",
+    "group10",
+    "group10-proj",
+    "group11",
+    "group11-proj",
+    "group12",
+    "group12-proj",
+    "group13",
+    "group13-proj",
+    "group14",
+    "group14-proj",
+    "group15",
+    "group15-proj"
+};
Index: trunk/src/util/object_manager.h
===================================================================
--- trunk/src/util/object_manager.h	(revision 6139)
+++ trunk/src/util/object_manager.h	(revision 6142)
@@ -1,6 +1,6 @@
 /*!
  * @file object_manager.h
- * @brief Definition of the ... singleton Class
-*/
+ * @brief Definition of the ObjectManager.
+ */
 
 #ifndef _OBJECT_MANAGER_H
@@ -9,4 +9,56 @@
 #include "base_object.h"
 #include <list>
+#include <vector>
+
+/// Enumerator for Managed Object Lists
+typedef enum {
+  OM_NULL             =  0,
+  OM_DEAD,
+  OM_DEAD_TICK,
+  OM_ENVIRON_NOTICK,
+  OM_ENVIRON,
+  OM_COMMON,
+
+  OM_GROUP_00,
+  OM_GROUP_00_PROJ,
+  OM_GROUP_01,
+  OM_GROUP_01_PROJ,
+  OM_GROUP_02,
+  OM_GROUP_02_PROJ,
+  OM_GROUP_03,
+  OM_GROUP_03_PROJ,
+  OM_GROUP_04,
+  OM_GROUP_04_PROJ,
+  OM_GROUP_05,
+  OM_GROUP_05_PROJ,
+  OM_GROUP_06,
+  OM_GROUP_06_PROJ,
+  OM_GROUP_07,
+  OM_GROUP_07_PROJ,
+  OM_GROUP_08,
+  OM_GROUP_08_PROJ,
+  OM_GROUP_09,
+  OM_GROUP_09_PROJ,
+  OM_GROUP_10,
+  OM_GROUP_10_PROJ,
+  OM_GROUP_11,
+  OM_GROUP_11_PROJ,
+  OM_GROUP_12,
+  OM_GROUP_12_PROJ,
+  OM_GROUP_13,
+  OM_GROUP_13_PROJ,
+  OM_GROUP_14,
+  OM_GROUP_14_PROJ,
+  OM_GROUP_15,
+  OM_GROUP_15_PROJ,
+
+  OM_SIZE,
+
+
+  OM_INIT             = -1, //!< DO NOT USE THIS. (WorldEntity Internal).
+} OM_LIST;
+
+#define OM_DEFAULT_LIST  OM_NULL
+
 
 // FORWARD DECLARATION
@@ -14,34 +66,35 @@
 class WorldEntity;
 
-class ObjectGroupList
-{
-
-
-
-};
-
-
-//! A default singleton class.
+//! A powerfull handler for the Object (WorldEntities) in the World.
 class ObjectManager : public BaseObject {
 
  public:
-  virtual ~ObjectManager(void);
-  /** @returns a Pointer to the only object of this Class */
-  inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager();  return ObjectManager::singletonRef; };
+   ObjectManager();
+   virtual ~ObjectManager();
 
+  void flush();
+
+  void toList (WorldEntity* entity, OM_LIST omList = OM_DEFAULT_LIST);
+  void toList (WorldEntity* entity, const char* omList);
+
+
+  std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) { return this->objectLists[listNumber]; }
+  const std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) const { return this->objectLists[listNumber]; }
 
   static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID);
 
-  ObjectGroupList* getGroupList( );
+  void debug(OM_LIST omList, unsigned int level = 0) const;
+  void debug(const char* listName = NULL, unsigned int level = 0);
+
+  static OM_LIST StringToOMList(const char* listName);
+  static const char* OMListToString(OM_LIST omList);
 
  private:
-  ObjectManager(void);
-  static ObjectManager* singletonRef;
-
-  std::list<ObjectGroupList>           groupList;
-
-  const std::list<BaseObject>*         pNodeList;
+  const std::list<BaseObject>*            pNodeList;
 
 
+  std::list<WorldEntity*>                 objectLists[OM_SIZE];
+
+  static const char*                      objectManagerListNames[]; //!< Names of all the lists
 };
 
Index: trunk/src/util/state.cc
===================================================================
--- trunk/src/util/state.cc	(revision 6139)
+++ trunk/src/util/state.cc	(revision 6142)
@@ -29,5 +29,5 @@
 const PNode* State::cameraTarget = NULL;
 
-tList<WorldEntity>* State::worldEntityList = NULL;
+ObjectManager* State::objectManager = NULL;
 
 /**
Index: trunk/src/util/state.h
===================================================================
--- trunk/src/util/state.h	(revision 6139)
+++ trunk/src/util/state.h	(revision 6142)
@@ -10,6 +10,5 @@
 class PNode;
 class WorldEntity;
-template<class T> class tList;
-//template<class T> class tStack;
+class ObjectManager;
 
 //! handles states about orxonox's most importatn objects
@@ -22,5 +21,7 @@
 
  public:
-  // CAMERA //
+   //////////////
+   /// CAMERA ///
+   //////////////
   /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
   static void setCamera(const PNode* camera, const PNode* cameraTarget);
@@ -30,9 +31,15 @@
   static inline const PNode* getCameraTarget() { return State::cameraTarget; };
 
-  // WORLD_ENTITY_LIST //
-  /** @param worldEntityList The World's List of WorldEntities */
-  static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; };
-  /** @returns the List of WorldEntities */
-  static inline tList<WorldEntity>* getWorldEntityList() { return State::worldEntityList; };
+  //////////////////////
+  /// OBJECT-MANAGER ///
+  //////////////////////
+  /** @param objectManager the new Current ObjectManager */
+  static inline void setObjectManager(ObjectManager* objectManager) { State::objectManager = objectManager; };
+  /** @returns the current ObjectManager. */
+  static inline ObjectManager* getObjectManager() { return State::objectManager; };
+
+  /////////////////////////
+  /// WORLD_ENTITY_LIST ///
+  /////////////////////////
 
  private:
@@ -42,8 +49,6 @@
   static const PNode*           cameraTarget;       //!< A reference to the cameraTarget
   static PNode*                 nullParent;         //!< A reference to the Null-PNode.
+  static ObjectManager*         objectManager;      //!< A referenct to the current ObjectManager
 
-  static tList<WorldEntity>*    worldEntityList;    //!< The List of the worldEntities
-
-  //tStack<
 };
 
