Index: orxonox/trunk/src/story_entities/world.cc
===================================================================
--- orxonox/trunk/src/story_entities/world.cc	(revision 3993)
+++ orxonox/trunk/src/story_entities/world.cc	(revision 4010)
@@ -1,2 +1,3 @@
+
 
 /* 
@@ -43,10 +44,11 @@
 #include "glmenu_imagescreen.h"
 #include "list.h"
+#include "game_loader.h"
 
 #include "animation3d.h"
 
+#include "substring.h"
 
 using namespace std;
-
 
 WorldInterface* WorldInterface::singletonRef = 0;
@@ -114,5 +116,49 @@
 }
 
-
+CREATE_FACTORY(World);
+
+World::World( TiXmlElement* root)
+{
+  this->constuctorInit("", -1);
+
+  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);
+    }
+}
 
 /** 
@@ -123,5 +169,5 @@
 World::World (char* name)
 {
-  this->init(name, -1);
+  this->constuctorInit(name, -1);
   //NullParent* np = NullParent::getInstance();
 }
@@ -133,5 +179,5 @@
 World::World (int worldID)
 {
-  this->init(NULL, worldID);
+  this->constuctorInit(NULL, worldID);
 }
 
@@ -178,12 +224,13 @@
    NO LEVEL LOADING HERE - NEVER!
 */
-void World::init(char* name, int worldID)
+void World::constuctorInit(char* name, int worldID)
 {
   this->setClassName ("World");
 
-  this->worldName = name;
+  //this->worldName = name;
+  //this->worldName = new char[strlen(name)+1];
+  //strcpy(this->worldName, name);
   this->debugWorldNr = worldID;
   this->entities = new tList<WorldEntity>();
-  AnimationPlayer::getInstance(); // initializes the animationPlayer
 }
 
@@ -201,4 +248,5 @@
   wi->init(this);
   this->garbageCollector = GarbageCollector::getInstance();
+
   this->trackManager = TrackManager::getInstance();
   this->lightMan = LightManager::getInstance();
@@ -206,4 +254,6 @@
   this->nullParent->setName ("NullParent");
 
+  AnimationPlayer::getInstance(); // initializes the animationPlayer
+
 }
 
@@ -213,12 +263,134 @@
 */
 ErrorMessage World::load()
