Index: code/branches/merge/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/merge/src/orxonox/CMakeLists.txt	(revision 1263)
+++ code/branches/merge/src/orxonox/CMakeLists.txt	(revision 1264)
@@ -16,4 +16,5 @@
   objects/Ambient.cc
   objects/Camera.cc
+  objects/CameraHandler.cc
   objects/Explosion.cc
   objects/Model.cc
Index: code/branches/merge/src/orxonox/Main.cc
===================================================================
--- code/branches/merge/src/orxonox/Main.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/Main.cc	(revision 1264)
Index: code/branches/merge/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/merge/src/orxonox/Orxonox.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/Orxonox.cc	(revision 1264)
@@ -189,9 +189,10 @@
     GraphicsEngine::getSingleton().destroy();
 
-    if (client_g)
-      delete client_g;
+    if (network::Client::getSingleton())
+      network::Client::destroySingleton();
     if (server_g)
       delete server_g;
   }
+
 
   /**
@@ -395,7 +396,7 @@
 
     if (serverIp_.compare("") == 0)
-      client_g = new network::Client();
+      client_g = network::Client::createSingleton();
     else
-      client_g = new network::Client(serverIp_, NETWORK_PORT);
+      client_g = network::Client::createSingleton(serverIp_, NETWORK_PORT);
 
     client_g->establishConnection();
@@ -511,4 +512,8 @@
 	  }
 
+    if(mode_==CLIENT)
+      network::Client::getSingleton()->closeConnection();
+    else if(mode_==SERVER)
+      server_g->close();
     return true;
   }
Index: code/branches/merge/src/orxonox/Orxonox.h
===================================================================
--- code/branches/merge/src/orxonox/Orxonox.h	(revision 1263)
+++ code/branches/merge/src/orxonox/Orxonox.h	(revision 1264)
Index: code/branches/merge/src/orxonox/objects/Ambient.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/Ambient.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Ambient.cc	(revision 1264)
@@ -57,4 +57,5 @@
         RegisterObject(Ambient);
         Ambient::instance_s = this;
+        registerAllVariables();
     }
 
@@ -63,4 +64,14 @@
     }
 
+    bool Ambient::create(){
+      GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
+      return true;
+    }
+    
+    void Ambient::registerAllVariables(){
+      registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
+      
+    }
+    
     void Ambient::loadParams(TiXmlElement* xmlElem)
     {
@@ -83,4 +94,5 @@
    {
     	GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
+      ambientLight_=colour;	
    }
 
@@ -96,4 +108,5 @@
 
         XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
+        create();
     }
 }
Index: code/branches/merge/src/orxonox/objects/Ambient.h
===================================================================
--- code/branches/merge/src/orxonox/objects/Ambient.h	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Ambient.h	(revision 1264)
@@ -34,8 +34,9 @@
 #include "util/Math.h"
 #include "core/BaseObject.h"
+#include "network/Synchronisable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Ambient : public BaseObject
+    class _OrxonoxExport Ambient : public BaseObject, network::Synchronisable
     {
         public:
@@ -46,4 +47,6 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setAmbientLight(const ColourValue& colour);
+            bool create();
+            void registerAllVariables();
 
             static void setAmbientLightTest(const ColourValue& colour)
@@ -52,4 +55,5 @@
         private:
             static Ambient* instance_s;
+            ColourValue ambientLight_;
 
     };
Index: code/branches/merge/src/orxonox/objects/Camera.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/Camera.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Camera.cc	(revision 1264)
@@ -47,56 +47,104 @@
 namespace orxonox
 {
-    CreateFactory(Camera);
+  //CreateFactory(Camera);
 
-    Camera::Camera()
+  Camera::Camera(Ogre::SceneNode* node)
+  {
+    //RegisterObject(Camera);
+    this->bHasFocus_ = false;
+    if( node != NULL )
+      this->setCameraNode(node);
+
+  }
+
+  Camera::~Camera()
+  {
+  }
+
+  /*void Camera::loadParams(TiXmlElement* xmlElem)
+  {
+    Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
+
+    if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
     {
-        RegisterObject(Camera);
+      //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
+
+      std::string name = xmlElem->Attribute("name");
+      std::string pos = xmlElem->Attribute("pos");
+      std::string lookat = xmlElem->Attribute("lookat");
+
+      this->cam_ = mgr->createCamera(name);
+
+      float x, y, z;
+      SubString posVec(xmlElem->Attribute("pos"), ',');
+      convertValue<std::string, float>(&x, posVec[0]);
+      convertValue<std::string, float>(&y, posVec[1]);
+      convertValue<std::string, float>(&z, posVec[2]);
+
+      setPosition(Vector3(x,y,z));
+
+      //std::string target = xmlElem->Attribute("lookat");
+      posVec.split(xmlElem->Attribute("lookat"), ',');
+      convertValue<std::string, float>(&x, posVec[0]);
+      convertValue<std::string, float>(&y, posVec[1]);
+      convertValue<std::string, float>(&z, posVec[2]);
+
+      cam_->lookAt(Vector3(x,y,z));
+
+      /*std::string node = xmlElem->Attribute("node");
+
+      Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
+      sceneNode->attachObject((Ogre::MovableObject*)cam_);
+      */
+
+      // FIXME: unused var
+      //Ogre::Viewport* vp =
+      //GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam_);
+    /*
+
+      COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
     }
+  }*/
 
