Index: code/trunk/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1602)
+++ code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1608)
@@ -35,19 +35,25 @@
 #include <OgreSceneNode.h>
 
-#include "CameraHandler.h"
 #include "util/Convert.h"
 #include "util/Math.h"
+
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/Debug.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+
+#include "network/Client.h"
+
+#include "hud/HUD.h"
+#include "tools/ParticleInterface.h"
+
 #include "GraphicsEngine.h"
-#include "core/input/InputManager.h"
-#include "tools/ParticleInterface.h"
 #include "RotatingProjectile.h"
 #include "ParticleProjectile.h"
-#include "core/XMLPort.h"
-#include "core/ConsoleCommand.h"
-#include "network/Client.h"
-#include "hud/HUD.h"
+#include "ParticleSpawner.h"
+#include "Backlight.h"
+#include "CameraHandler.h"
 
 namespace orxonox
@@ -101,4 +107,8 @@
         this->tt1_ = 0;
         this->tt2_ = 0;
+        this->smoke_ = 0;
+        this->fire_ = 0;
+
+        this->backlight_ = 0;
 
         this->redNode_ = 0;
@@ -143,5 +153,13 @@
                 delete this->tt2_;
 
-            if (setMouseEventCallback_)
+            if (this->smoke_)
+                this->smoke_->destroy();
+            if (this->fire_)
+                this->fire_->destroy();
+
+            if (this->backlight_)
+                delete this->backlight_;
+
+            if (this->setMouseEventCallback_)
                 InputManager::removeMouseHandler("SpaceShip");
 
@@ -184,5 +202,5 @@
     void SpaceShip::init()
     {
-        // START CREATING THRUSTER
+        // START CREATING THRUSTERS
         this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
         this->tt1_->createNewEmitter();
@@ -216,5 +234,5 @@
         node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
         node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
-        // END CREATING THRUSTER
+        // END CREATING THRUSTERS
 
         // START CREATING BLINKING LIGHTS
@@ -234,8 +252,18 @@
         // END CREATING BLINKING LIGHTS
 
-        this->smoke_.setParticle("Orxonox/smoke5", LODParticle::normal);
-        this->fire_.setParticle("Orxonox/fire3", LODParticle::normal);
+        // START CREATING ADDITIONAL EFFECTS
+        this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
+        this->attachObject(this->backlight_);
+        this->backlight_->setPosition(-2.35, 0, 0.2);
+        this->backlight_->setColour(this->getProjectileColour());
+
+        this->smoke_ = new ParticleSpawner();
+        this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
         this->attachObject(this->smoke_);
+
+        this->fire_ = new ParticleSpawner();
+        this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
         this->attachObject(this->fire_);
+        // END CREATING ADDITIONAL EFFECTS
 
         if (this->isExactlyA(Class(SpaceShip)))
@@ -255,8 +283,8 @@
             this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
             this->chFarNode_->setScale(0.4, 0.4, 0.4);
+            // END of testing crosshair
         }
 
         createCamera();
-        // END of testing crosshair
     }
 
@@ -280,6 +308,7 @@
         this->rightThrusterFlare_.setVisible(this->isVisible());
         this->leftThrusterFlare_.setVisible(this->isVisible());
-        this->smoke_.setVisible(this->isVisible());
-        this->fire_.setVisible(this->isVisible());
+        this->smoke_->setVisible(this->isVisible());
+        this->fire_->setVisible(this->isVisible());
+        this->backlight_->setVisible(this->isVisible());
     }
 
@@ -336,5 +365,4 @@
         CameraHandler::getInstance()->requestFocus(cam_);
       }
-
     }
 
@@ -378,16 +406,8 @@
     }
 
-    int sgn(float x)
-    {
-        if (x >= 0)
-            return 1;
-        else
-            return -1;
-    }
-
     std::string SpaceShip::whereAmI() {
-	return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
-	+ "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y)
-	+ "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z);
+        return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
+        + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y)
+        + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z);
     }
 
@@ -403,6 +423,16 @@
             this->cam_->tick(dt);
 
-        this->smoke_.setVisible(this->isVisible() && this->health_ < 40);
-        this->fire_.setVisible(this->isVisible() && this->health_ < 20);
+        if (this->smoke_)
+            this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
+        if (this->fire_)
+            this->fire_->setVisible(this->isVisible() && this->health_ < 20);
+
+        if (this->backlight_)
+        {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
+            if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
+                this->backlight_->setActive(false);
+            else
+                this->backlight_->setActive(true);
+        }
 
         if (this->redNode_ && this->greenNode_)
@@ -521,16 +551,11 @@
         }
 
-        if( myShip_ )
-        {
-          COUT(5) << "steering our ship: " << objectID << std::endl;
-          this->acceleration_.x = 0;
-          this->acceleration_.y = 0;
-          this->momentum_ = 0;
-          this->mouseXRotation_ = Radian(0);
-          this->mouseYRotation_ = Radian(0);
-        }/*else
-          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
-
-          this->bLMousePressed_ = false;
+        COUT(5) << "steering our ship: " << objectID << std::endl;
+        this->acceleration_.x = 0;
+        this->acceleration_.y = 0;
+        this->momentum_ = 0;
+        this->mouseXRotation_ = Radian(0);
+        this->mouseYRotation_ = Radian(0);
+        this->bLMousePressed_ = false;
     }
 