-{
-  //  BezierCurve* tmpCurve = new BezierCurve();
-  if(this->debugWorldNr != -1)
-    {
-      // initializing Font
-      this->glmis->step();
+{	
+  PRINTF0("> Loading world: '%s'\n", getPath());
+  
+  GameLoader* loader = GameLoader::getInstance();
+  
+  if( getPath() == NULL)
+    {
+      PRINTF0("World has no path specified for loading");
+      return (ErrorMessage){213,"Path not specified","World::load()"};
+    }
+  
+  TiXmlDocument* XMLDoc = new TiXmlDocument( path);
+  // load the campaign document
+  if( !XMLDoc->LoadFile())
+    //this->glmis->step();
+  
+  {
+    // report an error
+    PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
+    delete XMLDoc;
+    return (ErrorMessage){213,"XML File parsing error","World::load()"};
+  }
+  
+  // check basic validity
+  TiXmlElement* root = XMLDoc->RootElement();
+  assert( root != NULL);
+  
+  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
+    {
+      // report an error
+      PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
+      delete XMLDoc;
+      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
+    }
+  
+  // load the parameters
+  // name
+  char* temp;
+  const char* string = grabParameter( root, "name");
+  if( string == NULL)
+    {
+      PRINTF0("World is missing a proper 'name'\n");
+      string = "Unknown";
+      temp = new char[strlen(string + 2)];
+      strcpy( temp, string);
+      this->worldName = temp;
+    }
+  else
+    {
+      temp = new char[strlen(string + 2)];
+      strcpy( temp, string);
+      this->worldName = temp;
+    }
+  
+  
+  // find WorldEntities
+  TiXmlElement* element = root->FirstChildElement( "WorldEntities");
+  
+  if( element == NULL)
+    {
+      PRINTF0("World is missing 'WorldEntities'\n");
+    }
+  else
+    {
+      element = element->FirstChildElement();
+      // load Players/Objects/Whatever
+      PRINTF0("Loading WorldEntities\n");
+      while( element != NULL)
+	{
+	  WorldEntity* created = (WorldEntity*) loader->fabricate( element);
+	  if( created != NULL) this->spawn( created);
+	  // if we load a 'Player' we use it as localPlayer
+	  //todo do this more elegant 
+	  if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
+	  if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) skyBox = (SkyBox*) created;
+	  element = element->NextSiblingElement();
+	}
+      PRINTF0("Done loading WorldEntities\n");
+    }
+  
+  // find Track
+  /*element = root->FirstChildElement( "Track");
+  if( element == NULL)
+    {
+      PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n");
+    }
+  else
+    {	
+      //load track
+      PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n");
+
+      trackManager->loadTrack( element);
+      trackManager->finalize();
+      PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n");
+    }*/
+  
+  // free the XML data
+  delete XMLDoc;
+  
+  // finalize world
+  // initialize Font
+//  testFont = new FontSet();
+//  testFont->buildFont("../data/pictures/font.tga");
+  
+  // create null parent
+  this->nullParent = NullParent::getInstance ();
+  this->nullParent->setName ("NullParent");
+  
+  // finalize myPlayer
+  if( localPlayer == NULL)
+    {
+      PRINTF0("No Player specified in World '%s'\n", this->worldName);
+      return (ErrorMessage){213,"No Player defined","World::load()"};
+    }
+  
+  // bind input
+  Orxonox *orx = Orxonox::getInstance ();
+  orx->getLocalInput()->bind (localPlayer);
+  
+  // bind camera
+  this->localCamera = new Camera();
+  this->localCamera->setName ("camera");
+  //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));
@@ -278,304 +450,327 @@
 
       
-      /*monitor progress*/
-      this->glmis->step();
-
-      // LIGHT initialisation
-
-      lightMan->setAmbientColor(.1,.1,.1);
-      lightMan->addLight();
-      //      lightMan->setAttenuation(1.0, .01, 0.0);
-      //      lightMan->setDiffuseColor(1,1,1);
-      //  lightMan->addLight(1);
-      //  lightMan->setPosition(20, 10, -20);
-      //  lightMan->setDiffuseColor(0,0,0);
-      lightMan->debug();
-
-      switch(this->debugWorldNr)
-	{
-	  /*
-	    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:
-	  {
-	    lightMan->setPosition(-5.0, 10.0, -40.0);
-
-	    // !\todo old track-system has to be removed
-
-	    //create helper for player
-	    //HelperParent* hp = new HelperParent ();
-	    /* the player has to be added to this helper */
-
-	    // create a player
-	    this->localPlayer = new Player ();
-	    this->localPlayer->setName ("player");
-	    this->spawn (this->localPlayer);
-	    /*monitor progress*/
-	    //this->glmis->step();
-	    this->glmis->step();
-
-	    // bind input
-	    Orxonox *orx = Orxonox::getInstance ();
-	    orx->getLocalInput()->bind (this->localPlayer);
+  // LIGHT initialisation
+  lightMan = LightManager::getInstance();
+  lightMan->setAmbientColor(.1,.1,.1);
+  lightMan->addLight();
+  //      lightMan->setAttenuation(1.0, .01, 0.0);
+  //      lightMan->setDiffuseColor(1,1,1);
+  //  lightMan->addLight(1);
+  //  lightMan->setPosition(20, 10, -20);
+  //  lightMan->setDiffuseColor(0,0,0);
+  lightMan->debug();
+  lightMan->setPosition(-5.0, 10.0, -40.0);
+  
+  //	    trackManager->setBindSlave(env);
+  PNode* tn = trackManager->getTrackNode();
+  tn->addChild(this->localPlayer);
+  
+  //localCamera->setParent(TrackNode::getInstance());
+  tn->addChild(this->localCamera);
+  localCamera->lookAt(tn);
+  this->localPlayer->setMode(PNODE_ALL);
+  Vector* cameraOffset = new Vector (0, 5, -10);
+  trackManager->condition(2, LEFTRIGHT, this->localPlayer);
+  
+
+  // initialize debug coord system
+  objectList = glGenLists(1);
+  glNewList (objectList, GL_COMPILE);
+  
+  //  trackManager->drawGraph(.01);
+  trackManager->debug(2);
+  glEndList();
+
+  terrain = new Terrain("../data/worlds/newGround.obj");
+  terrain->setRelCoor(Vector(0,-10,0));
+  this->spawn(terrain);
+
+}
+
+void World::loadDebugWorld(int worldID)
+{
+  /*monitor progress*/
+  this->glmis->step();
+
+  // LIGHT initialisation
+
+  lightMan->setAmbientColor(.1,.1,.1);
+  lightMan->addLight();
+  //      lightMan->setAttenuation(1.0, .01, 0.0);
+  //      lightMan->setDiffuseColor(1,1,1);
+  //  lightMan->addLight(1);
+  //  lightMan->setPosition(20, 10, -20);
+  //  lightMan->setDiffuseColor(0,0,0);
+  lightMan->debug();
+
+  switch(this->debugWorldNr)
+    {
+      /*
+	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:
+      {
+	lightMan->setPosition(-5.0, 10.0, -40.0);
+
+	// !\todo old track-system has to be removed
+
+	//create helper for player
+	//HelperParent* hp = new HelperParent ();
+	/* the player has to be added to this helper */
+
+	// create a player
+	this->localPlayer = new Player ();
+	this->localPlayer->setName ("player");
+	this->spawn (this->localPlayer);
+	/*monitor progress*/
+	//this->glmis->step();
+	this->glmis->step();
+
+	// bind input
+	Orxonox *orx = Orxonox::getInstance ();
+	orx->getLocalInput()->bind (this->localPlayer);
 	    
-	    // bind camera
-	    this->localCamera = new Camera();
-	    this->localCamera->setName ("camera");
+	// bind camera
+	this->localCamera = new Camera();
+	this->localCamera->setName ("camera");
 	    
-	    /*monitor progress*/
-	    this->glmis->step();
-
-	    // Create SkySphere
-	    //	    this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
-	    //	    this->skySphere->setName("SkySphere");
-	    //	    this->localCamera->addChild(this->skySphere);
-	    //	    this->spawn(this->skySphere);
-	    skyBox = new SkyBox();
-	    skyBox->setTexture("pictures/sky/skybox", "jpg");
-	    skyBox->setParent(localCamera);
-	    this->spawn(skyBox);
-
-	    /*monitor progress*/
-	    this->glmis->step();
+	/*monitor progress*/
+	this->glmis->step();
+
+	// Create SkySphere
+	//	    this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
+	//	    this->skySphere->setName("SkySphere");
+	//	    this->localCamera->addChild(this->skySphere);
+	//	    this->spawn(this->skySphere);
+	skyBox = new SkyBox();
+	skyBox->setTexture("pictures/sky/skybox", "jpg");
+	skyBox->setParent(localCamera);
+	this->spawn(skyBox);
+
+	/*monitor progress*/
+	this->glmis->step();
 
 	    
-	    WorldEntity* env = new Environment();
-	    env->setName ("env");
-	    this->spawn(env);
+	WorldEntity* env = new Environment();
+	env->setName ("env");
+	this->spawn(env);
 
 	   
-	    /*
-	    Vector* es = new Vector (10, 5, 0);
-	    Quaternion* qs = new Quaternion ();
-	    WorldEntity* pr = new Primitive(P_CYLINDER);
-	    pr->setName("primitive");
-	    this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
-	    */
-
-	    /*monitor progress*/
-	    this->glmis->step();
-
-	    //	    trackManager->setBindSlave(env);
-	    PNode* tn = trackManager->getTrackNode();
-	    tn->addChild(this->localPlayer);
-	    this->localCamera->lookAt(tn);
-
-	    //localCamera->setParent(TrackNode::getInstance());
-	    tn->addChild(this->localCamera);
-	    //	    localCamera->lookAt(tn);
-	    this->localPlayer->setMode(PNODE_ALL);
-	    //Vector* cameraOffset = new Vector (0, 5, -10);
-	    trackManager->condition(2, LEFTRIGHT, this->localPlayer);
-	    this->glmis->step();
-	    break;
-	  }
-	case DEBUG_WORLD_1:
-	  {
-	    lightMan->setPosition(.0, .0, .0);
-	    lightMan->setAttenuation(1.0, .01, 0.0);
-	    lightMan->setSpecularColor(1,0,0);
-	    this->nullParent = NullParent::getInstance ();
-	    this->nullParent->setName ("NullParent");
-
-	    // create a player
-	    WorldEntity* myPlayer = new Player();
-	    myPlayer->setName ("player");
-	    this->spawn(myPlayer);
-	    this->localPlayer = myPlayer;	    
+	/*
+	  Vector* es = new Vector (10, 5, 0);
+	  Quaternion* qs = new Quaternion ();
+	  WorldEntity* pr = new Primitive(P_CYLINDER);
+	  pr->setName("primitive");
+	  this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
+	*/
+
+	/*monitor progress*/
+	this->glmis->step();
+
+	//	    trackManager->setBindSlave(env);
+	PNode* tn = trackManager->getTrackNode();
+	tn->addChild(this->localPlayer);
+	this->localCamera->lookAt(tn);
+
+	//localCamera->setParent(TrackNode::getInstance());
+	tn->addChild(this->localCamera);
+	//	    localCamera->lookAt(tn);
+	this->localPlayer->setMode(PNODE_ALL);
+	//Vector* cameraOffset = new Vector (0, 5, -10);
+	trackManager->condition(2, LEFTRIGHT, this->localPlayer);
+	this->glmis->step();
+	break;
+      }
+    case DEBUG_WORLD_1:
+      {
+	lightMan->setPosition(.0, .0, .0);
+	lightMan->setAttenuation(1.0, .01, 0.0);
+	lightMan->setSpecularColor(1,0,0);
+	this->nullParent = NullParent::getInstance ();
+	this->nullParent->setName ("NullParent");
+
+	// create a player
+	WorldEntity* myPlayer = new Player();
+	myPlayer->setName ("player");
+	this->spawn(myPlayer);
+	this->localPlayer = myPlayer;	    
 	    
-	    // bind input
-	    Orxonox *orx = Orxonox::getInstance();
-	    orx->getLocalInput()->bind (myPlayer);
+	// bind input
+	Orxonox *orx = Orxonox::getInstance();
+	orx->getLocalInput()->bind (myPlayer);
 	    
-	    // bind camera
-	    this->localCamera = new Camera ();
-	    this->localCamera->setName ("camera");
-	    this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
-	    this->localCamera->setParent(this->localPlayer);
-
-	    // Create SkySphere
-	    skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
-	    this->localPlayer->addChild(this->skySphere);
-	    this->spawn(this->skySphere);
-	    Vector* es = new Vector (20, 0, 0);
-	    Quaternion* qs = new Quaternion ();
-
-	    lightMan->getLight(0)->setParent(trackManager->getTrackNode());
-	    break;
-	  }
-	case DEBUG_WORLD_2:
-	  {
-	    lightMan->setAmbientColor(.1,.1,.1);
-	    lightMan->addLight();
-	    lightMan->setPosition(-5.0, 10.0, -40.0);
-	    this->nullParent = NullParent::getInstance ();
-	    this->nullParent->setName ("NullParent");
-
-	    // !\todo old track-system has to be removed
-
-	    //create helper for player
-	    //HelperParent* hp = new HelperParent ();
-	    /* the player has to be added to this helper */
-
-	    // create a player
-	    this->localPlayer = new Player ();
-	    this->localPlayer->setName ("player");
-	    this->spawn (this->localPlayer);
-	    /*monitor progress*/
-	    //this->glmis->step();	    
-	    this->glmis->step();
-
-	    // bind input
-	    Orxonox *orx = Orxonox::getInstance ();
-	    orx->getLocalInput()->bind (this->localPlayer);
+	// bind camera
+	this->localCamera = new Camera ();
+	this->localCamera->setName ("camera");
+	this->localCamera->lookAt(LightManager::getInstance()->getLight(0));
+	this->localCamera->setParent(this->localPlayer);
+
+	// Create SkySphere
+	skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
+	this->localPlayer->addChild(this->skySphere);
+	this->spawn(this->skySphere);
+	Vector* es = new Vector (20, 0, 0);
+	Quaternion* qs = new Quaternion ();
+
+	lightMan->getLight(0)->setParent(trackManager->getTrackNode());
+	break;
+      }
+    case DEBUG_WORLD_2:
+      {
+	lightMan->setAmbientColor(.1,.1,.1);
+	lightMan->addLight();
+	lightMan->setPosition(-5.0, 10.0, -40.0);
+	this->nullParent = NullParent::getInstance ();
+	this->nullParent->setName ("NullParent");
+
+	// !\todo old track-system has to be removed
+
+	//create helper for player
+	//HelperParent* hp = new HelperParent ();
+	/* the player has to be added to this helper */
+
+	// create a player
+	this->localPlayer = new Player ();
+	this->localPlayer->setName ("player");
+	this->spawn (this->localPlayer);
+	/*monitor progress*/
+	//this->glmis->step();	    
+	this->glmis->step();
+
+	// bind input
+	Orxonox *orx = Orxonox::getInstance ();
+	orx->getLocalInput()->bind (this->localPlayer);
 	    
-	    // bind camera
-	    this->localCamera = new Camera();
-	    this->localCamera->setName ("camera");
-	    this->localCamera->lookAt(this->localPlayer);
-	    this->localCamera->setParent(this->localPlayer);
+	// bind camera
+	this->localCamera = new Camera();
+	this->localCamera->setName ("camera");
+	this->localCamera->lookAt(this->localPlayer);
+	this->localCamera->setParent(this->localPlayer);
 	    
-	    /*monitor progress*/
-	    this->glmis->step();
-
-	    // Create SkySphere
-	    this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
-	    this->skySphere->setName("SkySphere");
-	    this->spawn(this->skySphere);
-	    this->localCamera->addChild(this->skySphere);
-	    this->skySphere->setMode(PNODE_MOVEMENT);
-	    /*monitor progress*/
-	    this->glmis->step();
-
-
- 	    WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
-	    this->localPlayer->addChild(baseNode);
-	    baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
-	    this->spawn(baseNode);
-
- 	    WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
-	    baseNode->addChild(secondNode);
-	    secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
-	    this->spawn(secondNode);
-
-
- 	    WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
-	    secondNode->addChild(thirdNode);
-	    thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
-	    this->spawn(thirdNode);
+	/*monitor progress*/
+	this->glmis->step();
+
+	// Create SkySphere
+	this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
+	this->skySphere->setName("SkySphere");
+	this->spawn(this->skySphere);
+	this->localCamera->addChild(this->skySphere);
+	this->skySphere->setMode(PNODE_MOVEMENT);
+	/*monitor progress*/
+	this->glmis->step();
+
+
+	WorldEntity* baseNode = new Satellite(Vector(1,0,1), 1.2);
+	this->localPlayer->addChild(baseNode);
+	baseNode->setRelCoor(Vector(10.0, 2.0, 1.0));
+	this->spawn(baseNode);
+
+	WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
+	baseNode->addChild(secondNode);
+	secondNode->setRelCoor(Vector(0.0, 0.0, 3.0));
+	this->spawn(secondNode);
+
+
+	WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
+	secondNode->addChild(thirdNode);
+	thirdNode->setRelCoor(Vector(2.0, 0.0, 0.0));
+	this->spawn(thirdNode);
 
 	    
    
-	    WorldEntity* c = new Environment();
-	    this->localPlayer->addChild(c);
-	    c->setRelCoor(Vector(10.0, 2.0, -1.0));
-	    this->spawn(c);
+	WorldEntity* c = new Environment();
+	this->localPlayer->addChild(c);
+	c->setRelCoor(Vector(10.0, 2.0, -1.0));
+	this->spawn(c);
 
 
 	    
-	    Animation3D* animation = new Animation3D(c);
-	    animation->setInfinity(ANIM_INF_REPLAY);
-
-
-	    animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 
-	    animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 
-	    animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 
-
-
-
-
-
-
-	    /*	   
-		  KeyFrame* f1 = new KeyFrame;
-		  f1->position = new Vector(-1.1, 0.0, 2.6);
-		  f1->direction = new Quaternion();
-		  f1->time = 1.0;
-		  f1->mode = NEG_EXP;
+	Animation3D* animation = new Animation3D(c);
+	animation->setInfinity(ANIM_INF_REPLAY);
+
+
+	animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 
+	animation->addKeyFrame(Vector(0, 2, 0), Quaternion(M_PI, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 
+	animation->addKeyFrame(Vector(0, 0, 0), Quaternion(0, Vector(0,1,0)), 1.0, ANIM_NEG_EXP, ANIM_LINEAR); 
+
+
+
+
+
+
+	/*	   
+	  KeyFrame* f1 = new KeyFrame;
+	  f1->position = new Vector(-1.1, 0.0, 2.6);
+	  f1->direction = new Quaternion();
+	  f1->time = 1.0;
+	  f1->mode = NEG_EXP;
 		  
 		  
-		  KeyFrame* f2 = new KeyFrame;
-		  f2->position = new Vector(-2.1, 0.0, 2.6);
-		  f2->direction = new Quaternion();
-		  f2->time = 0.1;
-		  f2->mode = NEG_EXP;
+	  KeyFrame* f2 = new KeyFrame;
+	  f2->position = new Vector(-2.1, 0.0, 2.6);
+	  f2->direction = new Quaternion();
+	  f2->time = 0.1;
+	  f2->mode = NEG_EXP;
 		  
-		  KeyFrame* f3 = new KeyFrame;
-		  f3->position = new Vector(10.0, 2.0, -1.0);
-		  f3->direction = new Quaternion();
-		  f3->time = 0.2;
-		  f3->mode = NEG_EXP;
+	  KeyFrame* f3 = new KeyFrame;
+	  f3->position = new Vector(10.0, 2.0, -1.0);
+	  f3->direction = new Quaternion();
+	  f3->time = 0.2;
+	  f3->mode = NEG_EXP;
 		  
-		  KeyFrame* f4 = new KeyFrame;
-		  f4->position = new Vector(10.0, 5.0, -1.0);
-		  f4->direction = new Quaternion();
-		  f4->time = 1.0;
-		  f4->mode = NEG_EXP;
+	  KeyFrame* f4 = new KeyFrame;
+	  f4->position = new Vector(10.0, 5.0, -1.0);
+	  f4->direction = new Quaternion();
+	  f4->time = 1.0;
+	  f4->mode = NEG_EXP;
 		  
 		  
 		  
-		  this->simpleAnimation->animatorBegin();
-		  this->simpleAnimation->selectObject(b);
-		  this->simpleAnimation->setAnimationMode(SINGLE);
-		  this->simpleAnimation->addKeyFrame(f1);
-		  this->simpleAnimation->addKeyFrame(f2);
-		  this->simpleAnimation->start();
-		  this->simpleAnimation->selectObject(c);
-		  this->simpleAnimation->addKeyFrame(f3);
-		  this->simpleAnimation->addKeyFrame(f4);
-		  this->simpleAnimation->start();
-		  this->simpleAnimation->animatorEnd();
-	    */
-
-	    /*
-	    Vector* es = new Vector (10, 5, 0);
-	    Quaternion* qs = new Quaternion ();
-	    WorldEntity* pr = new Primitive(P_CYLINDER);
-	    pr->setName("primitive");
-	    this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
-	    */
-
-	    /*monitor progress*/
-	    this->glmis->step();
-
-	    //	    trackManager->setBindSlave(env);
-	    PNode* tn = trackManager->getTrackNode();
-	    tn->addChild(this->localPlayer);
-
-	    //localCamera->setParent(TrackNode::getInstance());
-	    tn->addChild(this->localCamera);
-	    //	    localCamera->lookAt(tn);
-	    this->localPlayer->setMode(PNODE_ALL);
-	    //Vector* cameraOffset = new Vector (0, 5, -10);
-	    trackManager->condition(2, LEFTRIGHT, this->localPlayer);
-	    this->glmis->step();
-
-	    break;
-	  }
-	default:
-	  printf("World::load() - no world with ID %i found", this->debugWorldNr );
-	}
-    }
-  else if(this->worldName != NULL)
-    {
-
-    }
-
-  // initialize debug coord system
-  objectList = glGenLists(1);
-  glNewList (objectList, GL_COMPILE);
- 
-  //  trackManager->drawGraph(.01);
-  trackManager->debug(2);
-  glEndList();
-
-  terrain = new Terrain("../data/worlds/newGround.obj");
-  terrain->setRelCoor(Vector(0,-10,0));
-  this->spawn(terrain);
-
-}
+	  this->simpleAnimation->animatorBegin();
+	  this->simpleAnimation->selectObject(b);
+	  this->simpleAnimation->setAnimationMode(SINGLE);
+	  this->simpleAnimation->addKeyFrame(f1);
+	  this->simpleAnimation->addKeyFrame(f2);
+	  this->simpleAnimation->start();
+	  this->simpleAnimation->selectObject(c);
+	  this->simpleAnimation->addKeyFrame(f3);
+	  this->simpleAnimation->addKeyFrame(f4);
+	  this->simpleAnimation->start();
+	  this->simpleAnimation->animatorEnd();
+	*/
+
+	/*
+	  Vector* es = new Vector (10, 5, 0);
+	  Quaternion* qs = new Quaternion ();
+	  WorldEntity* pr = new Primitive(P_CYLINDER);
+	  pr->setName("primitive");
+	  this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
+	*/
+
+	/*monitor progress*/
+	this->glmis->step();
+
+	//	    trackManager->setBindSlave(env);
+	PNode* tn = trackManager->getTrackNode();
+	tn->addChild(this->localPlayer);
+
+	//localCamera->setParent(TrackNode::getInstance());
+	tn->addChild(this->localCamera);
+	//	    localCamera->lookAt(tn);
+	this->localPlayer->setMode(PNODE_ALL);
+	//Vector* cameraOffset = new Vector (0, 5, -10);
+	trackManager->condition(2, LEFTRIGHT, this->localPlayer);
+	this->glmis->step();
+
+	break;
+      }
+    default:
+      printf("World::load() - no world with ID %i found", this->debugWorldNr );
+    }
+}
+
 
 
@@ -852,5 +1047,5 @@
       this->tick ();
       // Update the state
-      this->update ();      
+      this->update ();     
       // Process collision
       this->collide ();
@@ -935,6 +1130,5 @@
 	}
       delete iterator;
-      //skySphere->updatePosition(localCamera->absCoordinate);
-      
+
       /* update tick the rest */
       this->trackManager->tick(this->dt);
@@ -1055,2 +1249,12 @@
 }
 
+void World::setPath( const char* name)
+{
+  this->path = new char[strlen(name)+1];
+  strcpy(this->path, name);
+}
+
+const char* World::getPath( void)
+{
+  return path;
+}