-    Camera::~Camera()
-    {
-    }
+  void Camera::setCameraNode(Ogre::SceneNode* node)
+  {
+    this->positionNode_ = node;
+    // set camera to node values according to camera mode
+  }
 
-    void Camera::loadParams(TiXmlElement* xmlElem)
-    {
-      Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
+  void Camera::setTargetNode(Ogre::SceneNode* obj)
+  {
+    this->targetNode_ = obj;
+  }
 
-      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
-      {
-        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
+  /**
+    don't move anything before here! here the Ogre camera is set to values of this camera
+    always call update after changes
+  */
+  void Camera::update()
+  {
+    COUT(0) << "p " << this->positionNode_->getPosition() << std::endl;
+    COUT(0) << "t " << this->targetNode_->getPosition() << std::endl;
+    if(this->positionNode_ != NULL)
+      this->cam_->setPosition(this->positionNode_->getPosition());
+    if(this->targetNode_ != NULL)
+      this->cam_->lookAt(this->targetNode_->getPosition());
+  }
 
-        std::string name = xmlElem->Attribute("name");
-        std::string pos = xmlElem->Attribute("pos");
-        std::string lookat = xmlElem->Attribute("lookat");
+  /**
+    what to do when camera loses focus (do not request focus in this function!!)
+    this is called by the CameraHandler singleton class to notify the camera
+  */
+  void Camera::removeFocus()
+  {
+    this->bHasFocus_ = false;
+    this->positionNode_->detachObject(cam_);
+  }
 
-        Ogre::Camera *cam = mgr->createCamera(name);
-
-        float x, y, z;
-        SubString posVec(xmlElem->Attribute("pos"), ',');
-        convertValue<std::string, float>(&x, posVec[0]);
-        convertValue<std::string, float>(&y, posVec[1]);
-        convertValue<std::string, float>(&z, posVec[2]);
-
-        cam->setPosition(Vector3(x,y,z));
-
-        posVec = SubString(xmlElem->Attribute("lookat"), ',');
-        convertValue<std::string, float>(&x, posVec[0]);
-        convertValue<std::string, float>(&y, posVec[1]);
-        convertValue<std::string, float>(&z, posVec[2]);
-
-        cam->lookAt(Vector3(x,y,z));
-
-        std::string node = xmlElem->Attribute("node");
-
-        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
-        sceneNode->attachObject((Ogre::MovableObject*)cam);
-
-        // FIXME: unused var
-        //Ogre::Viewport* vp = 
-        GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
-
-
-        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
-      }
-   }
+  void Camera::setFocus(Ogre::Camera* ogreCam)
+  {
+    this->bHasFocus_ = true;
+    this->cam_ = ogreCam;
+    this->positionNode_->attachObject(cam_);
+  }
 }
