Index: /trunk/src/story_entities/network_world.cc
===================================================================
--- /trunk/src/story_entities/network_world.cc	(revision 6344)
+++ /trunk/src/story_entities/network_world.cc	(revision 6345)
@@ -20,16 +20,14 @@
 
 #include "shell_command.h"
-
+#include "resource_manager.h"
 #include "state.h"
 
 #include "p_node.h"
-#include "pilot_node.h"
 #include "world_entity.h"
 #include "player.h"
 #include "camera.h"
 #include "environment.h"
-#include "skysphere.h"
-#include "skybox.h"
-#include "satellite.h"
+#include "terrain.h"
+
 #include "test_entity.h"
 #include "terrain.h"
@@ -91,29 +89,8 @@
 
 /**
-  *  create a new NetworkWorld
-
-    This creates a new empty world!
-*/
-NetworkWorld::NetworkWorld (const char* name)
-{
-  this->path = NULL;
-  this->constuctorInit(name, -1);
-}
-
-/**
- *  creates a new NetworkWorld...
- * @param worldID with this ID
-*/
-NetworkWorld::NetworkWorld (int worldID)
-{
-  this->path = NULL;
-  this->constuctorInit(NULL, worldID);
-}
-
-/**
  *  remove the NetworkWorld from memory
-
-    delete everything explicitly, that isn't contained in the parenting tree!
-    things contained in the tree are deleted automaticaly
+ *
+ *  delete everything explicitly, that isn't contained in the parenting tree!
+ *  things contained in the tree are deleted automaticaly
  */
 NetworkWorld::~NetworkWorld ()
@@ -150,6 +127,4 @@
   // unload the resources !!
   ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
-
-  delete[] this->path;
 }
 
@@ -171,5 +146,4 @@
 
   this->setName(name);
-  this->debugNetworkWorldNr = worldID;
   this->gameTime = 0.0f;
   this->setSpeed(1.0);
@@ -228,4 +202,5 @@
 
   GraphicsEngine::getInstance()->displayFPS(true);
+  this->displayLoadScreen();
 }
 
@@ -233,5 +208,5 @@
 /**
  *  loads the NetworkWorld by initializing all resources, and set their default values.
-*/
+ */
 ErrorMessage NetworkWorld::load()
 {
@@ -242,7 +217,6 @@
   if( getPath() == NULL)
     {
-      PRINTF(1)("NetworkWorld has no path specified for loading");
-      this->loadDebugNetworkWorld(this->getStoryID());
-      return (ErrorMessage){213,"Path not specified","NetworkWorld::load()"};
+      PRINTF(1)("World has no path specified for loading");
+      return (ErrorMessage){213,"Path not specified","World::load()"};
     }
 
@@ -323,6 +297,6 @@
       if( created != NULL )
       {
-        if(created->isA(CL_SPAWNING_POINT))
-          this->spawn(dynamic_cast<WorldEntity*>(created));
+//        if(created->isA(CL_SPAWNING_POINT))
+//          this->spawn(dynamic_cast<WorldEntity*>(created));
         printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName());
       }
@@ -357,6 +331,6 @@
         if( created != NULL )
         {
-          if(created->isA(CL_WORLD_ENTITY))
-            this->spawn(dynamic_cast<WorldEntity*>(created));
+//          if(created->isA(CL_WORLD_ENTITY))
+//            this->spawn(dynamic_cast<WorldEntity*>(created));
           printf("Created a %s: %s\n", created->getClassName(), created->getName());
         }
@@ -369,9 +343,10 @@
           //todo do this more elegant
         if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
-          sky = dynamic_cast<SkyBox*>(created);
+          sky = dynamic_cast<WorldEntity*>(created);
         if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
         {
           terrain = dynamic_cast<Terrain*>(created);
           CDEngine::getInstance()->setTerrain(terrain);
+
         }
 
@@ -382,6 +357,6 @@
         if( created != NULL )
         {
-          if(created->isA(CL_WORLD_ENTITY))
-            this->spawn(dynamic_cast<WorldEntity*>(created));
+//          if(created->isA(CL_WORLD_ENTITY))
+//            this->spawn(dynamic_cast<WorldEntity*>(created));
           printf("Created a %s: %s\n", created->getClassName(), created->getName());
         }
@@ -394,5 +369,5 @@
           //todo do this more elegant
         if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
