Index: orxonox/branches/physics/src/story_entities/world.cc
===================================================================
--- orxonox/branches/physics/src/story_entities/world.cc	(revision 4274)
+++ orxonox/branches/physics/src/story_entities/world.cc	(revision 4283)
@@ -33,4 +33,5 @@
 #include "skybox.h"
 #include "satellite.h"
+#include "test_entity.h"
 #include "terrain.h"
 #include "light.h"
@@ -41,4 +42,5 @@
 #include "animation_player.h"
 #include "particle_engine.h"
+#include "graphics_engine.h"
 
 #include "command_node.h"
@@ -53,4 +55,6 @@
 #include "substring.h"
 
+#include "factory.h"
+
 using namespace std;
 
@@ -121,46 +125,10 @@
 CREATE_FACTORY(World);
 
-World::World( TiXmlElement* root)
+World::World(const TiXmlElement* root)
 {
   this->constuctorInit("", -1);
   this->path = NULL;
-  const char *string;
-  char *name;
-  int id;
-  
-  PRINTF0("Creating a World\n");
-  
-  // identifier
-  string = grabParameter( root, "identifier");
-  if( string == NULL || sscanf(string, "%d", &id) != 1)
-    {
-      PRINTF0("World is missing a proper 'identifier'\n");
-      this->setStoryID( -1);
-    }
-  else setStoryID( id);
-
-  // next id
-  string = grabParameter( root, "nextid");
-  if( string == NULL || sscanf(string, "%d", &id) != 1)
-    {
-      PRINTF0("World is missing a proper 'nextid'\n");
-      this->setStoryID( -1);
-    }
-  else setNextStoryID( id);
-  
-
-  // path
-  string = grabParameter( root, "path");
-  if( string == NULL)
-    {
-      PRINTF0("World is missing a proper 'path'\n");
-      this->setPath( NULL);
-    }
-  else
-    {
-      name = new char[strlen(string + 2)];
-      strcpy( name, string);
-      this->setPath( name);
-    }
+  
+  this->loadParams(root);
 }
 
@@ -201,5 +169,4 @@
 
   delete WorldInterface::getInstance();
-
   delete this->nullParent;
   delete this->entities;
@@ -208,9 +175,10 @@
   delete this->particleEngine;
   TextEngine::getInstance()->flush();
-
   delete PhysicsEngine::getInstance();
   delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence.
   //delete garbagecollecor
   //delete animator
+
+  LoadClassDescription::printAll();
 
   ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
@@ -237,4 +205,56 @@
 }
 