Index: code/branches/merge/src/orxonox/objects/Camera.h
===================================================================
--- code/branches/merge/src/orxonox/objects/Camera.h	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Camera.h	(revision 1264)
@@ -30,22 +30,38 @@
 #define _Camera_H__
 
+#include <OgrePrerequisites.h>
+#include <OgreSceneNode.h>
+#include <OgreCamera.h>
+
 #include "OrxonoxPrereqs.h"
-
-#include "core/BaseObject.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Camera : public BaseObject
+    class _OrxonoxExport Camera
     {
-        public:
-            Camera();
-            virtual ~Camera();
+      friend class CameraHandler;
+      public:
+        Camera(Ogre::SceneNode* node = NULL);
+        virtual ~Camera();
+
+        //inline void setPosition(Ogre::Vector3 pos) { position_->setPosition(pos); cam_->setPosition(pos); }
+        void setCameraNode(Ogre::SceneNode* node);
+        inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; }
+        // maybe also BaseObject
+        void setTargetNode(Ogre::SceneNode* obj);
 
 
-            void loadParams(TiXmlElement* xmlElem);
+        void update();
+        inline bool hasFocus() { return this->bHasFocus_; }
 
-        private:
+      private:
+        void removeFocus();
+        void setFocus(Ogre::Camera* ogreCam);
 
-
+      private:
+        Ogre::SceneNode* targetNode_;
+        Ogre::SceneNode* positionNode_;
+        Ogre::Camera* cam_;
+        bool bHasFocus_;
     };
 }
Index: code/branches/merge/src/orxonox/objects/CameraHandler.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/CameraHandler.cc	(revision 1264)
+++ code/branches/merge/src/orxonox/objects/CameraHandler.cc	(revision 1264)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+#include <OgreSceneManager.h>
+#include <OgreRenderWindow.h>
+
+#include "OrxonoxStableHeaders.h"
+#include "core/ObjectList.h"
+#include "CameraHandler.h"
+#include "Camera.h"
+#include "GraphicsEngine.h"
+
+#include <OgreCamera.h>
+
+namespace orxonox {
+
+  CameraHandler* CameraHandler::singletonRef = NULL;
+
+  CameraHandler::CameraHandler()
+  {
+    this->cam_ = GraphicsEngine::getSingleton().getSceneManager()->createCamera("Cam");
+    GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_);
+    /*this->activeCamera_ = *ObjectList<Camera>::begin();
+    this->activeCamera_->cam_ = this->cam_;*/
+  }
+
+  void CameraHandler::requestFocus(Camera* requestCam)
+  {
+    // notify old camera (if it exists)
+    if(focusList_.size() > 0)
+      focusList_.back()->removeFocus();
+    // add to list
+    focusList_.push_back(requestCam);
+    // set focus to new camera and update (if necessary)
+    if(!requestCam->hasFocus()) {
+      requestCam->setFocus(this->cam_);
+      requestCam->update();
+    }
+    // delete dublicates
+    focusList_.unique();
+  }
+
+  void CameraHandler::releaseFocus(Camera* cam)
+  {
+    // notify the cam of releasing the focus
+    if(cam->hasFocus())
+      cam->removeFocus();
+    // delete camera from list
+    focusList_.remove(cam);
+    // set new focus if necessary
+    if(!(focusList_.back()->hasFocus()))
+      focusList_.back()->setFocus(this->cam_);
+  }
+/*
+  void CameraHandler::changeActiveCamera(Camera* setCam)
+  {
+    cam_->getParentSceneNode()->detachObject(cam_);
+    //setCam->attachCamera(cam_);
+    activeCamera_ = setCam;
+  }
+*/
+/*  bool isInVector(Camera* cam)
+  {
+    for(std::vector<Camera*>::iterator it = cams_.begin(); it != cams_.end(); it++)
+    {
+      if (*it == cam) return true;
+    }
+    return false;
+  }*/
+}
Index: code/branches/merge/src/orxonox/objects/CameraHandler.h
===================================================================
--- code/branches/merge/src/orxonox/objects/CameraHandler.h	(revision 1264)
+++ code/branches/merge/src/orxonox/objects/CameraHandler.h	(revision 1264)
@@ -0,0 +1,75 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+ /**
+ @file  CameraHandler.h
+ @brief Handles the instances of Camera class
+ @author Benjamin Knecht <beni_at_orxonox.net>
+  */
+
+#ifndef _Camera_Handler_H__
+#define _Camera_Handler_H__
+
+#include <list>
+
+#include <OgreCamera.h>
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+#include "Camera.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport CameraHandler
+  {
+
+    public:
+      inline static CameraHandler* getInstance() { if (!CameraHandler::singletonRef) CameraHandler::singletonRef = new CameraHandler(); return CameraHandler::singletonRef; }
+      inline ~CameraHandler() { CameraHandler::singletonRef = NULL; }
+      inline Camera* getActiveCamera() { return this->focusList_.back(); }
+      /*void registerCamera(Camera* newCam);
+      void changeActiveCamera(Camera* setCam);*/
+      void requestFocus(Camera* requestCam);
+      void releaseFocus(Camera* cam);
+
+    private:
+      CameraHandler();
+      //bool isInVector(Camera* cam);
+
+    private:
+      static CameraHandler* singletonRef;
+      Ogre::Camera* cam_;
+      std::list<Camera*> focusList_;
+      //std::vector<Camera*> cams_;
+
+  };
+}
+
+#endif /* _Camera_Handler_H__ */
Index: code/branches/merge/src/orxonox/objects/Model.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/Model.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Model.cc	(revision 1264)
@@ -62,5 +62,5 @@
         XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
 