-          sky = dynamic_cast<SkyBox*>(created);
+          sky = dynamic_cast<WorldEntity*>(created);
         if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
         {
@@ -434,24 +409,14 @@
   }
 
-  // bind camera
-  playable->addChild (this->localCamera);
 
 //   //localCamera->setParent(TrackNode::getInstance());
 //  tn->addChild(this->localCamera);
   localCamera->setClipRegion(1, 10000.0);
-  localCamera->lookAt(playable);
+//  localCamera->lookAt(playable);
 //  this->localPlayer->setParentMode(PNODE_ALL);
-  if (sky != NULL)
-  {
-    this->sky->setParent(this->localCamera);
-    this->sky->setParentMode(PNODE_MOVEMENT);
-  }
-
-  // initialize debug coord system
-  objectList = glGenLists(1);
-  glNewList (objectList, GL_COMPILE);
-
-  glEndList();
-
+  if (this->sky != NULL)
+  {
+    this->localCamera->addChild(sky);
+  }
   SoundEngine::getInstance()->setListener(this->localCamera);
 
@@ -483,10 +448,5 @@
 }
 
-
-
-/**
- * creates a debug world: only for experimental stuff
-*/
-void NetworkWorld::loadDebugNetworkWorld(int worldID)
+ErrorMessage NetworkWorld::postLoad()
 {
   /*monitor progress*/
@@ -499,58 +459,7 @@
   LightManager::getInstance()->debug();
 
-  switch(this->debugNetworkWorldNr)
-    {
-      /*
-        this loads the hard-coded debug world. this only for simplicity and will be
-        removed by a reald world-loader, which interprets a world-file.
-        if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and
-        make whatever you want...
-      */
-    case DEBUG_WORLD_0:
-      {
-        LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);
-        /*monitor progress*/
-        this->glmis->step();
-
-        // bind camera
-        this->localCamera = new Camera();
-        this->localCamera->setName ("camera");
-        /*monitor progress*/
-        this->glmis->step();
-
-
-        // Create SkySphere
-        this->sky = new Skysphere("pictures/sky-replace.jpg");
-        this->sky->setName("SkySphere");
-        this->spawn(this->sky);
-        this->localCamera->addChild(this->sky);
-        this->sky->setParentMode(PNODE_MOVEMENT);
-        /*monitor progress*/
-        this->glmis->step();
-
-
-        terrain = new Terrain("worlds/newGround.obj");
-        terrain->setRelCoor(Vector(0,-10,0));
-        this->spawn(terrain);
-        /*monitor progress*/
-        this->glmis->step();
-
-        this->glmis->step();
-        break;
-      }
-    case DEBUG_WORLD_1:
-      {
-
-        break;
-      }
-    case DEBUG_WORLD_2:
-      {
-
-        break;
-      }
-    default:
-      break;
-    }
-}
+  this->releaseLoadScreen();
+}
+
 
 /**
@@ -560,5 +469,5 @@
  * started
 */
-ErrorMessage NetworkWorld::init()
+ErrorMessage NetworkWorld::preStart()
 {
   this->bPause = false;
@@ -567,5 +476,4 @@
   PNode::getNullParent()->updateNode (0.001f);
   PNode::getNullParent()->updateNode (0.001f);
-
 }
 
@@ -573,10 +481,8 @@
 /**
  *  starts the NetworkWorld
-*/
+ */
 ErrorMessage NetworkWorld::start()
 {
-  PRINTF(3)("NetworkWorld::start() - starting current NetworkWorld: nr %i\n", this->debugNetworkWorldNr);
-  this->bQuitOrxonox = false;
-  this->bQuitCurrentGame = false;
+  this->bQuitWorld = false;
   this->mainLoop();
 }
@@ -590,5 +496,5 @@
 {
   PRINTF(3)("NetworkWorld::stop() - got stop signal\n");
-  this->bQuitCurrentGame = true;
+  this->bQuitWorld= true;
 }
 
@@ -632,7 +538,7 @@
 
 /**
- *  removes the loadscreen, and changes over to the game
-
-   @todo take out the delay
+ * @brief removes the loadscreen, and changes over to the game
+ *
+ * @todo take out the delay
 */
 void NetworkWorld::releaseLoadScreen ()
