Index: /code/branches/objecthierarchy2/src/orxonox/objects/Scene.cc
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/Scene.cc	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/Scene.cc	(revision 2447)
@@ -33,5 +33,4 @@
 #include <OgreSceneManagerEnumerator.h>
 #include <OgreSceneNode.h>
-#include <OgreLight.h>
 
 #include "core/CoreIncludes.h"
@@ -48,5 +47,5 @@
 
         this->setScene(this);
-        this->bShadows_ = false;
+        this->bShadows_ = true;
 
         if (Core::showsGraphics())
@@ -69,16 +68,4 @@
             this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
         }
-
-        // test test test
-        if (Core::showsGraphics() && this->sceneManager_)
-        {
-            Ogre::Light* light;
-            light = this->sceneManager_->createLight("Light-1");
-            light->setType(Ogre::Light::LT_DIRECTIONAL);
-            light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));
-            light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));
-            light->setDirection(1, -0.3, 0.3);
-        }
-        // test test test
 
         this->registerVariables();
@@ -116,4 +103,5 @@
         REGISTERSTRING(this->skybox_,     direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
         REGISTERDATA(this->ambientLight_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
+        REGISTERDATA(this->bShadows_,     direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
     }
 
Index: /code/branches/objecthierarchy2/src/orxonox/objects/Scene.h
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/Scene.h	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/Scene.h	(revision 2447)
@@ -75,4 +75,6 @@
             void networkcallback_applyAmbientLight()
                 { this->setAmbientLight(this->ambientLight_); }
+            void networkcallback_applyShadows()
+                { this->setShadow(this->bShadows_); }
 
             Ogre::SceneManager*    sceneManager_;
Index: /code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc	(revision 2447)
@@ -149,21 +149,26 @@
     void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
     {
-        if (victim)
+        if (victim && victim->getPlayer())
         {
             std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(victim->getPlayer());
-            it->second = PlayerState::Dead;
-
-            ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
-            if (victim->getCamera())
-            {
-                entity->setPosition(victim->getCamera()->getWorldPosition());
-                entity->setOrientation(victim->getCamera()->getWorldOrientation());
+            if (it != this->players_.end())
+            {
+                it->second = PlayerState::Dead;
+
+                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
+                if (victim->getCamera())
+                {
+                    entity->setPosition(victim->getCamera()->getWorldPosition());
+                    entity->setOrientation(victim->getCamera()->getWorldOrientation());
+                }
+                else
+                {
+                    entity->setPosition(victim->getWorldPosition());
+                    entity->setOrientation(victim->getWorldOrientation());
+                }
+                it->first->startControl(entity);
             }
             else
-            {
-                entity->setPosition(victim->getWorldPosition());
-                entity->setOrientation(victim->getWorldOrientation());
-            }
-            it->first->startControl(entity);
+                COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl;
         }
     }
Index: /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2447)
@@ -81,7 +81,12 @@
         if (this->isInitialized())
         {
+            this->bDestroyWhenPlayerLeft_ = false;
+
             if (this->bHasLocalController_ && this->bHasHumanController_)
                 this->stopLocalHumanControl();
 
+            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
+                this->getPlayer()->stopControl(this, false);
+
             if (this->hud_)
                 delete this->hud_;
@@ -89,7 +94,4 @@
             if (this->camera_)
                 delete this->camera_;
-
-            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
-                this->getPlayer()->stopControl(this, false);
         }
     }
@@ -231,18 +233,24 @@
     void ControllableEntity::startLocalHumanControl()
     {
-        this->camera_ = new Camera(this);
-        this->camera_->requestFocus();
-        if (this->cameraPositionTemplate_ != "")
-            this->addTemplate(this->cameraPositionTemplate_);
-        if (this->cameraPositions_.size() > 0)
-            this->cameraPositions_.front()->attachCamera(this->camera_);
-        else
-            this->attach(this->camera_);
-
-        if (this->hudtemplate_ != "")
-        {
-            this->hud_ = new OverlayGroup(this);
-            this->hud_->addTemplate(this->hudtemplate_);
-            this->hud_->setOwner(this);
+        if (!this->camera_)
+        {
+            this->camera_ = new Camera(this);
+            this->camera_->requestFocus();
+            if (this->cameraPositionTemplate_ != "")
+                this->addTemplate(this->cameraPositionTemplate_);
+            if (this->cameraPositions_.size() > 0)
+                this->cameraPositions_.front()->attachCamera(this->camera_);
+            else
+                this->attach(this->camera_);
+        }
+
+        if (!this->hud_)
+        {
+            if (this->hudtemplate_ != "")
+            {
+                this->hud_ = new OverlayGroup(this);
+                this->hud_->addTemplate(this->hudtemplate_);
+                this->hud_->setOwner(this);
+            }
         }
     }
Index: /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Light.cc
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Light.cc	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Light.cc	(revision 2447)
@@ -36,5 +36,6 @@
 
 #include "util/String.h"
-#include "util/Convert.h"
+#include "util/Exception.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -43,6 +44,4 @@
 namespace orxonox
 {
-    unsigned int Light::lightCounter_s = 0;
-
     CreateFactory(Light);
 
@@ -51,7 +50,31 @@
         RegisterObject(Light);
 
-        if (this->getScene() && this->getScene()->getSceneManager())
-        this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++));
-        this->getNode()->attachObject(this->light_);
+        this->light_ = 0;
+        this->diffuse_ = ColourValue::White;
+        this->specular_ = ColourValue::White;
+        this->type_ = Ogre::Light::LT_POINT;
+        this->attenuation_ = Vector4(100000, 1, 0, 0);
+        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
+
+        if (Core::showsGraphics())
+        {
+            if (!this->getScene())
+                ThrowException(AbortLoading, "Can't create Light, no scene given.");
+            if (!this->getScene()->getSceneManager())
+                ThrowException(AbortLoading, "Can't create Light, no scene manager given.");
+
+            if (this->getScene() && this->getScene()->getSceneManager())
+            {
+                this->light_ = this->getScene()->getSceneManager()->createLight("Light" + getUniqueNumberString());
+                this->light_->setDirection(WorldEntity::FRONT);
+                this->getNode()->attachObject(this->light_);
+
+                this->updateType();
+                this->updateDiffuseColour();
+                this->updateSpecularColour();
+                this->updateAttenuation();
+                this->updateSpotlightRange();
+            }
+        }
 
         this->registerVariables();
@@ -71,66 +94,42 @@
         SUPER(Light, XMLPort, xmlelement, mode);
 
-        XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point");
-        XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "diffuse",   setDiffuseColour,  getDiffuseColour,  xmlelement, mode, const ColourValue&);
-        XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "specular",  setSpecularColour, getSpecularColour, xmlelement, mode, const ColourValue&);
-        XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "direction", setDirection,      getDirection,      xmlelement, mode, const Vector3&);
+        XMLPortParam(Light, "type",           setTypeString,     getTypeString,     xmlelement, mode).defaultValues("point");
+        XMLPortParam(Light, "diffuse",        setDiffuseColour,  getDiffuseColour,  xmlelement, mode).defaultValues(ColourValue::White);
+        XMLPortParam(Light, "specular",       setSpecularColour, getSpecularColour, xmlelement, mode).defaultValues(ColourValue::White);
+        XMLPortParam(Light, "attenuation",    setAttenuation,    getAttenuation,    xmlelement, mode).defaultValues(Vector4(100000, 1, 0, 0));
+        XMLPortParam(Light, "spotlightrange", setSpotlightRange, getSpotlightRange, xmlelement, mode).defaultValues(Vector3(40.0f, 30.0f, 1.0f));
     }
 
     void Light::registerVariables()
     {
-        REGISTERDATA(this->type_, direction::toclient, new NetworkCallback<Light>(this, &Light::changedType));
-        REGISTERDATA(this->light_->getDiffuseColour(), direction::toclient);
-        REGISTERDATA(this->light_->getSpecularColour(), direction::toclient);
-        REGISTERDATA(this->light_->getDirection(), direction::toclient);
+        REGISTERDATA(this->type_,           direction::toclient, new NetworkCallback<Light>(this, &Light::updateType));
+        REGISTERDATA(this->diffuse_,        direction::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
+        REGISTERDATA(this->specular_,       direction::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
+        REGISTERDATA(this->attenuation_,    direction::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
+        REGISTERDATA(this->spotlightRange_, direction::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
     }
 
-    const std::string& Light::getName() const
+    void Light::updateDiffuseColour()
     {
         if (this->light_)
-            return this->light_->getName();
-        else
-            return BLANKSTRING;
+            this->light_->setDiffuseColour(this->diffuse_);
     }
 
-    void Light::setDiffuseColour(const ColourValue& colour)
+    void Light::updateSpecularColour()
     {
         if (this->light_)
-            this->light_->setDiffuseColour(colour);
+            this->light_->setSpecularColour(this->specular_);
     }
 
-    const ColourValue& Light::getDiffuseColour() const
+    void Light::updateAttenuation()
     {
-        if (this->light_)
-            return this->light_->getDiffuseColour();
-        else
-            return ColourValue::White;
+        if (this->light_ && this->type_ != Ogre::Light::LT_DIRECTIONAL)
+            this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w);
     }
 
-    void Light::setSpecularColour(const ColourValue& colour)
+    void Light::updateSpotlightRange()
     {
-        if (this->light_)
-            this->light_->setSpecularColour(colour);
-    }
-
-    const ColourValue& Light::getSpecularColour() const
-    {
-        if (this->light_)
-            return this->light_->getSpecularColour();
-        else
-            return ColourValue::White;
-    }
-
-    void Light::setDirection(const Vector3& direction)
-    {
-        if (this->light_)
-            this->light_->setDirection(direction);
-    }
-
-    const Vector3& Light::getDirection() const
-    {
-        if (this->light_)
-            return this->light_->getDirection();
-        else
-            return Vector3::ZERO;
+        if (this->light_ && this->type_ == Ogre::Light::LT_SPOTLIGHT)
+            this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z);
     }
 
@@ -157,12 +156,19 @@
             case Ogre::Light::LT_POINT:
             default:
-                return "poinT";
+                return "point";
         }
     }
 