-        create();
+        Model::create();
     }
 
@@ -71,10 +71,11 @@
 
     bool Model::create(){
-      WorldEntity::create();
+      if(!WorldEntity::create())
+        return false;
       if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
       {
         this->mesh_.setMesh(meshSrc_);
         this->attachObject(this->mesh_.getEntity());
-        COUT(4) << "Loader: Created model" << std::endl;
+        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
       }
       return true;
@@ -82,5 +83,6 @@
 
     void Model::registerAllVariables(){
-      WorldEntity::registerAllVariables();
+//       WorldEntity::registerAllVariables();
+      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
       registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
     }
Index: code/branches/merge/src/orxonox/objects/NPC.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/NPC.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/NPC.cc	(revision 1264)
@@ -40,4 +40,5 @@
   {
     RegisterObject(NPC);
+    registerAllVariables();
   }
 
@@ -59,4 +60,14 @@
     this->translate(location);
     movable_ = movable;
+  }
+  
+  void NPC::registerAllVariables(){
+    Model::registerAllVariables();
+    registerVar(&movable_, sizeof(movable_), network::DATA);
+  }
+  
+  bool NPC::create(){
+    Model::create();
+    return true;
   }
 
Index: code/branches/merge/src/orxonox/objects/NPC.h
===================================================================
--- code/branches/merge/src/orxonox/objects/NPC.h	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/NPC.h	(revision 1264)
@@ -52,4 +52,6 @@
       void update();
       void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
+      void registerAllVariables();
+      bool create();
 
     private:
Index: code/branches/merge/src/orxonox/objects/Skybox.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/Skybox.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Skybox.cc	(revision 1264)
@@ -47,4 +47,5 @@
     {
         RegisterObject(Skybox);
+        registerAllVariables();
     }
 
@@ -57,8 +58,8 @@
     	if (xmlElem->Attribute("src"))
     	{
-    		std::string skyboxSrc = xmlElem->Attribute("src");
-	    	this->setSkybox(skyboxSrc);
+    		skyboxSrc_ = xmlElem->Attribute("src");
+        this->create();
 
-	    	COUT(4) << "Loader: Set skybox: "<< skyboxSrc << std::endl << std::endl;
+	    	COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl;
     	}
    }