@@ -655,24 +561,5 @@
 
 /**
- *  function to put your own debug stuff into it. it can display informations about
-   the current class/procedure
-*/
-// void NetworkWorld::debug()
-// {
-//   PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");
-//   tIterator<WorldEntity>* iterator = this->entities->getIterator();
-//   WorldEntity* entity = iterator->firstElement();
-//   while( entity != NULL)
-//   {
-//     PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());
-//     entity = iterator->nextElement();
-//   }
-//   delete iterator;
-// }
-
-
-/**
   \brief main loop of the world: executing all world relevant function
-
   in this loop we synchronize (if networked), handle input events, give the heart-beat to
   all other member-entities of the world (tick to player, enemies etc.), checking for
@@ -682,25 +569,24 @@
 {
   this->lastFrame = SDL_GetTicks ();
-  PRINTF(3)("NetworkWorld::mainLoop() - Entering main loop\n");
-
-  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */
-    {
-      ++this->cycle;
-//      PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());
+  PRINTF(3)("World::mainLoop() - Entering main loop\n");
+
+  while(!this->bQuitWorld) /* @todo implement pause */
+  {
+    ++this->cycle;
       // Network
-      this->synchronize ();
+    this->synchronize ();
       // Process input
-      this->handleInput ();
-      if( this->bQuitCurrentGame || this->bQuitOrxonox)
-          break;
+    this->handleInput ();
+    if( this->bQuitWorld)
+      break;
       // Process time
-      this->tick ();
+    this->tick ();
       // Process collision
-      this->collide ();
+    this->collide ();
       // Update the state
-      this->update ();
+    this->update ();
       // Draw
-      this->display ();
-    }
+    this->display ();
+  }
 
   PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n");
@@ -775,7 +661,7 @@
       this->gameTime += this->dtS;
 
-/*      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
+      this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);
       this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);
-      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/
+      this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);
       this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);
       this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);
@@ -815,5 +701,4 @@
   GraphicsEngine::getInstance()->update(this->dtS);
   PNode::getNullParent()->updateNode (this->dtS);
-
   SoundEngine::getInstance()->update();
   //music->update();
@@ -864,13 +749,21 @@
   engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
 
+   if( unlikely( this->showBV))  // to draw the bounding boxes of the objects at level 2 for debug purp
+   {
+     CDEngine* engine = CDEngine::getInstance();
+     engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));
+     engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON));
+     engine->drawBV(State::getObjectManager()->getObjectList(OM_COMMON));
+     engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_00));
+     engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01));
+     engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));
+   }
+
 //   {
 //     if( entity->isVisible() ) entity->draw();
   //FIXME
-//     if( unlikely( this->showBV)) entity->drawBVTree(3, 226);  // to draw the bounding boxes of the objects at level 2 for debug purp
 //     entity = iterator->nextElement();
 //   }
 
-  glCallList (objectList);
-
   ParticleEngine::getInstance()->draw();
 
@@ -880,56 +773,4 @@
   engine->draw();
   //TextEngine::getInstance()->draw();
-}
-
-/**
- *  add and spawn a new entity to this world
- * @param entity to be added
-*/
-void NetworkWorld::spawn(WorldEntity* entity)
-{
-//   this->entities->add (entity);
-  entity->postSpawn ();
-
-}
-
-
-/**
- *  add and spawn a new entity to this world
- * @param entity to be added
- * @param absCoor At what coordinates to add this entity.
- * @param absDir In which direction should it look.
-*/
-void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)
-{
-//   this->entities->add (entity);
-
-  entity->setAbsCoor (*absCoor);
-  entity->setAbsDir (*absDir);
-
-  entity->postSpawn ();
-}
-
-
-/**
- *  add and spawn a new entity to this world
- * @param entity to be added
- * @param entity to be added to (PNode)
- * @param At what relative  coordinates to add this entity.
- * @param In which relative direction should it look.
-*/
-void NetworkWorld::spawn(WorldEntity* entity, PNode* parentNode,
-                  Vector* relCoor, Quaternion* relDir)
-{
-  if( parentNode != NULL)
-    {
-      parentNode->addChild (entity);
-
-      entity->setRelCoor (*relCoor);
-      entity->setRelDir (*relDir);
-
-//       this->entities->add (entity);
-
-      entity->postSpawn ();
-    }
 }
 