-    void Light::changedType()
+    void Light::updateType()
     {
         if (this->light_)
+        {
             this->light_->setType(this->type_);
+
+            if (this->type_ != Ogre::Light::LT_DIRECTIONAL)
+                this->updateAttenuation();
+            if (this->type_ == Ogre::Light::LT_SPOTLIGHT)
+                this->updateSpotlightRange();
+        }
     }
 
Index: /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Light.h
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Light.h	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Light.h	(revision 2447)
@@ -54,19 +54,67 @@
                 { return this->light_; }
 
-            const std::string& getName() const;
-
             inline void setType(Ogre::Light::LightTypes type)
-                { this->type_ = type; this->changedType(); }
-            Ogre::Light::LightTypes getType() const
+                { this->type_ = type; this->updateType(); }
+            inline Ogre::Light::LightTypes getType() const
                 { return this->type_; }
 
-            void setDiffuseColour(const ColourValue& colour);
-            const ColourValue& getDiffuseColour() const;
+            inline void setDiffuseColour(const ColourValue& colour)
+                { this->diffuse_ = colour; this->updateDiffuseColour(); }
+            inline const ColourValue& getDiffuseColour() const
+                { return this->diffuse_; }
 
-            void setSpecularColour(const ColourValue& colour);
-            const ColourValue& getSpecularColour() const;
+            inline void setSpecularColour(const ColourValue& colour)
+                { this->specular_ = colour; this->updateSpecularColour(); }
+            inline const ColourValue& getSpecularColour() const
+                { return this->specular_; }
 