+void World::loadParams(const TiXmlElement* root)
+{
+  const char *string;
+  char *name;
+  int id;
+
+  PRINTF0("Creating a World\n");
+
+  LoadParam<World>(root, "identifier", this, &World::setStoryID)
+    .describe("Sets the StoryID of this world");
+  LoadParam<World>(root, "nextid", this, &World::setNextStoryID)
+    .describe("Sets the ID of the next world");
+  LoadParam<World>(root, "path", this, &World::setPath)
+    .describe("The Filename of this World (relative from the data-dir)");
+
+
+  /*  
+  // identifier
+  string = grabParameter( root, "identifier");
+  if( string == NULL || sscanf(string, "%d", &id) != 1)
+  {
+  PRINTF0("World is missing a proper 'identifier'\n");
+  this->setStoryID( -1);
+  }
+  else setStoryID( id);
+
+  // next id
+  string = grabParameter( root, "nextid");
+  if( string == NULL || sscanf(string, "%d", &id) != 1)
+  {
+  PRINTF0("World is missing a proper 'nextid'\n");
+  this->setStoryID( -1);
+  }
+  else setNextStoryID( id);
+  
+
+  // path
+  string = grabParameter( root, "path");
+  if( string == NULL)
+  {
+  PRINTF0("World is missing a proper 'path'\n");
+  this->setPath( NULL);
+  }
+  else
+  {
+  name = new char[strlen(string + 2)];
+  strcpy( name, string);
+  this->setPath( name);
+  }
+  */
+}
+
 
 /**
@@ -262,4 +282,6 @@
   this->localCamera = new Camera();
   this->localCamera->setName ("camera");
+  
+  GraphicsEngine::getInstance()->displayFPS(true);
 }
 
@@ -334,5 +356,5 @@
   else
     {
-      this->glmis->load(element);
+      this->glmis->loadParams(element);
       this->glmis->draw();
     }
@@ -368,14 +390,13 @@
   if( element == NULL)
     {
-      PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n");
+      PRINTF(0)("World is missing a 'Track'\n");
     }
   else
     {	
       //load track
-      PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n");
+      PRINTF(4)("Loading Track\n");
 
       trackManager->load( element);
       trackManager->finalize();
-      PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n");
     }
   
@@ -392,65 +413,6 @@
   //this->localCamera->bind (localPlayer);
   this->localPlayer->addChild (this->localCamera);
-  
-  
-  // stuff beyond this point remains to be loaded properly
-  /*
-      // initializing the TrackManager
-  this->trackManager = TrackManager::getInstance();
-      //trackManager->addPoint(Vector(0,0,0));
-      trackManager->addPoint(Vector(150, -35, 5));
-      trackManager->addPoint(Vector(200,-35, 5));
-      trackManager->addPoint(Vector(250, -35, 5));
-      trackManager->addPoint(Vector(320,-33,-.55));
-      trackManager->setDuration(1);
-      trackManager->setSavePoint();
-
-      trackManager->addPoint(Vector(410, 0, 0));
-      trackManager->addPoint(Vector(510, 20, -10));
-      trackManager->addPoint(Vector(550, 20, -10));
-      trackManager->addPoint(Vector(570, 20, -10));
-      trackManager->setDuration(2);
       
-      trackManager->forkS("testFork1,testFork2");
-      trackManager->workOn("testFork1");
-      trackManager->addPoint(Vector(640, 25, -30));
-      trackManager->addPoint(Vector(700, 40, -120));
-      trackManager->addPoint(Vector(800, 50, -150));
-      trackManager->addPoint(Vector(900, 60, -100));
-      trackManager->addPoint(Vector(900, 60, -70));
-      trackManager->addPoint(Vector(990, 65, -15));
-      trackManager->addPoint(Vector(1050, 65, -10));
-      trackManager->addPoint(Vector(1100, 65, -20));
-      trackManager->setDuration(4);
-
-      trackManager->workOn("testFork2");
-      trackManager->addPoint(Vector(640, 25, 20));
-      trackManager->addPoint(Vector(670, 50, 120));
-      trackManager->addPoint(Vector(700, 70, 80));
-      trackManager->addPoint(Vector(800, 70, 65));
-      trackManager->addPoint(Vector(850, 65, 65));
-      trackManager->addPoint(Vector(920, 35, 40));
-      trackManager->addPoint(Vector(945, 40, 40));
-      trackManager->addPoint(Vector(970, 24, 40));
-      trackManager->addPoint(Vector(1000, 40, -7));
-      trackManager->setDuration(4);
-      
-      
-      trackManager->joinS("testFork1,testFork2");
-	
-      trackManager->addPoint(Vector(1200, 60, -50));
-      trackManager->addPoint(Vector(1300, 50, -50));
-      trackManager->addPoint(Vector(1400, 40, -50));
-      trackManager->addPoint(Vector(1500, 40, -60));
-      trackManager->addPoint(Vector(1600, 35, -55));
-      trackManager->addPoint(Vector(1700, 45, -40));
-      trackManager->addPoint(Vector(1750, 60, -40));
-      trackManager->addPoint(Vector(1770, 80, -40));
-      trackManager->addPoint(Vector(1800, 100, -40));
-      trackManager->setDuration(10);
-  */
-      trackManager->finalize();
-
-      
+
   lightMan->setAmbientColor(.1,.1,.1);
   lightMan->addLight();
@@ -460,5 +422,5 @@
   //  lightMan->setPosition(20, 10, -20);
   //  lightMan->setDiffuseColor(0,0,0);
-  lightMan->debug();
+  //lightMan->debug();
   lightMan->setPosition(-5.0, 10.0, -40.0);
   
@@ -481,6 +443,6 @@
   glNewList (objectList, GL_COMPILE);
   
-  trackManager->drawGraph(.01);
-  trackManager->debug(2);
+  //trackManager->drawGraph(.01);
+  //trackManager->debug(2);
   glEndList();
 
@@ -519,5 +481,13 @@
   //    new PhysicsConnection(system, gravity);
 