Index: /trunk/src/story_entities/network_world.h
===================================================================
--- /trunk/src/story_entities/network_world.h	(revision 6344)
+++ /trunk/src/story_entities/network_world.h	(revision 6345)
@@ -7,8 +7,6 @@
 #define _WORLD_H
 
-#include "stdincl.h"
-#include "comincl.h"
+#include "sdlincl.h"
 #include "story_entity.h"
-#include "p_node.h"
 #include "object_manager.h"
 
@@ -33,6 +31,4 @@
 
  public:
-  NetworkWorld (const char* name);
-  NetworkWorld (int worldID);
   NetworkWorld (const TiXmlElement* root = NULL);
   virtual ~NetworkWorld ();
@@ -45,5 +41,7 @@
   virtual ErrorMessage preLoad();
   virtual ErrorMessage load ();
-  virtual ErrorMessage init ();
+  virtual ErrorMessage postLoad();
+
+  virtual ErrorMessage preStart();
   virtual ErrorMessage start ();
   virtual ErrorMessage stop ();
@@ -52,16 +50,9 @@
   virtual ErrorMessage destroy ();
 
-  void loadDebugNetworkWorld(int worldID);
-
-  virtual void displayLoadScreen();
-  virtual void releaseLoadScreen();
-
-  /* command node functions */
-  bool command (Command* cmd);
+  void displayLoadScreen();
+  void releaseLoadScreen();
 
   /* interface to world */
-  void spawn (WorldEntity* entity);
-  void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);
-  void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);
+//  void spawn (WorldEntity* entity);
 
   /** @param speed sets the speed of the Game */
@@ -69,6 +60,4 @@
   const char* getPath();
   void setPath( const char* name);
-
-  inline Camera* getLocalCamera() { return this->localCamera; };
 
   void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; };
@@ -78,5 +67,4 @@
   void constuctorInit(const char* name, int worldID);
   /* function for main-loop */
-  void mainLoop ();
   void synchronize ();
   void handleInput ();
@@ -86,10 +74,20 @@
   void collide ();
   void draw ();
+  void mainLoop ();
+
   void display ();
   void debug ();
 
   private:
-    bool   showPNodes;                  //!< if the PNodes should be visible.
-    bool   showBV;                      //!< if the Bounding Volumes should be visible.
+    char* path;                         //!< The file from which this world is loaded
+
+    // FLAGS //
+    bool bQuitWorld;                    //!< quit only the current game and return to menu
+    bool bPause;                        //!< pause mode
+
+    bool showPNodes;                    //!< if the PNodes should be visible.
+    bool showBV;                        //!< if the Bounding Volumes should be visible.
+
+    // TIMING //
     Uint32 lastFrame;                   //!< last time of frame
     Uint32 cycle;                       //!< The cycle we are in (starts with 0 and rises with every frame)
@@ -98,26 +96,19 @@
     float speed;                        //!< how fast the game flows
     double gameTime;                    //!< this is where the game time is saved
-    bool bQuitOrxonox;                  //!< quit this application
-    bool bQuitCurrentGame;              //!< quit only the current game and return to menu
-    bool bPause;                        //!< pause mode
 
-    ObjectManager      objectManager;   //!< The ObjectManager of this World.
+    // INTERNAL ENGINES
+    ObjectManager objectManager;        //!< The ObjectManager of this World.
+    Shell*     shell;
+    OggPlayer* music;
 
     GLMenuImageScreen* glmis;           //!< The Level-Loader Display
 
-    int debugNetworkWorldNr;                   //!< The Debug Nr. needed, if something goes wrong
-    char* path;                         //!< The file from which this world is loaded
 
-    Shell*     shell;
-    OggPlayer* music;
+    // IMPORTANT ENTITIES
+    Camera* localCamera;                //!< The current Camera
+    Player* localPlayer;                //!< The Player, you fly through the level.
 
-  // IMPORTANT WORLD-ENTITIES
-    Camera* localCamera;                //!< The current Camera
     WorldEntity* sky;                   //!< The Environmental Heaven of orxonox @todo insert this to environment insted
     Terrain* terrain;                   //!< The Terrain of the NetworkWorld.
-
-    GLuint objectList;                  //!< temporary: @todo this will be ereased soon
-
-    Player* localPlayer;                //!< The Player, you fly through the level.
 };
 