@@ -69,4 +70,8 @@
    }
 
+   void Skybox::setSkyboxSrc(const std::string& src){
+     skyboxSrc_ = src;
+   }
+   
     /**
         @brief XML loading and saving.
@@ -79,5 +84,16 @@
         BaseObject::XMLPort(xmlelement, mode);
 
-        XMLPortParamLoadOnly(Skybox, "src", setSkybox, xmlelement, mode);
+        XMLPortParamLoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);
+        create();
     }
+    
+    bool Skybox::create(){
+      this->setSkybox(skyboxSrc_);
+      return true;
+    }
+    
+    void Skybox::registerAllVariables(){
+      registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
+    }
+    
 }
Index: code/branches/merge/src/orxonox/objects/Skybox.h
===================================================================
--- code/branches/merge/src/orxonox/objects/Skybox.h	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/Skybox.h	(revision 1264)
@@ -33,8 +33,9 @@
 
 #include "core/BaseObject.h"
+#include "network/Synchronisable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Skybox : public BaseObject
+    class _OrxonoxExport Skybox : public BaseObject, public network::Synchronisable
     {
         public:
@@ -45,6 +46,11 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setSkybox(const std::string& skyboxname);
+            
+            bool create();
+            void registerAllVariables();
+            void setSkyboxSrc(const std::string &src);
 
         private:
+            std::string skyboxSrc_;
 
 
Index: code/branches/merge/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/SpaceShip.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/SpaceShip.cc	(revision 1264)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Benjamin Knecht
  *
  */
@@ -37,4 +37,5 @@
 #include <OgreSceneNode.h>
 
+#include "CameraHandler.h"
 #include "tinyxml/tinyxml.h"
 #include "ois/OIS.h"
@@ -50,4 +51,5 @@
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
+#include "network/Client.h"
 
 namespace orxonox
