Index: code/branches/objecthierarchy/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/objecthierarchy/src/orxonox/CMakeLists.txt	(revision 2026)
+++ code/branches/objecthierarchy/src/orxonox/CMakeLists.txt	(revision 2027)
@@ -1,4 +1,5 @@
 SET( ORXONOX_SRC_FILES
   GraphicsEngine.cc
+  LevelManager.cc
   Main.cc
   Settings.cc
@@ -43,5 +44,11 @@
   tools/WindowEventListener.cc
 
-  LevelManager.cc
+  objects/CameraHandler.cc
+  objects/Radar.cc
+  objects/RadarListener.cc
+  objects/RadarViewable.cc
+  objects/Tickable.cc
+  objects/Test.cc
+  objects/Script.cc
 
   objects/Scene.cc
@@ -50,21 +57,12 @@
   objects/worldentities/MovableEntity.cc
   objects/worldentities/ControllableEntity.cc
+  objects/worldentities/Model.cc
+  objects/worldentities/Camera.cc
+  objects/worldentities/SpawnPoint.cc
+#  objects/worldentities/Backlight.cc
+#  objects/worldentities/ParticleSpawner.cc
 
-  objects/worldentities/Model.cc
-
-#  objects/Backlight.cc
-  objects/Camera.cc
-  objects/CameraHandler.cc
-#  objects/ParticleSpawner.cc
-  objects/Radar.cc
-  objects/RadarListener.cc
-  objects/RadarViewable.cc
-  objects/Tickable.cc
-  objects/Test.cc
-  objects/Script.cc
-  objects/Trigger.cc
-  objects/DistanceTrigger.cc
-
-  objects/worldentities/SpawnPoint.cc
+  objects/worldentities/triggers/Trigger.cc
+  objects/worldentities/triggers/DistanceTrigger.cc
 
   objects/worldentities/pawns/Spectator.cc
Index: code/branches/objecthierarchy/src/orxonox/objects/Backlight.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/Backlight.cc	(revision 2026)
+++ 	(revision )
@@ -1,170 +1,0 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Backlight.h"
-
-#include <OgreBillboard.h>
-#include <OgreRibbonTrail.h>
-#include <OgreSceneManager.h>
-
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/Executor.h"
-#include "util/Math.h"
-#include "GraphicsEngine.h"
-
-namespace orxonox
-{
-    CreateFactory(Backlight);
-
-    float Backlight::timeFactor_s = 1.0;
-
-    Backlight::Backlight(float maxspeed, float brakingtime, float scale)
-    {
-        RegisterObject(Backlight);
-
-        this->setConfigValues();
-        this->traillength_ = 1;
-
-        this->configure(maxspeed, brakingtime, scale);
-    }
-    
-    bool Backlight::create(){
-      if(!WorldEntity::create())
-        return false;
-      
-      this->getNode()->setInheritScale(false);
-
-      this->billboard_.setBillboardSet("Flares/backlightflare");
-      this->attachObject(this->billboard_.getBillboardSet());
-
-      this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
-      this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
-      this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
-      this->ribbonTrail_->addNode(this->getNode());
-
-
-      this->ribbonTrail_->setTrailLength(this->maxTraillength_);
-      this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
-
-        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
-      this->setTimeFactor(1.0f);
-      
-      this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
-      this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
-      this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
-      this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
-      return true;
-    }
-
-    Backlight::~Backlight()
-    {
-        if (this->isInitialized())
-        {
-            this->detachObject(this->billboard_.getBillboardSet());
-            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
-            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
-        }
-    }
-
-    void Backlight::setConfigValues()
-    {
-        SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
-        SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
-        SetConfigValue(width_, 7.0).description("The width of the trail");
-    }
-
-    void Backlight::setTimeFactor(float factor)
-    {
-        Backlight::timeFactor_s = factor;
-        float change = Backlight::timeFactor_s / this->maxLifeTime_;
-        this->ribbonTrail_->setWidthChange(0, this->width_ * change);
-        this->updateColourChange();
-    }
-
-    void Backlight::updateColourChange()
-    {
-        this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
-    }
-    
-    
-    void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){
-      SUPER(Backlight, XMLPort, xmlelement, mode);
-      
-      Backlight::create();
-    }
-
-    void Backlight::tick(float dt)
-    {
-        SUPER(Backlight, tick, dt);
-
-        if (this->isActive())
-        {
-            if (this->traillength_ < this->maxTraillength_)
-            {
-                this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
-                this->updateColourChange();
-            }
-        }
-        else
-        {
-            if (this->traillength_ > 1)
-            {
-                this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
-                this->updateColourChange();
-            }
-        }
-
-        this->ribbonTrail_->setTrailLength(this->traillength_);
-    }
-
-    void Backlight::setColour(const ColourValue& colour)
-    {
-        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
-        this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75));
-    }
-
-    void Backlight::configure(float maxspeed, float brakingtime, float scale)
-    {
-        this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
-        this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
-
-        this->brakefactor_ = this->maxLifeTime_ / brakingtime;
-
-        this->scale(scale);
-    }
-
-    void Backlight::changedVisibility()
-    {
-        SUPER(Backlight, changedVisibility);
-
-        this->billboard_.setVisible(this->isVisible());
-        this->ribbonTrail_->setVisible(this->isVisible());
-    }
-}
Index: code/branches/objecthierarchy/src/orxonox/objects/Backlight.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/Backlight.h	(revision 2026)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _Backlight_H__
-#define _Backlight_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "WorldEntity.h"
-#include "tools/BillboardSet.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport Backlight : public WorldEntity
-    {
-        public:
-            Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
-            virtual ~Backlight();
-
-            void setConfigValues();
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void tick(float dt);
-            virtual void changedVisibility();
-            virtual bool create();
-
-            void setColour(const ColourValue& colour);
-            void setTimeFactor(float factor);
-
-        private:
-            void configure(float maxspeed, float brakingtime, float scale = 1);
-            void updateColourChange();
-
-            static float timeFactor_s;
-            BillboardSet billboard_;
-            Ogre::SceneNode* ribbonTrailNode_;
-            Ogre::RibbonTrail* ribbonTrail_;
-
-            float maxLifeTime_;
-            float trailSegmentLength_;
-            float width_;
-
-            float brakefactor_;
-
-            float maxTraillength_;
-            float traillength_;
-
-            size_t maxTrailsegments_;
-    };
-}
-
-#endif /* _Backlight_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/Camera.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/Camera.cc	(revision 2026)
+++ 	(revision )
@@ -1,126 +1,0 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Benjamin Knecht
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Camera.h"
-
-#include <string>
-#include <cassert>
-
-#include <OgreCamera.h>
-#include <OgreSceneManager.h>
-#include <OgreSceneNode.h>
-#include <OgreViewport.h>
-
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "objects/Scene.h"
-#include "objects/CameraHandler.h"
-
-namespace orxonox
-{
-    CreateFactory(Camera);
-
-    Camera::Camera(BaseObject* creator) : PositionableEntity(creator)
-    {
-        RegisterObject(Camera);
-
-        assert(this->getScene());
-        assert(this->getScene()->getSceneManager());
-
-        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
-        this->getNode()->attachObject(this->camera_);
-
-        this->bHasFocus_ = false;
-        this->bDrag_ = false;
-        this->nearClipDistance_ = 1;
-
-        this->setObjectMode(0x0);
-
-        this->setConfigValues();
-        this->configvaluecallback_changedNearClipDistance();
-
-        this->requestFocus(); // ! HACK ! REMOVE THIS !
-    }
-
-    Camera::~Camera()
-    {
-        if (this->isInitialized())
-        {
-            this->releaseFocus();
-        }
-    }
-
-    void Camera::setConfigValues()
-    {
-        SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance);
-    }
-
-    void Camera::configvaluecallback_changedNearClipDistance()
-    {
-        this->camera_->setNearClipDistance(this->nearClipDistance_);
-    }
-
-    void Camera::tick(float dt)
-    {
-/*
-        // this stuff here may need some adjustments
-        float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
-
-        Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
-        this->cameraNode_->translate(coeff * offset);
-
-        this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
-*/
-    }
-
-    void Camera::requestFocus()
-    {
-        CameraHandler::getInstance().requestFocus(this);
-    }
-
-    void Camera::releaseFocus()
-    {
-        CameraHandler::getInstance().releaseFocus(this);
-    }
-
-    /**
-        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;
-    }
-
-    void Camera::setFocus(Ogre::Viewport* viewport)
-    {
-        this->bHasFocus_ = true;
-        viewport->setCamera(this->camera_);
-    }
-}
Index: code/branches/objecthierarchy/src/orxonox/objects/Camera.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/Camera.h	(revision 2026)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Benjamin Knecht
- *
- */
-
-#ifndef _Camera_H__
-#define _Camera_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <OgrePrerequisites.h>
-#include "objects/worldentities/PositionableEntity.h"
-#include "objects/Tickable.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport Camera : public PositionableEntity, public Tickable
-    {
-        friend class CameraHandler;
-
-        public:
-            Camera(BaseObject* creator);
-            virtual ~Camera();
-
-            void setConfigValues();
-            virtual void tick(float dt);
-
-            void requestFocus();
-            void releaseFocus();
-
-            inline bool hasFocus()
-                { return this->bHasFocus_; }
-
-            inline void setDrag(bool bDrag)
-                { this->bDrag_ = bDrag; }
-            inline bool getDrag() const
-                { return this->bDrag_; }
-
-        private:
-            void removeFocus();
-            void setFocus(Ogre::Viewport* viewport);
-            void configvaluecallback_changedNearClipDistance();
-
-            Ogre::Camera*   camera_;
-            float           nearClipDistance_;
-            bool            bHasFocus_;
-            bool            bDrag_;
-    };
-}
-
-#endif /* _Camera_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc	(revision 2026)
+++ code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc	(revision 2027)
@@ -32,5 +32,5 @@
 
 #include "core/Core.h"
