Index: code/branches/main_reto/src/orxonox_ship.cc
===================================================================
--- code/branches/main_reto/src/orxonox_ship.cc	(revision 171)
+++ code/branches/main_reto/src/orxonox_ship.cc	(revision 190)
@@ -33,11 +33,14 @@
 
 #include "bullet.h"
+#include "bullet_manager.h"
+#include "inertial_node.h"
+#include "weapon_manager.h"
 
 #include "orxonox_ship.h"
-#include "weapon_manager.h"
 
 
 namespace orxonox {
   using namespace Ogre;
+  using namespace weapon;
 
   /**
@@ -62,9 +65,11 @@
   * @param mNode The scene node which the ship will be attached to later.
   */
-  OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node)
-	      : sceneMgr_(sceneMgr), rootNode_(node), currentSpeed_(Vector3(0, 0, 0)),
+  OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node,
+        BulletManager *bulletManager)
+	      : sceneMgr_(sceneMgr), //currentSpeed_(Vector3(0, 0, 0)),
         baseThrust_(1000), currentThrust_(Vector3::ZERO),
-        objectCounter_(0), bulletSpeed_(400)
-  {
+        objectCounter_(0), bulletManager_(bulletManager)//, bulletSpeed_(400)
+  {
+    rootNode_ = new InertialNode(node, Vector3::ZERO);
   }
 
@@ -76,4 +81,8 @@
   OrxonoxShip::~OrxonoxShip()
   {
+    if (mainWeapon_)
+      delete mainWeapon_;
+    if (rootNode_)
+      delete rootNode_;
   }
 
@@ -95,12 +104,14 @@
 	  // TODO: names must be unique! use static variables..
 	  shipEntity_ = sceneMgr_->createEntity("Ship", "fish.mesh");
-	  SceneNode *fishNode = rootNode_->createChildSceneNode("fishNode");
-	  fishNode->yaw(Degree(-90));
-	  fishNode->attachObject(shipEntity_);
-	  fishNode->setScale(Vector3(10, 10, 10));
+	  InertialNode *fishNode = rootNode_->createChildNode();
+    fishNode->getSceneNode()->yaw(Degree(-90));
+	  fishNode->getSceneNode()->attachObject(shipEntity_);
+	  fishNode->getSceneNode()->setScale(Vector3(10, 10, 10));
 
     // initialise weapon(s)
-    SceneNode *mainWeaponNode = rootNode_->createChildSceneNode("mainWeaponNode");
-    mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode, 1);
+    InertialNode *mainWeaponNode = rootNode_->createChildNode();
+    mainWeapon_ = new WeaponManager(sceneMgr_, mainWeaponNode,
+          bulletManager_, 1);
+    mainWeapon_->addWeapon("Barrel Gun");
 
 	  return true;
@@ -110,10 +121,9 @@
   /**
   * Gets the ship to accelerate in the current direction.
-  * The value should be between 0 and 1, with one beeing full thrust and 0 none.
+  * The value should be between 0 and 1, with one beeing full thrust and 0 none
   * @param value Acceleration between 0 and 1
   */
   void OrxonoxShip::setMainThrust(const Real value)
   {
-	  //currentThrust_ = value * baseThrust_;
     currentThrust_.z = value * baseThrust_;
   }
@@ -122,10 +132,9 @@
   /**
   * Gets the ship to accelerate sideways regarding the current direction.
-  * The value should be between 0 and 1, with one beeing full thrust and 0 none.
+  * The value should be between 0 and 1, with one beeing full thrust and 0 none
   * @param value Acceleration between 0 and 1
   */
   void OrxonoxShip::setSideThrust(const Real value)
   {
-	  //currentSideThrust_ = value * baseThrust_;
     currentThrust_.x = value * baseThrust_;
   }
@@ -134,10 +143,9 @@
   /**
   * Gets the ship to accelerate up and down.
-  * The value should be between 0 and 1, with one beeing full thrust and 0 none.
+  * The value should be between 0 and 1, with one beeing full thrust and 0 none
   * @param value Acceleration between 0 and 1
   */
   void OrxonoxShip::setYThrust(const Real value)
   {
-    //currentYThrust_ = value * baseThrust_;
     currentThrust_.y = value * baseThrust_;
   }
@@ -150,5 +158,5 @@
   void OrxonoxShip::turnUpAndDown(const Radian &angle)
   {
-    rootNode_->pitch(-angle, Node::TS_LOCAL);
+    rootNode_->getSceneNode()->pitch(-angle, Node::TS_LOCAL);
   }
 
@@ -160,5 +168,5 @@
   void OrxonoxShip::turnLeftAndRight(const Radian &angle)
   {
-    rootNode_->yaw(-angle, Node::TS_PARENT);
+    rootNode_->getSceneNode()->yaw(-angle, Node::TS_PARENT);
   }
 
@@ -170,5 +178,5 @@
   Vector3 OrxonoxShip::getSpeed()
   {
-    return currentSpeed_;
+    return rootNode_->getSpeed();
   }
 
@@ -177,5 +185,5 @@
   * @return The Root Node.
   */
-  SceneNode* OrxonoxShip::getRootNode()
+  InertialNode* OrxonoxShip::getRootNode()
   {
     return rootNode_;
@@ -189,17 +197,7 @@
   * @return Bullet containing speed and entity.
   */
-  Bullet* OrxonoxShip::fire()
-  {
-	  // TODO: Names must be unique!
-	  SceneNode *temp = rootNode_->getParentSceneNode()->createChildSceneNode(
-          "BulletNode" + StringConverter::toString(objectCounter_));
-	  temp->setOrientation(rootNode_->getOrientation());
-	  temp->setPosition(rootNode_->getPosition());
-	  temp->setScale(Vector3(1, 1, 1) * 10);
-	  temp->yaw(Degree(-90));
-	  return new Bullet(temp, sceneMgr_->createEntity("bullet"
-          + StringConverter::toString(objectCounter_++), "Barrel.mesh"), currentSpeed_
-          + (rootNode_->getOrientation() * Vector3(0, 0, -1)).normalisedCopy()
-          * bulletSpeed_);
+  void OrxonoxShip::fire()
+  {
+    mainWeapon_->primaryFireRequest();
   }
 
@@ -214,11 +212,11 @@
   bool OrxonoxShip::tick(unsigned long time, Real deltaTime)
   {
-    Quaternion quad = rootNode_->getOrientation();
+    mainWeapon_->tick(time, deltaTime);
+
+    Quaternion quad = rootNode_->getSceneNode()->getOrientation();
     quad.normalise();
-    currentSpeed_ += quad * (Vector3(-1, -1, -1) * currentThrust_) * deltaTime;
-    //currentSpeed_ += quad * Vector3(0, 0, -1) * currentThrust_ * deltaTime;
-	  //currentSpeed_ += quad * Vector3(-1, 0,  0) * currentSideThrust_ * deltaTime;
-
-	  rootNode_->translate(currentSpeed_ * deltaTime);
+    rootNode_->addSpeed(quad * (Vector3(-1, -1, -1) * currentThrust_) * deltaTime);
+
+    rootNode_->getSceneNode()->translate(rootNode_->getSpeed() * deltaTime);
 
 	  return true;