@@ -64,5 +66,10 @@
     SpaceShip::SpaceShip()
     {
+        RegisterObject(SpaceShip);
+        this->registerAllVariables();
+
         SpaceShip::instance_s = this;
+
+        this->setConfigValues();
 
         this->setMouseEventCallback_ = false;
@@ -73,4 +80,5 @@
 
         this->camNode_ = 0;
+        this->camName_ = "camNode";
 
         this->tt_ = 0;
@@ -96,45 +104,7 @@
         this->setRotationAxis(1, 0, 0);
         this->setStatic(false);
-/*
-        this->moveForward_ = 0;
-        this->rotateUp_ = 0;
-        this->rotateDown_ = 0;
-        this->rotateRight_ = 0;
-        this->rotateLeft_ = 0;
-        this->loopRight_ = 0;
-        this->loopLeft_ = 0;
-        this->brakeForward_ = 0;
-        this->brakeRotate_ = 0;
-        this->brakeLoop_ = 0;
-        this->speedForward_ = 0;
-        this->speedRotateUpDown_ = 0;
-        this->speedRotateRightLeft_ = 0;
-        this->speedLoopRightLeft_ = 0;
-        this->maxSpeedForward_ = 0;
-        this->maxSpeedRotateUpDown_ = 0;
-        this->maxSpeedRotateRightLeft_ = 0;
-        this->maxSpeedLoopRightLeft_ = 0;
-        this->accelerationForward_ = 0;
-        this->accelerationRotateUpDown_ = 0;
-        this->accelerationRotateRightLeft_ = 0;
-        this->accelerationLoopRightLeft_ = 0;
-
-        this->speed = 250;
-        this->loop = 100;
-        this->rotate = 10;
-        this->mouseX = 0;
-        this->mouseY = 0;
-        this->maxMouseX = 0;
-        this->minMouseX = 0;
-        this->moved = false;
-
-        this->brakeRotate(rotate*10);
-        this->brakeLoop(loop);
-*/
-//         this->create();
-
-        RegisterObject(SpaceShip);
-        this->registerAllVariables();
-        this->setConfigValues();
+
+        server_=false;
+
 
         COUT(3) << "Info: SpaceShip was loaded" << std::endl;
@@ -156,7 +126,14 @@
 
     void SpaceShip::registerAllVariables(){
-      Model::registerAllVariables();
-
-
+      registerVar( &camName_, camName_.length()+1, network::STRING, 0x1);
+      registerVar( &maxSpeed_, sizeof(maxSpeed_), network::DATA, 0x1);
+      registerVar( &maxSideAndBackSpeed_, sizeof(maxSideAndBackSpeed_), network::DATA, 0x1);
+      registerVar( &maxRotation_, sizeof(maxRotation_), network::DATA, 0x1);
+      registerVar( &translationAcceleration_, sizeof(translationAcceleration_), network::DATA, 0x1);
+      registerVar( &rotationAcceleration_, sizeof(rotationAcceleration_), network::DATA, 0x1);
+      registerVar( &rotationAccelerationRadian_, sizeof(rotationAccelerationRadian_), network::DATA, 0x1);
+      registerVar( &translationDamping_, sizeof(translationDamping_), network::DATA, 0x1);
+      registerVar( &rotationDamping_, sizeof(rotationDamping_), network::DATA, 0x1);
+      registerVar( &rotationDampingRadian_, sizeof(rotationDampingRadian_), network::DATA, 0x1);
 
     }
@@ -164,9 +141,12 @@
     void SpaceShip::init()
     {
-        if (!setMouseEventCallback_)
-        {
-          InputManager::addMouseHandler(this, "SpaceShip");
-          setMouseEventCallback_ = true;
-        }
+		if ((!network::Client::getSingleton() || network::Client::getSingleton()->getShipID()==objectID ))
+		{
+        	if (!setMouseEventCallback_)
+        	{
+          		InputManager::addMouseHandler(this, "SpaceShip");
+          		setMouseEventCallback_ = true;
+        	}
+		}
 
         // START CREATING THRUSTER
@@ -222,4 +202,5 @@
         this->chFarNode_->setScale(0.4, 0.4, 0.4);
 
+        createCamera();
         // END of testing crosshair
     }
@@ -236,4 +217,5 @@
         Model::loadParams(xmlElem);
         this->create();
+        this->getFocus();
 /*
         if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
@@ -286,6 +268,21 @@
     void SpaceShip::setCamera(const std::string& camera)
     {
-        Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");
-        this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
+      camName_=camera;
+      // change camera attributes here, if you want to ;)
+    }
+    
+    void SpaceShip::getFocus(){
+      COUT(4) << "requesting focus" << std::endl;
+      if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID)
+        CameraHandler::getInstance()->requestFocus(cam_);
+      
+    }
+    
+    void SpaceShip::createCamera(){
+//       COUT(4) << "begin camera creation" << std::endl;
+      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
+      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
+      this->camNode_->setPosition(/*this->getNode()->getPosition() +*/ Vector3(-50,0,10));
+      COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl;
 /*
 //        node->setInheritOrientation(false);
@@ -293,13 +290,14 @@
         cam->lookAt(Vector3(0,20,0));
         cam->roll(Degree(0));
-*/
-
-        cam->setPosition(Vector3(-200,0,35));
+      *//*COUT(4) << "creating new camera" << std::endl;*/
+      cam_ = new Camera(this->camNode_);
+
+      cam_->setTargetNode(this->getNode());
 //        cam->setPosition(Vector3(0,-350,0));
-        cam->lookAt(Vector3(0,0,35));
-        cam->roll(Degree(-90));
-
-        this->camNode_->attachObject(cam);
-        GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
+      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
+        this->setBacksync(true);
+        CameraHandler::getInstance()->requestFocus(cam_);
+      }
+
     }
 
@@ -337,4 +335,7 @@
         XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
         XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
+        server_=true; // TODO: this is only a hack
+        SpaceShip::create();
+        getFocus();
     }
 