-#include "Camera.h"
+#include "objects/worldentities/Camera.h"
 
 
Index: code/branches/objecthierarchy/src/orxonox/objects/DistanceTrigger.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/DistanceTrigger.cc	(revision 2026)
+++ 	(revision )
@@ -1,125 +1,0 @@
-/*
- *   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 "OrxonoxStableHeaders.h"
-#include "DistanceTrigger.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox {
-
-  CreateFactory(DistanceTrigger);
-
-  DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)
-  {
-    RegisterObject(DistanceTrigger);
-
-    targetMask_.exclude(Class(BaseObject));
-  }
-
-  DistanceTrigger::~DistanceTrigger()
-  {
-  }
-
-  void DistanceTrigger::addTarget(Ogre::Node* targetNode)
-  {
-    this->targetSet_.insert(targetNode);
-  }
-
-  void DistanceTrigger::removeTarget(Ogre::Node* targetNode)
-  {
-    int returnval = this->targetSet_.erase(targetNode);
-    if (returnval == 0)
-    {
-      COUT(2) << "Warning: Node " << targetNode << " did not exist in targetSet of trigger " << this << " !" << std::endl;
-      COUT(4) << "Content of targetSet of trigger " << this << " :" << std::endl;
-      std::set<Ogre::Node*>::iterator it;
-      for(it = this->targetSet_.begin(); it != this->targetSet_.end(); it++)
-      {
-        COUT(4) << *it << std::endl;
-      }
-      COUT(4) << "End of targetSet of trigger " << this << std::endl;
-    }
-  }
-
-  void DistanceTrigger::addTargets(const std::string& targets)
-  {
-    Identifier* targetId = ClassByString(targets);
-    targetMask_.include(targetId);
-    // trigger shouldn't react on itself or other triggers
-    targetMask_.exclude(Class(Trigger), true);
-
-  }
-
-  void DistanceTrigger::removeTargets(const std::string& targets)
-  {
-    Identifier* targetId = ClassByString(targets);
-    targetMask_.exclude(targetId);
-  }
-
-  bool DistanceTrigger::checkDistance()
-  {
-    // Iterate through all WorldEntities
-    for(Iterator<WorldEntity> it = ObjectList<WorldEntity>::begin(); it; it++)
-    {
-      // check if WorldEntity is a target
-      if(targetMask_.isIncluded(it->getIdentifier()))
-      {
-        Vector3 distanceVec = it->getNode()->getWorldPosition() - this->getNode()->getWorldPosition();
-        if (distanceVec.length() < this->distance_)
-        {
-          return true;
-        }
-      }
-    }
-    return false;
-
-  }
-
-  void DistanceTrigger::setDistance(float dist)
-  {
-    this->distance_ = dist;
-  }
-
-  void DistanceTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-  {
-    Trigger::XMLPort(xmlelement, mode);
-
-    XMLPortParamLoadOnly(DistanceTrigger, "distance", setDistance, xmlelement, mode);
-    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode);
-  }
-
-  bool DistanceTrigger::isTriggered(TriggerMode mode)
-  {
-    if(Trigger::isTriggered(mode))
-      return checkDistance();
-    else
-      return false;
-  }
-}
Index: code/branches/objecthierarchy/src/orxonox/objects/DistanceTrigger.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/DistanceTrigger.h	(revision 2026)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*
- *   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:
- *      ...
- *
- */
-
-#ifndef _DistanceTrigger_H__
-#define _DistanceTrigger_H__
-
-#include "Trigger.h"
-
-#include <set>
-
-#include <OgreNode.h>
-
-#include "core/ClassTreeMask.h"
-#include "core/BaseObject.h"
-
-namespace orxonox {
-
-  class _OrxonoxExport DistanceTrigger : public Trigger
-  {
-    public:
-      DistanceTrigger(BaseObject* creator);
-      ~DistanceTrigger();
-      void addTarget(Ogre::Node* targetNode);
-      void removeTarget(Ogre::Node* targetNode);
-      void addTargets(const std::string& targets);
-      void removeTargets(const std::string& targets);
-      void setDistance(float dist);
-      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-      bool checkDistance();
-
-    protected:
-      bool isTriggered(TriggerMode mode);
-
-    private:
-      ClassTreeMask targetMask_;
-      std::set<Ogre::Node*> targetSet_;
-      float distance_;
-  };
-
-}
-
-#endif /* _Trigger_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/ParticleSpawner.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/ParticleSpawner.cc	(revision 2026)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "ParticleSpawner.h"
-
-#include <OgreSceneManager.h>
-#include "core/CoreIncludes.h"
-#include "core/Executor.h"
-#include "tools/ParticleInterface.h"
-#include "GraphicsEngine.h"
-
-namespace orxonox
-{
-    CreateFactory(ParticleSpawner);
-
-    ParticleSpawner::ParticleSpawner()
-    {
-        RegisterObject(ParticleSpawner);
-        this->particle_ = 0;
-    }
-
-    ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction)
-    {
-        RegisterObject(ParticleSpawner);
-        this->setParticle(templateName, detaillevel, lifetime, startdelay, destroydelay, direction);
-    }
-
-    void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction)
-    {
-        ExecutorMember<ParticleSpawner>* executor = createExecutor(createFunctor(&ParticleSpawner::createParticleSpawner));
-        this->destroydelay_ = destroydelay;
-        executor->setDefaultValues(lifetime);
-        this->timer_.setTimer(startdelay, false, this, executor);
-        this->particle_ = new ParticleInterface(templateName, detaillevel);
-        this->particle_->addToSceneNode(this->getNode());
-        this->particle_->setEnabled(false);
-        if (direction != Vector3::ZERO)
-        {
-            this->particle_->getAllEmitters()->setDirection(direction);
-        }
-    }
-
-    ParticleSpawner::~ParticleSpawner()
-    {
-        if (this->isInitialized() && this->particle_)
-        {
-            this->particle_->detachFromSceneNode();
-            delete this->particle_;
-        }
-    };
-
-    void ParticleSpawner::destroy()
-    {
-        this->setPosition(this->getNode()->getParent()->getPosition());
-        this->getNode()->getParent()->removeChild(this->getNode());
-        this->detachFromParent();
-        if (this->particle_)
-            this->particle_->setEnabled(false);
-        if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_)
-            this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
-    }
-
-    void ParticleSpawner::createParticleSpawner(float lifetime)
-    {
-        this->particle_->setEnabled(true);
-        if (lifetime != 0)
-            this->timer_.setTimer(lifetime, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
-    }
-
-    void ParticleSpawner::destroyParticleSpawner()
-    {
-        delete this;
-    }
-
-    void ParticleSpawner::setVisible(bool visible)
-    {
-        if (this->particle_)
-            this->particle_->setEnabled(visible);
-    }
-}
Index: code/branches/objecthierarchy/src/orxonox/objects/ParticleSpawner.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/ParticleSpawner.h	(revision 2026)
+++ 	(revision )
@@ -1,63 +1,0 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _ParticleSpawner_H__
-#define _ParticleSpawner_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "WorldEntity.h"
-#include "tools/Timer.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport ParticleSpawner : public WorldEntity
-    {
-        public:
-            ParticleSpawner();
-            ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO);
-            virtual ~ParticleSpawner();
-            void destroy();
-
-            void setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO);
-            inline ParticleInterface* getParticleInterface() const
-                { return this->particle_; }
-
-            void setVisible(bool visible);
-
-        private:
-            void createParticleSpawner(float lifetime);
-            void destroyParticleSpawner();
-
-            Timer<ParticleSpawner> timer_;
-            ParticleInterface* particle_;
-            float destroydelay_;
-    };
-}
-
-#endif /* _ParticleSpawner_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/Trigger.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/Trigger.cc	(revision 2026)
+++ 	(revision )
@@ -1,298 +1,0 @@
-/*
- *   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 "OrxonoxStableHeaders.h"
-#include "Trigger.h"
-
-#include <OgreBillboard.h>
-#include "util/Debug.h"
-#include "core/CoreIncludes.h"
-#include "core/ConsoleCommand.h"
-#include "core/XMLPort.h"
-#include "objects/Scene.h"
-
-namespace orxonox
-{
-
-  SetConsoleCommand(Trigger, debugFlares, false).defaultValues(false);
-
-  CreateFactory(Trigger);
-
-  Trigger::Trigger(BaseObject* creator) : PositionableEntity(creator)
-  {
-    RegisterObject(Trigger);
-
-    mode_ = TM_EventTriggerAND;
-    bActive_ = false;
-    bInvertMode_ = false;
-    delay_ = 0.0;
-    bTriggered_ = false;
-    bUpdating_ = false;
-    remainingActivations_ = -1;
-    bStayOn_ = false;
-    latestState_ = 0x0;
-
-    if (this->getScene() && this->getScene()->getSceneManager())
-    {
-      debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
-      debugBillboard_.setVisible(false);
-    }
-
-    this->getNode()->attachObject(debugBillboard_.getBillboardSet());
-  }
-
-  Trigger::~Trigger()
-  {
-  }
-
-  void Trigger::init()
-  {
-    timeSinceLastEvent_ = delay_;
-  }
-
-  void Trigger::debugFlares(bool bVisible)
-  {
-    for (ObjectList<Trigger>::iterator it = ObjectList<Trigger>::begin(); it != ObjectList<Trigger>::end(); ++it)
-      it->setVisible(bVisible);
-  }
-
-  void Trigger::changedVisibility()
-  {
-    debugBillboard_.setVisible(this->isVisible());
-  }
-
-  const Trigger* Trigger::getTrigger(unsigned int index) const
-  {
-    if (children_.size() <= index)
-      return NULL;
-
-    std::set<Trigger*>::const_iterator it;
-    it = children_.begin();
-
-    for ( unsigned int i = 0; i != index; i++ )
-    {
-      it++;
-    }
-    return *it;
-  }
-
-  void Trigger::tick(float dt)
-  {
-
-    bool newTriggered;
-    newTriggered = this->isTriggered();
-
-    // check if new triggering event is really new
-    if((this->latestState_ & 0x1) != newTriggered)
-    {
-      // create new state
-      if(newTriggered)
-      {
-        latestState_ |= 1; // set trigger bit
-        this->switchState();
-      }
-      else
-      {
-        latestState_ &= 0xFE; // set trigger bit
-        if (this->bStayOn_)
-          this->storeState();
-        else
-          this->switchState();
-      }
-    }
-
-    if(remainingTime_ > 0.0)
-    {
-      remainingTime_ -= dt;
-      // only increase when acctually waiting for a state in the queue
-      if(timeSinceLastEvent_ >= 0.0)
-        timeSinceLastEvent_ += dt;
-    }
-
-    while(remainingTime_ <= 0.0 && stateChanges_.size() > 0)
-    {
-      // time ran out, change state to new one
-      char newState = stateChanges_.front().second;
-      bTriggered_ = (newState & 0x1);
-      bActive_ = newState & 2;
-      this->stateChanges_.pop();
-      if(stateChanges_.size() != 0)
-        remainingTime_ = stateChanges_.front().first;
-      else
-        timeSinceLastEvent_ = delay_;
-    }
-
-
-
-    if (bTriggered_ && bActive_)
-      this->setBillboardColour(ColourValue(0.5, 1.0, 0.0));
-    else if (!bTriggered_ && bActive_)
-      this->setBillboardColour(ColourValue(0.0, 1.0, 0.0));
-    else if (bTriggered_ && !bActive_)
-      this->setBillboardColour(ColourValue(1.0, 0.5, 0.0));
-    else
-      this->setBillboardColour(ColourValue(1.0, 0.0, 0.0));
-    bUpdating_ = false;
-  }
-
-  void Trigger::setBillboardColour(ColourValue colour)
-  {
-    this->debugBillboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
-  }
-
-  void Trigger::storeState()
-  {
-    // put state change into queue
-    this->stateChanges_.push(std::pair<float,char>(timeSinceLastEvent_, latestState_));
-    // reset time since last event
-    timeSinceLastEvent_ = 0.0;
-
-    if(this->stateChanges_.size() == 1)
-      remainingTime_ = stateChanges_.front().first;
-  }
-
-  bool Trigger::isTriggered(TriggerMode mode)
-  {
-    if(bUpdating_)
-      return bTriggered_;
-
-    if( children_.size() != 0 )
-    {
-      bUpdating_ = true;
-      bool returnval = false;
-      switch(mode)
-      {
-        case TM_EventTriggerAND:
-          returnval = checkAnd();
-          break;
-        case TM_EventTriggerOR:
-          returnval = checkOr();
-          break;
-        case TM_EventTriggerXOR:
-          returnval = checkXor();
-          break;
-        default:
-          returnval = false;
-          break;
-      }
-      if(bInvertMode_)
-        return !returnval;
-      else
-        return returnval;
-    }
-    return true;
-  }
-
-  void Trigger::setDelay(float delay)
-  {
-    this->delay_ = delay;
-  }
-
-  void Trigger::setMode(const std::string& modeName)
-  {
-    if (modeName == "and")
-      setMode(TM_EventTriggerAND);
-    else if (modeName == "or")
-      setMode(TM_EventTriggerOR);
-    else if (modeName == "xor")
-      setMode(TM_EventTriggerXOR);
-  }
-
-  void Trigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-  {
-    WorldEntity::XMLPort(xmlelement, mode);
-
-    XMLPortParamLoadOnly(Trigger, "delay", setDelay, xmlelement, mode);
-    XMLPortParamLoadOnly(Trigger, "stayOn", setStayOn, xmlelement, mode);
-    XMLPortParamLoadOnly(Trigger, "activations", setActivations, xmlelement, mode);
-    XMLPortParamLoadOnly(Trigger, "invert", setInvert, xmlelement, mode);
-    XMLPortParamLoadOnlyTemplate(Trigger, "mode", setMode, xmlelement, mode, const std::string&);
-
-    XMLPortObject(Trigger, Trigger, "", addTrigger, getTrigger, xmlelement, mode);
-
-    this->init();
-  }
-
-  void Trigger::addTrigger(Trigger* trig)
-  {
-    if (this != trig)
-      this->children_.insert(trig);
-  }
-
-  bool Trigger::switchState()
-  {
-    if ( remainingActivations_ <= -1 || this->latestState_ & 2 || remainingActivations_ > 0)
-    {
-      this->latestState_ ^= 2; // toggle state bit
-      // increase activation count
-      if (this->latestState_ & 2) remainingActivations_--;
-      this->storeState();
-
-      return true;
-    }
-    return false;
-  }
-
-
-  bool Trigger::checkAnd()
-  {
-    std::set<Trigger*>::iterator it;
-    for(it = this->children_.begin(); it != this->children_.end(); it++)
-    {
-      if(!((*it)->isActive()))
-        return false;
-    }
-    return true;
-  }
-
-  bool Trigger::checkOr()
-  {
-    std::set<Trigger*>::iterator it;
-    for(it = this->children_.begin(); it != this->children_.end(); it++)
-    {
-      if((*it)->isActive())
-        return true;
-    }
-    return false;
-  }
-
-  bool Trigger::checkXor()
-  {
-    std::set<Trigger*>::iterator it;
-    bool test = false;
-    for(it = this->children_.begin(); it != this->children_.end(); it++)
-    {
-      if(test && (*it)->isActive())
-        return false;
-      if((*it)->isActive())
-        test = true;
-    }
-    return test;
-  }
-
-}
Index: code/branches/objecthierarchy/src/orxonox/objects/Trigger.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/Trigger.h	(revision 2026)
+++ 	(revision )
@@ -1,113 +1,0 @@
-/*
- *   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:
- *      ...
- *
- */
-
-#ifndef _Trigger_H__
-#define _Trigger_H__
-
-#include <set>
-#include <queue>
-
-#include "OrxonoxPrereqs.h"
-
-#include "worldentities/PositionableEntity.h"
-#include "tools/BillboardSet.h"
-
-namespace orxonox {
-
-  enum TriggerMode
-  {
-    TM_EventTriggerAND,
-    TM_EventTriggerOR,
-    TM_EventTriggerXOR,
-  };
-
-  class _OrxonoxExport Trigger : public PositionableEntity
-  {
-    public:
-      Trigger(BaseObject* creator);
-      ~Trigger();
-
-      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-      virtual void tick(float dt);
-
-      inline bool isActive() const
-        { return bActive_; }
-
-      void addTrigger(Trigger* trig);
-      const Trigger* getTrigger(unsigned int index) const;
-
-      inline TriggerMode getMode() const
-        { return mode_; }
-      inline void setMode(TriggerMode mode)
-        { this->mode_ = mode; }
-      void setMode(const std::string& modeName);
-
-      inline void setInvert(int invert)
-        { bInvertMode_ = invert; }
-      inline void setStayOn(int stayOn)
-        { this->bStayOn_ = (stayOn == 1) ? true : false; }
-      inline void setActivations(int activations)
-        { this->remainingActivations_ = activations; }
-      void setDelay(float delay);
-      bool switchState();
-
-      static void debugFlares(bool bVisible);
-      virtual void changedVisibility();
-
-    private:
-      void init();
-      bool checkAnd();
-      bool checkOr();
-      bool checkXor();
-      void setBillboardColour(ColourValue colour);
-      void storeState();
-
-    protected:
-      inline bool isTriggered() { return this->isTriggered(this->mode_); }
-      virtual bool isTriggered(TriggerMode mode);
-
-    private:
-      std::set<Trigger*> children_;
-      std::queue<std::pair<float,char> > stateChanges_;
-      float remainingTime_;
-      float timeSinceLastEvent_;
-      TriggerMode mode_;
-      bool bActive_;
-      bool bInvertMode_;
-      bool bTriggered_;
-      bool bUpdating_;
-      BillboardSet debugBillboard_;
-      float delay_;
-      int remainingActivations_;
-      bool bStayOn_;
-      char latestState_;
-  };
-
-}
-
-#endif /* _Trigger_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/Backlight.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/Backlight.cc	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/Backlight.cc	(revision 2027)
@@ -0,0 +1,170 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Backlight.h"
+
+#include <OgreBillboard.h>
+#include <OgreRibbonTrail.h>
+#include <OgreSceneManager.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Executor.h"
+#include "util/Math.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(Backlight);
+
+    float Backlight::timeFactor_s = 1.0;
+
+    Backlight::Backlight(float maxspeed, float brakingtime, float scale)
+    {
+        RegisterObject(Backlight);
+
+        this->setConfigValues();
+        this->traillength_ = 1;
+
+        this->configure(maxspeed, brakingtime, scale);
+    }
+    
+    bool Backlight::create(){
+      if(!WorldEntity::create())
+        return false;
+      
+      this->getNode()->setInheritScale(false);
+
+      this->billboard_.setBillboardSet("Flares/backlightflare");
+      this->attachObject(this->billboard_.getBillboardSet());
+
+      this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
+      this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
+      this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
+      this->ribbonTrail_->addNode(this->getNode());
+
+
+      this->ribbonTrail_->setTrailLength(this->maxTraillength_);
+      this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
+
+        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
+      this->setTimeFactor(1.0f);
+      
+      this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
+      this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
+      this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
+      this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
+      return true;
+    }
+
+    Backlight::~Backlight()
+    {
+        if (this->isInitialized())
+        {
+            this->detachObject(this->billboard_.getBillboardSet());
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
+        }
+    }
+
+    void Backlight::setConfigValues()
+    {
+        SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
+        SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
+        SetConfigValue(width_, 7.0).description("The width of the trail");
+    }
+
+    void Backlight::setTimeFactor(float factor)
+    {
+        Backlight::timeFactor_s = factor;
+        float change = Backlight::timeFactor_s / this->maxLifeTime_;
+        this->ribbonTrail_->setWidthChange(0, this->width_ * change);
+        this->updateColourChange();
+    }
+
+    void Backlight::updateColourChange()
+    {
+        this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
+    }
+    
+    
+    void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){
+      SUPER(Backlight, XMLPort, xmlelement, mode);
+      
+      Backlight::create();
+    }
+
+    void Backlight::tick(float dt)
+    {
+        SUPER(Backlight, tick, dt);
+
+        if (this->isActive())
+        {
+            if (this->traillength_ < this->maxTraillength_)
+            {
+                this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
+                this->updateColourChange();
+            }
+        }
+        else
+        {
+            if (this->traillength_ > 1)
+            {
+                this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
+                this->updateColourChange();
+            }
+        }
+
+        this->ribbonTrail_->setTrailLength(this->traillength_);
+    }
+
+    void Backlight::setColour(const ColourValue& colour)
+    {
+        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+        this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75));
+    }
+
+    void Backlight::configure(float maxspeed, float brakingtime, float scale)
+    {
+        this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
+        this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
+
+        this->brakefactor_ = this->maxLifeTime_ / brakingtime;
+
+        this->scale(scale);
+    }
+
+    void Backlight::changedVisibility()
+    {
+        SUPER(Backlight, changedVisibility);
+
+        this->billboard_.setVisible(this->isVisible());
+        this->ribbonTrail_->setVisible(this->isVisible());
+    }
+}
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/Backlight.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/Backlight.h	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/Backlight.h	(revision 2027)
@@ -0,0 +1,76 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Backlight_H__
+#define _Backlight_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Backlight : public WorldEntity
+    {
+        public:
+            Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
+            virtual ~Backlight();
+
+            void setConfigValues();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            virtual void changedVisibility();
+            virtual bool create();
+
+            void setColour(const ColourValue& colour);
+            void setTimeFactor(float factor);
+
+        private:
+            void configure(float maxspeed, float brakingtime, float scale = 1);
+            void updateColourChange();
+
+            static float timeFactor_s;
+            BillboardSet billboard_;
+            Ogre::SceneNode* ribbonTrailNode_;
+            Ogre::RibbonTrail* ribbonTrail_;
+
+            float maxLifeTime_;
+            float trailSegmentLength_;
+            float width_;
+
+            float brakefactor_;
+
+            float maxTraillength_;
+            float traillength_;
+
+            size_t maxTrailsegments_;
+    };
+}
+
+#endif /* _Backlight_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.cc	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.cc	(revision 2027)
@@ -0,0 +1,126 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Benjamin Knecht
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Camera.h"
+
+#include <string>
+#include <cassert>
+
+#include <OgreCamera.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreViewport.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "objects/Scene.h"
+#include "objects/CameraHandler.h"
+
+namespace orxonox
+{
+    CreateFactory(Camera);
+
+    Camera::Camera(BaseObject* creator) : PositionableEntity(creator)
+    {
+        RegisterObject(Camera);
+
+        assert(this->getScene());
+        assert(this->getScene()->getSceneManager());
+
+        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
+        this->getNode()->attachObject(this->camera_);
+
+        this->bHasFocus_ = false;
+        this->bDrag_ = false;
+        this->nearClipDistance_ = 1;
+
+        this->setObjectMode(0x0);
+
+        this->setConfigValues();
+        this->configvaluecallback_changedNearClipDistance();
+
+        this->requestFocus(); // ! HACK ! REMOVE THIS !
+    }
+
+    Camera::~Camera()
+    {
+        if (this->isInitialized())
+        {
+            this->releaseFocus();
+        }
+    }
+
+    void Camera::setConfigValues()
+    {
+        SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance);
+    }
+
+    void Camera::configvaluecallback_changedNearClipDistance()
+    {
+        this->camera_->setNearClipDistance(this->nearClipDistance_);
+    }
+
+    void Camera::tick(float dt)
+    {
+/*
+        // this stuff here may need some adjustments
+        float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
+
+        Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
+        this->cameraNode_->translate(coeff * offset);
+
+        this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
+*/
+    }
+
+    void Camera::requestFocus()
+    {
+        CameraHandler::getInstance().requestFocus(this);
+    }
+
+    void Camera::releaseFocus()
+    {
+        CameraHandler::getInstance().releaseFocus(this);
+    }
+
+    /**
+        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;
+    }
+
+    void Camera::setFocus(Ogre::Viewport* viewport)
+    {
+        this->bHasFocus_ = true;
+        viewport->setCamera(this->camera_);
+    }
+}
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.h	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.h	(revision 2027)
@@ -0,0 +1,74 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Benjamin Knecht
+ *
+ */
+
+#ifndef _Camera_H__
+#define _Camera_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "objects/worldentities/PositionableEntity.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Camera : public PositionableEntity, public Tickable
+    {
+        friend class CameraHandler;
+
+        public:
+            Camera(BaseObject* creator);
+            virtual ~Camera();
+
+            void setConfigValues();
+            virtual void tick(float dt);
+
+            void requestFocus();
+            void releaseFocus();
+
+            inline bool hasFocus()
+                { return this->bHasFocus_; }
+
+            inline void setDrag(bool bDrag)
+                { this->bDrag_ = bDrag; }
+            inline bool getDrag() const
+                { return this->bDrag_; }
+
+        private:
+            void removeFocus();
+            void setFocus(Ogre::Viewport* viewport);
+            void configvaluecallback_changedNearClipDistance();
+
+            Ogre::Camera*   camera_;
+            float           nearClipDistance_;
+            bool            bHasFocus_;
+            bool            bDrag_;
+    };
+}
+
+#endif /* _Camera_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2026)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2027)
@@ -36,5 +36,5 @@
 
 #include "objects/infos/PlayerInfo.h"