-            void setDirection(const Vector3& direction);
-            const Vector3& getDirection() const;
+            /**
+                @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance.
+
+                @param attenuation.x range (The absolute upper range of the light in world units)
+                @param attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation)
+                @param attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance)
+                @param attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula)
+
+                Quote from the Ogre API:
+                Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects.
+                Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity.
+                This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here!
+
+                Quote from the Ogre wiki:
+                "Using these numbers, the light has 100% intensity at 0 distance, and
+                trails off to near black at a distance equal to the Range. Keep in mind
+                that most of the light falls in the first 20% of the range."
+
+                Range   Constant   Linear     Quadratic
+                3250,     1.0,     0.0014,    0.000007
+                600,      1.0,     0.007,     0.0002
+                325,      1.0,     0.014,     0.0007
+                200,      1.0,     0.022,     0.0019
+                160,      1.0,     0.027,     0.0028
+                100,      1.0,     0.045,     0.0075
+                65,       1.0,     0.07,      0.017
+                50,       1.0,     0.09,      0.032
+                32,       1.0,     0.14,      0.07
+                20,       1.0,     0.22,      0.20
+                13,       1.0,     0.35,      0.44
+                7,        1.0,     0.7,       1.8
+            */
+            inline void setAttenuation(const Vector4& attenuation)
+                { this->attenuation_ = attenuation; this->updateAttenuation(); }
+            inline const Vector4& getAttenuation() const
+                { return this->attenuation_; }
+
+            /**
+                @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them.
+
+                @param spotlightRange.x innerAngle (The angle covered by the bright inner cone)
+                @param spotlightRange.x outerAngle (The angle covered by the outer cone)
+                @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.)
+            */
+            inline void setSpotlightRange(const Vector3& spotlightRange)
+                { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); }
+            inline const Vector3& getSpotlightRange() const
+                { return this->spotlightRange_; }
 
         private:
@@ -74,10 +122,16 @@
             std::string getTypeString() const;
 
-            void changedType();
+            void updateType();
+            void updateDiffuseColour();
+            void updateSpecularColour();
+            void updateAttenuation();
+            void updateSpotlightRange();
 
-            static unsigned int lightCounter_s;
             Ogre::Light* light_;
             Ogre::Light::LightTypes type_;
-
+            ColourValue diffuse_;
+            ColourValue specular_;
+            Vector4 attenuation_;
+            Vector3 spotlightRange_;
     };
 }
Index: /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Model.cc
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Model.cc	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Model.cc	(revision 2447)
@@ -41,4 +41,6 @@
     {
         RegisterObject(Model);
+
+        this->bCastShadows_ = true;
 
         this->registerVariables();
Index: /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2446)
+++ /code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2447)
@@ -180,5 +180,5 @@
             effect->setOrientation(this->getOrientation());
             effect->setDestroyAfterLife(true);
-            effect->setSource("Orxonox/explosion2");
+            effect->setSource("Orxonox/explosion2b");
             effect->setLifetime(4.0f);
         }