-}
+
+  WorldEntity* testEntity = new TestEntity();
+  //testEntity->setRelCoor(Vector(570, 10, -15));
+  testEntity->setRelCoor(Vector(25, -10, -20));
+  testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
+  this->spawn(testEntity);
+  this->localPlayer->addChild(testEntity);
+}
+
 
 void World::loadDebugWorld(int worldID)
@@ -525,7 +495,64 @@
   /*monitor progress*/
   this->glmis->step();
+  // stuff beyond this point remains to be loaded properly
+
+  // initializing the TrackManager
+  this->trackManager = TrackManager::getInstance();
+  //trackManager->addPoint(Vector(0,0,0));
+  trackManager->addPoint(Vector(150, -35, 5));
+  trackManager->addPoint(Vector(200,-35, 5));
+  trackManager->addPoint(Vector(250, -35, 5));
+  trackManager->addPoint(Vector(320,-33,-.55));
+  trackManager->setDuration(1);
+  trackManager->setSavePoint();
+
+  trackManager->addPoint(Vector(410, 0, 0));
+  trackManager->addPoint(Vector(510, 20, -10));
+  trackManager->addPoint(Vector(550, 20, -10));
+  trackManager->addPoint(Vector(570, 20, -10));
+  trackManager->setDuration(2);
+      
+  trackManager->forkS("testFork1,testFork2");
+  trackManager->workOn("testFork1");
+  trackManager->addPoint(Vector(640, 25, -30));
+  trackManager->addPoint(Vector(700, 40, -120));
+  trackManager->addPoint(Vector(800, 50, -150));
+  trackManager->addPoint(Vector(900, 60, -100));
+  trackManager->addPoint(Vector(900, 60, -70));
+  trackManager->addPoint(Vector(990, 65, -15));
+  trackManager->addPoint(Vector(1050, 65, -10));
+  trackManager->addPoint(Vector(1100, 65, -20));
+  trackManager->setDuration(4);
+
+  trackManager->workOn("testFork2");
+  trackManager->addPoint(Vector(640, 25, 20));
+  trackManager->addPoint(Vector(670, 50, 120));
+  trackManager->addPoint(Vector(700, 70, 80));
+  trackManager->addPoint(Vector(800, 70, 65));
+  trackManager->addPoint(Vector(850, 65, 65));
+  trackManager->addPoint(Vector(920, 35, 40));
+  trackManager->addPoint(Vector(945, 40, 40));
+  trackManager->addPoint(Vector(970, 24, 40));
+  trackManager->addPoint(Vector(1000, 40, -7));
+  trackManager->setDuration(4);
+      
+      
+  trackManager->joinS("testFork1,testFork2");
+	
+  trackManager->addPoint(Vector(1200, 60, -50));
+  trackManager->addPoint(Vector(1300, 50, -50));
+  trackManager->addPoint(Vector(1400, 40, -50));
+  trackManager->addPoint(Vector(1500, 40, -60));
+  trackManager->addPoint(Vector(1600, 35, -55));
+  trackManager->addPoint(Vector(1700, 45, -40));
+  trackManager->addPoint(Vector(1750, 60, -40));
+  trackManager->addPoint(Vector(1770, 80, -40));
+  trackManager->addPoint(Vector(1800, 100, -40));
+  trackManager->setDuration(10);
+  
+  trackManager->finalize();
+  
 
   // LIGHT initialisation
-
   lightMan->setAmbientColor(.1,.1,.1);
   lightMan->addLight();
@@ -1164,10 +1191,17 @@
       this->trackManager->tick(this->dt);
       this->localCamera->tick(this->dt);
+      AnimationPlayer::getInstance()->tick(this->dtS);
+
+      PhysicsEngine::getInstance()->tick(this->dtS);
+
+      particleEngine->tick(this->dtS);
       this->garbageCollector->tick(this->dtS);
-
-      AnimationPlayer::getInstance()->tick(this->dtS);
-      PhysicsEngine::getInstance()->tick(this->dtS);
-
-      particleEngine->tick(this->dtS);
+	  
+      /* actualy the Graphics Engine should tick the world not the other way around...
+	 but since we like the things not too complicated we got it this way around
+	 until there is need or time to do it the other way around.
+	 \todo: GraphicsEngine ticks world: separation of processes and data...
+      */
+      GraphicsEngine::getInstance()->tick(this->dtS);
     }
   this->lastFrame = currentFrame;