-#include "objects/Camera.h"
+#include "objects/worldentities/Camera.h"
 #include "overlays/OverlayGroup.h"
 
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.cc	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.cc	(revision 2027)
@@ -0,0 +1,106 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleSpawner.h"
+
+#include <OgreSceneManager.h>
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "tools/ParticleInterface.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(ParticleSpawner);
+
+    ParticleSpawner::ParticleSpawner()
+    {
+        RegisterObject(ParticleSpawner);
+        this->particle_ = 0;
+    }
+
+    ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction)
+    {
+        RegisterObject(ParticleSpawner);
+        this->setParticle(templateName, detaillevel, lifetime, startdelay, destroydelay, direction);
+    }
+
+    void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction)
+    {
+        ExecutorMember<ParticleSpawner>* executor = createExecutor(createFunctor(&ParticleSpawner::createParticleSpawner));
+        this->destroydelay_ = destroydelay;
+        executor->setDefaultValues(lifetime);
+        this->timer_.setTimer(startdelay, false, this, executor);
+        this->particle_ = new ParticleInterface(templateName, detaillevel);
+        this->particle_->addToSceneNode(this->getNode());
+        this->particle_->setEnabled(false);
+        if (direction != Vector3::ZERO)
+        {
+            this->particle_->getAllEmitters()->setDirection(direction);
+        }
+    }
+
+    ParticleSpawner::~ParticleSpawner()
+    {
+        if (this->isInitialized() && this->particle_)
+        {
+            this->particle_->detachFromSceneNode();
+            delete this->particle_;
+        }
+    };
+
+    void ParticleSpawner::destroy()
+    {
+        this->setPosition(this->getNode()->getParent()->getPosition());
+        this->getNode()->getParent()->removeChild(this->getNode());
+        this->detachFromParent();
+        if (this->particle_)
+            this->particle_->setEnabled(false);
+        if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_)
+            this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
+    }
+
+    void ParticleSpawner::createParticleSpawner(float lifetime)
+    {
+        this->particle_->setEnabled(true);
+        if (lifetime != 0)
+            this->timer_.setTimer(lifetime, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
+    }
+
+    void ParticleSpawner::destroyParticleSpawner()
+    {
+        delete this;
+    }
+
+    void ParticleSpawner::setVisible(bool visible)
+    {
+        if (this->particle_)
+            this->particle_->setEnabled(visible);
+    }
+}
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.h	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.h	(revision 2027)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleSpawner_H__
+#define _ParticleSpawner_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleSpawner : public WorldEntity
+    {
+        public:
+            ParticleSpawner();
+            ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO);
+            virtual ~ParticleSpawner();
+            void destroy();
+
+            void setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO);
+            inline ParticleInterface* getParticleInterface() const
+                { return this->particle_; }
+
+            void setVisible(bool visible);
+
+        private:
+            void createParticleSpawner(float lifetime);
+            void destroyParticleSpawner();
+
+            Timer<ParticleSpawner> timer_;
+            ParticleInterface* particle_;
+            float destroydelay_;
+    };
+}
+
+#endif /* _ParticleSpawner_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc	(revision 2027)
@@ -0,0 +1,125 @@
+/*
+ *   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 "OrxonoxStableHeaders.h"
+#include "DistanceTrigger.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox {
+
+  CreateFactory(DistanceTrigger);
+
+  DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)
+  {
+    RegisterObject(DistanceTrigger);
+
+    targetMask_.exclude(Class(BaseObject));
+  }
+
+  DistanceTrigger::~DistanceTrigger()
+  {
+  }
+
+  void DistanceTrigger::addTarget(Ogre::Node* targetNode)
+  {
+    this->targetSet_.insert(targetNode);
+  }
+
+  void DistanceTrigger::removeTarget(Ogre::Node* targetNode)
+  {
+    int returnval = this->targetSet_.erase(targetNode);
+    if (returnval == 0)
+    {
+      COUT(2) << "Warning: Node " << targetNode << " did not exist in targetSet of trigger " << this << " !" << std::endl;
+      COUT(4) << "Content of targetSet of trigger " << this << " :" << std::endl;
+      std::set<Ogre::Node*>::iterator it;
+      for(it = this->targetSet_.begin(); it != this->targetSet_.end(); it++)
+      {
+        COUT(4) << *it << std::endl;
+      }
+      COUT(4) << "End of targetSet of trigger " << this << std::endl;
+    }
+  }
+
+  void DistanceTrigger::addTargets(const std::string& targets)
+  {
+    Identifier* targetId = ClassByString(targets);
+    targetMask_.include(targetId);
+    // trigger shouldn't react on itself or other triggers
+    targetMask_.exclude(Class(Trigger), true);
+
+  }
+
+  void DistanceTrigger::removeTargets(const std::string& targets)
+  {
+    Identifier* targetId = ClassByString(targets);
+    targetMask_.exclude(targetId);
+  }
+
+  bool DistanceTrigger::checkDistance()
+  {
+    // Iterate through all WorldEntities
+    for(Iterator<WorldEntity> it = ObjectList<WorldEntity>::begin(); it; it++)
+    {
+      // check if WorldEntity is a target
+      if(targetMask_.isIncluded(it->getIdentifier()))
+      {
+        Vector3 distanceVec = it->getNode()->getWorldPosition() - this->getNode()->getWorldPosition();
+        if (distanceVec.length() < this->distance_)
+        {
+          return true;
+        }
+      }
+    }
+    return false;
+
+  }
+
+  void DistanceTrigger::setDistance(float dist)
+  {
+    this->distance_ = dist;
+  }
+
+  void DistanceTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+  {
+    Trigger::XMLPort(xmlelement, mode);
+
+    XMLPortParamLoadOnly(DistanceTrigger, "distance", setDistance, xmlelement, mode);
+    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode);
+  }
+
+  bool DistanceTrigger::isTriggered(TriggerMode mode)
+  {
+    if(Trigger::isTriggered(mode))
+      return checkDistance();
+    else
+      return false;
+  }
+}
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h	(revision 2027)
@@ -0,0 +1,67 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _DistanceTrigger_H__
+#define _DistanceTrigger_H__
+
+#include "Trigger.h"
+
+#include <set>
+
+#include <OgreNode.h>
+
+#include "core/ClassTreeMask.h"
+#include "core/BaseObject.h"
+
+namespace orxonox {
+
+  class _OrxonoxExport DistanceTrigger : public Trigger
+  {
+    public:
+      DistanceTrigger(BaseObject* creator);
+      ~DistanceTrigger();
+      void addTarget(Ogre::Node* targetNode);
+      void removeTarget(Ogre::Node* targetNode);
+      void addTargets(const std::string& targets);
+      void removeTargets(const std::string& targets);
+      void setDistance(float dist);
+      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+      bool checkDistance();
+
+    protected:
+      bool isTriggered(TriggerMode mode);
+
+    private:
+      ClassTreeMask targetMask_;
+      std::set<Ogre::Node*> targetSet_;
+      float distance_;
+  };
+
+}
+
+#endif /* _Trigger_H__ */
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.cc	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.cc	(revision 2027)
@@ -0,0 +1,298 @@
+/*
+ *   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 "OrxonoxStableHeaders.h"
+#include "Trigger.h"
+
+#include <OgreBillboard.h>
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/XMLPort.h"
+#include "objects/Scene.h"
+
+namespace orxonox
+{
+
+  SetConsoleCommand(Trigger, debugFlares, false).defaultValues(false);
+
+  CreateFactory(Trigger);
+
+  Trigger::Trigger(BaseObject* creator) : PositionableEntity(creator)
+  {
+    RegisterObject(Trigger);
+
+    mode_ = TM_EventTriggerAND;
+    bActive_ = false;
+    bInvertMode_ = false;
+    delay_ = 0.0;
+    bTriggered_ = false;
+    bUpdating_ = false;
+    remainingActivations_ = -1;
+    bStayOn_ = false;
+    latestState_ = 0x0;
+
+    if (this->getScene() && this->getScene()->getSceneManager())
+    {
+      debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
+      debugBillboard_.setVisible(false);
+    }
+
+    this->getNode()->attachObject(debugBillboard_.getBillboardSet());
+  }
+
+  Trigger::~Trigger()
+  {
+  }
+
+  void Trigger::init()
+  {
+    timeSinceLastEvent_ = delay_;
+  }
+
+  void Trigger::debugFlares(bool bVisible)
+  {
+    for (ObjectList<Trigger>::iterator it = ObjectList<Trigger>::begin(); it != ObjectList<Trigger>::end(); ++it)
+      it->setVisible(bVisible);
+  }
+
+  void Trigger::changedVisibility()
+  {
+    debugBillboard_.setVisible(this->isVisible());
+  }
+
+  const Trigger* Trigger::getTrigger(unsigned int index) const
+  {
+    if (children_.size() <= index)
+      return NULL;
+
+    std::set<Trigger*>::const_iterator it;
+    it = children_.begin();
+
+    for ( unsigned int i = 0; i != index; i++ )
+    {
+      it++;
+    }
+    return *it;
+  }
+
+  void Trigger::tick(float dt)
+  {
+
+    bool newTriggered;
+    newTriggered = this->isTriggered();
+
+    // check if new triggering event is really new
+    if((this->latestState_ & 0x1) != newTriggered)
+    {
+      // create new state
+      if(newTriggered)
+      {
+        latestState_ |= 1; // set trigger bit
+        this->switchState();
+      }
+      else
+      {
+        latestState_ &= 0xFE; // set trigger bit
+        if (this->bStayOn_)
+          this->storeState();
+        else
+          this->switchState();
+      }
+    }
+
+    if(remainingTime_ > 0.0)
+    {
+      remainingTime_ -= dt;
+      // only increase when acctually waiting for a state in the queue
+      if(timeSinceLastEvent_ >= 0.0)
+        timeSinceLastEvent_ += dt;
+    }
+
+    while(remainingTime_ <= 0.0 && stateChanges_.size() > 0)
+    {
+      // time ran out, change state to new one
+      char newState = stateChanges_.front().second;
+      bTriggered_ = (newState & 0x1);
+      bActive_ = newState & 2;
+      this->stateChanges_.pop();
+      if(stateChanges_.size() != 0)
+        remainingTime_ = stateChanges_.front().first;
+      else
+        timeSinceLastEvent_ = delay_;
+    }
+
+
+
+    if (bTriggered_ && bActive_)
+      this->setBillboardColour(ColourValue(0.5, 1.0, 0.0));
+    else if (!bTriggered_ && bActive_)
+      this->setBillboardColour(ColourValue(0.0, 1.0, 0.0));
+    else if (bTriggered_ && !bActive_)
+      this->setBillboardColour(ColourValue(1.0, 0.5, 0.0));
+    else
+      this->setBillboardColour(ColourValue(1.0, 0.0, 0.0));
+    bUpdating_ = false;
+  }
+
+  void Trigger::setBillboardColour(ColourValue colour)
+  {
+    this->debugBillboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+  }
+
+  void Trigger::storeState()
+  {
+    // put state change into queue
+    this->stateChanges_.push(std::pair<float,char>(timeSinceLastEvent_, latestState_));
+    // reset time since last event
+    timeSinceLastEvent_ = 0.0;
+
+    if(this->stateChanges_.size() == 1)
+      remainingTime_ = stateChanges_.front().first;
+  }
+
+  bool Trigger::isTriggered(TriggerMode mode)
+  {
+    if(bUpdating_)
+      return bTriggered_;
+
+    if( children_.size() != 0 )
+    {
+      bUpdating_ = true;
+      bool returnval = false;
+      switch(mode)
+      {
+        case TM_EventTriggerAND:
+          returnval = checkAnd();
+          break;
+        case TM_EventTriggerOR:
+          returnval = checkOr();
+          break;
+        case TM_EventTriggerXOR:
+          returnval = checkXor();
+          break;
+        default:
+          returnval = false;
+          break;
+      }
+      if(bInvertMode_)
+        return !returnval;
+      else
+        return returnval;
+    }
+    return true;
+  }
+
+  void Trigger::setDelay(float delay)
+  {
+    this->delay_ = delay;
+  }
+
+  void Trigger::setMode(const std::string& modeName)
+  {
+    if (modeName == "and")
+      setMode(TM_EventTriggerAND);
+    else if (modeName == "or")
+      setMode(TM_EventTriggerOR);
+    else if (modeName == "xor")
+      setMode(TM_EventTriggerXOR);
+  }
+
+  void Trigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+  {
+    WorldEntity::XMLPort(xmlelement, mode);
+
+    XMLPortParamLoadOnly(Trigger, "delay", setDelay, xmlelement, mode);
+    XMLPortParamLoadOnly(Trigger, "stayOn", setStayOn, xmlelement, mode);
+    XMLPortParamLoadOnly(Trigger, "activations", setActivations, xmlelement, mode);
+    XMLPortParamLoadOnly(Trigger, "invert", setInvert, xmlelement, mode);
+    XMLPortParamLoadOnlyTemplate(Trigger, "mode", setMode, xmlelement, mode, const std::string&);
+
+    XMLPortObject(Trigger, Trigger, "", addTrigger, getTrigger, xmlelement, mode);
+
+    this->init();
+  }
+
+  void Trigger::addTrigger(Trigger* trig)
+  {
+    if (this != trig)
+      this->children_.insert(trig);
+  }
+
+  bool Trigger::switchState()
+  {
+    if ( remainingActivations_ <= -1 || this->latestState_ & 2 || remainingActivations_ > 0)
+    {
+      this->latestState_ ^= 2; // toggle state bit
+      // increase activation count
+      if (this->latestState_ & 2) remainingActivations_--;
+      this->storeState();
+
+      return true;
+    }
+    return false;
+  }
+
+
+  bool Trigger::checkAnd()
+  {
+    std::set<Trigger*>::iterator it;
+    for(it = this->children_.begin(); it != this->children_.end(); it++)
+    {
+      if(!((*it)->isActive()))
+        return false;
+    }
+    return true;
+  }
+
+  bool Trigger::checkOr()
+  {
+    std::set<Trigger*>::iterator it;
+    for(it = this->children_.begin(); it != this->children_.end(); it++)
+    {
+      if((*it)->isActive())
+        return true;
+    }
+    return false;
+  }
+
+  bool Trigger::checkXor()
+  {
+    std::set<Trigger*>::iterator it;
+    bool test = false;
+    for(it = this->children_.begin(); it != this->children_.end(); it++)
+    {
+      if(test && (*it)->isActive())
+        return false;
+      if((*it)->isActive())
+        test = true;
+    }
+    return test;
+  }
+
+}
Index: code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.h	(revision 2027)
+++ code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.h	(revision 2027)
@@ -0,0 +1,113 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _Trigger_H__
+#define _Trigger_H__
+
+#include <set>
+#include <queue>
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/worldentities/PositionableEntity.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox {
+
+  enum TriggerMode
+  {
+    TM_EventTriggerAND,
+    TM_EventTriggerOR,
+    TM_EventTriggerXOR,
+  };
+
+  class _OrxonoxExport Trigger : public PositionableEntity
+  {
+    public:
+      Trigger(BaseObject* creator);
+      ~Trigger();
+
+      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+      virtual void tick(float dt);
+
+      inline bool isActive() const
+        { return bActive_; }
+
+      void addTrigger(Trigger* trig);
+      const Trigger* getTrigger(unsigned int index) const;
+
+      inline TriggerMode getMode() const
+        { return mode_; }
+      inline void setMode(TriggerMode mode)
+        { this->mode_ = mode; }
+      void setMode(const std::string& modeName);
+
+      inline void setInvert(int invert)
+        { bInvertMode_ = invert; }
+      inline void setStayOn(int stayOn)
+        { this->bStayOn_ = (stayOn == 1) ? true : false; }
+      inline void setActivations(int activations)
+        { this->remainingActivations_ = activations; }
+      void setDelay(float delay);
+      bool switchState();
+
+      static void debugFlares(bool bVisible);
+      virtual void changedVisibility();
+
+    private:
+      void init();
+      bool checkAnd();
+      bool checkOr();
+      bool checkXor();
+      void setBillboardColour(ColourValue colour);
+      void storeState();
+
+    protected:
+      inline bool isTriggered() { return this->isTriggered(this->mode_); }
+      virtual bool isTriggered(TriggerMode mode);
+
+    private:
+      std::set<Trigger*> children_;
+      std::queue<std::pair<float,char> > stateChanges_;
+      float remainingTime_;
+      float timeSinceLastEvent_;
+      TriggerMode mode_;
+      bool bActive_;
+      bool bInvertMode_;
+      bool bTriggered_;
+      bool bUpdating_;
+      BillboardSet debugBillboard_;
+      float delay_;
+      int remainingActivations_;
+      bool bStayOn_;
+      char latestState_;
+  };
+
+}
+
+#endif /* _Trigger_H__ */