@@ -448,5 +449,6 @@
         if (this->bLMousePressed_ && this->timeToReload_ <= 0)
         {
-            new Projectile(this);
+            Projectile *p = new Projectile(this);
+            p->setBacksync(true);
             this->timeToReload_ = this->reloadTime_;
         }
@@ -520,24 +522,28 @@
         }
 
-        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
+        if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ ){
+          COUT(4) << "steering our ship: " << objectID << " mkeyboard: " << mKeyboard << std::endl;
+          if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
             this->acceleration_.x = this->translationAcceleration_;
-        else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
+          else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
             this->acceleration_.x = -this->translationAcceleration_;
-        else
+          else
             this->acceleration_.x = 0;
 
-        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
+          if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
             this->acceleration_.y = -this->translationAcceleration_;
-        else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
+          else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
             this->acceleration_.y = this->translationAcceleration_;
-        else
+          else
             this->acceleration_.y = 0;
 
-        if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
+          if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
             this->momentum_ = Radian(-this->rotationAccelerationRadian_);
-        else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
+          else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
             this->momentum_ = Radian(this->rotationAccelerationRadian_);
-        else
+          else
             this->momentum_ = 0;
+        }/*else
+          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
 
         WorldEntity::tick(dt);
Index: code/branches/merge/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/branches/merge/src/orxonox/objects/SpaceShip.h	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/SpaceShip.h	(revision 1264)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Benjamin Knecht
  *
  */
@@ -35,4 +35,5 @@
 
 #include "core/InputHandler.h"
+#include "Camera.h"
 #include "Model.h"
 #include "../tools/BillboardSet.h"
@@ -62,4 +63,6 @@
             void setRotDamp(float value);
 
+            void getFocus();
+
             static void setMaxSpeedTest(float value)
                 { SpaceShip::instance_s->setMaxSpeed(value); }
@@ -72,4 +75,5 @@
 
         private:
+            void createCamera();
             static SpaceShip* instance_s;
 
@@ -81,4 +85,7 @@
 
             Ogre::SceneNode* camNode_;
+            Camera* cam_;  
+            std::string camName_;
+
 
             ParticleInterface* tt_;
@@ -117,4 +124,5 @@
 
             float emitterRate_;
+            bool server_;
     };
 }
Index: code/branches/merge/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/branches/merge/src/orxonox/objects/WorldEntity.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/objects/WorldEntity.cc	(revision 1264)
@@ -66,7 +66,11 @@
         }
     }
+    
 
     WorldEntity::~WorldEntity()
     {
+      // just to make sure we clean out all scene nodes
+      if(this->getNode())
+        this->getNode()->removeAndDestroyAllChildren();
     }
 
@@ -75,4 +79,5 @@
         if (!this->bStatic_)
         {
+//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
             this->velocity_ += (dt * this->acceleration_);
             this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
@@ -89,4 +94,5 @@
         create();
     }
+    
 
     void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
@@ -115,4 +121,6 @@
 
         XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
+        
+        WorldEntity::create();
     }
 
@@ -121,22 +129,32 @@
     {
       // register coordinates
-      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
-      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
-      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA);
+      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
       // register orientation
-      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA);
-      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
-      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
-      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
-      // not needed at the moment, because we don't have prediction yet
+      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
       // register velocity_
-      registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
-      registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
-      registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA);
-      // register rotationAxis/rate
-      registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA);
-      registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
-      registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
-      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
+//       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
+//       // register rotationAxis/rate
+//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
+      // register scale of node
+      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
+      //register staticity
+      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
+      //register acceleration
+      // register velocity_
+//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
     }
 
Index: code/branches/merge/src/orxonox/particle/ParticleInterface.cc
===================================================================
--- code/branches/merge/src/orxonox/particle/ParticleInterface.cc	(revision 1263)
+++ code/branches/merge/src/orxonox/particle/ParticleInterface.cc	(revision 1264)
@@ -63,4 +63,6 @@
   ParticleInterface::~ParticleInterface(void)
   {
+    while(particleSystem_->getNumEmitters()>0)
+      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
     sceneManager_->destroyParticleSystem(particleSystem_);
   }
