Index: code/branches/AI/src/AIClass.h
===================================================================
--- code/branches/AI/src/AIClass.h	(revision 426)
+++ code/branches/AI/src/AIClass.h	(revision 426)
@@ -0,0 +1,99 @@
+#ifndef Flocking_Class
+#define Flocking_Class
+
+#include <Ogre.h>
+#include <OgreVector3.h>
+#include <OgreMath.h>
+
+#include <iostream>
+
+
+#endif
+
+using namespace std;
+using namespace Ogre;
+
+class AIPilot {
+
+
+  /*
+  TASKS:                                                                         Requirements:
+
+    - Change actual Speed to required Speed                                          - Speed as Vector3 , spaceship(?) -> pilot attached to it or vice versa (?)
+    - Open fire, if allowed                                                          - Status of the fleet commander -> allowed to fire , fly etc.
+    - differ friend, ally and enemy                                                  - Lists of ships + who controls them
+    - report ship status to fleet commander                                          - Call own ship status -> ammo, damage etc.
+
+
+
+  */
+
+  public:
+    Vector3 speed;
+
+
+
+  //default constructor
+  AIPilot() {
+     speed = (1,0,0);
+  }
+
+  Vector3 steer(Vector3 reqSpeed) {
+    Quaternion sRotation = speed.getRotationTo(reqSpeed);
+    Radian rollarc = sRotation.getRoll();
+    Radian pitcharc = sRotation.getPitch();
+    Radian yawarc = sRotation.getYaw();
+    return Vector3((float)rollarc.valueRadians(), (float)pitcharc.valueRadians(), (float)yawarc.valueRadians());
+  }
+
+
+
+};
+
+class AIFleetCommander : public  AIPilot {
+
+
+  /*
+  TASKS:                                                                       Requirements:
+
+    - Same tasks as AI_Pilot (only if shipcontrol)                                   - Same as AI_Pilot
+    - Calculate required Speed for any ship in Fleet                                 - Knows all calculation functions
+    - Request fleet status and report to commander                                   - Better list of all ships -> more data for fleet ships
+
+
+
+  */
+
+  public:
+
+
+  //default constructor
+  AIFleetCommander() {
+
+  }
+
+
+
+};
+
+class AICommander : public  AIFleetCommander {
+
+
+  /*
+  TASKS:                                                                     Requirements:
+
+    - Decide on general tactics                                                      - List of general fleet status + all possible information on enemies
+    - Save and load tactical data (?)                                                - files with tactical data, e.g. success of strategy etc.
+
+
+
+  */
+
+  //default constructor
+  AICommander() {
+
+  }
+
+
+
+};
Index: code/branches/AI/src/Arrival.h
===================================================================
--- code/branches/AI/src/Arrival.h	(revision 426)
+++ code/branches/AI/src/Arrival.h	(revision 426)
@@ -0,0 +1,76 @@
+
+// Arrival Class
+
+
+#ifndef Flocking_Class
+#define Flocking_Class
+
+#include <Ogre.h>
+#include <OgreVector3.h>
+
+
+#include <iostream>
+
+
+#endif
+
+using namespace std;
+using namespace Ogre;
+
+class Arrival {
+
+  public:
+    Vector3 location;  // locationvector of the element
+    Vector3 speed;  // speedvector of the element
+    Vector3 acceleration;  // accelerationvector of the element
+    Vector3 target;  //target to arrive
+    int accelerationForwards;  //from steering-interface
+    int MaxSpeed;  //from steering-interface
+
+
+  Arrival() {
+    acceleration = (0,0,0);
+    speed = (0,0,0);
+    location = (0,0,0);
+    target = (0,0,0);
+  }
+
+  Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
+    acceleration = acceleration_;
+    speed = speed_;
+    location = location_;
+    target = target_;
+  }
+
+  void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
+    acceleration = acceleration_;
+    speed = speed_;
+    location = location_;
+    target = target_;
+  }
+
+  void setTarget(Vector3 target_) {
+    setValues(this.location, this.speed, this.acceleration, target_);
+  }
+
+  Vector3 getDirection() {
+    Vector3 direction = target-location;
+  }
+
+  double relativeDirectApproach() {
+    return (accelerationForwards / (2*getDirection().length / (MaxSpeed/accelerationForwards)^2) );
+  }
+
+  void Approach() {
+    Quaternion rotation = (0,0,0,0);
+    if (relativeDirectApproach() > 1) {
+      rotation = speed.getRotationTo(getDirection());
+      // do that turn
+      
+    }
+    else {
+
+    }
+
+  }
+}
Index: code/branches/AI/src/Flocking.h
===================================================================
--- code/branches/AI/src/Flocking.h	(revision 326)
+++ code/branches/AI/src/Flocking.h	(revision 426)
@@ -13,4 +13,5 @@
 #include <Ogre.h>
 #include <OgreVector3.h>
+
 
 #include <iostream>
@@ -29,4 +30,5 @@
     Vector3 speed;  // speedvector of the element
     Vector3 acceleration;  // accelerationvector of the element
+    bool movable;  // movability of the element
 
   Element() {
@@ -34,16 +36,19 @@
     speed = (0,0,0);
     location = (0,0,0);
+    movable = true;
   }
 
-  Element(Vector3 location_, Vector3 speed_, Vector3 acceleration_) {
+  Element(Vector3 location_, Vector3 speed_, Vector3 acceleration_, bool movable_) {
     acceleration = acceleration_;
     speed = speed_;
     location = location_;
+    movable = movable_;
   }
 
-  void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_) {
+  void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, bool movable_) {
     acceleration = acceleration_;
     speed = speed_;
     location = location_;
+    movable = movable_;
   }
 
@@ -54,12 +59,16 @@
   }
 
-//EINF[GEN DES ELEMENTS
+//EINFÜGEN DES ELEMENTS
   void update(Element arrayOfElements[], const FrameEvent& time) {
-    calculateAcceleration(arrayOfElements);  //updates the acceleration
-    calculateSpeed(time);  //updates the speed
-    calculateLocation(time);  //updates the location
+      if (this->movable == true) {calculateAcceleration(arrayOfElements);}
+
+ /*   if (this->movable ==  true) {
+      calculateAcceleration(arrayOfElements);  //updates the acceleration
+      calculateSpeed(time);  //updates the speed
+      calculateLocation(time);  //updates the location
+    }   */
   }
 
-//EINF[GEN DES ELEMENTS
+//EINFÜGEN DES ELEMENTS
   void calculateAcceleration(Element arrayOfElements[]) {
   //calculates the accelerationvector based on the steeringvectors of
@@ -79,15 +88,22 @@
   Vector3 separation(Element arrayOfElements[]) {
     Vector3* steering = new Vector3(0,0,0); //steeringvector
+    Vector3* inverseDistance = new Vector3(0,0,0);
     int numberOfNeighbour = 0;  //number of observed neighbours
+    float distance = 0;
     //go through all elements
-    for(int i=0; i<3; i++) {  //just working with 3 elements at the moment
+    for(int i=0; i<9; i++) {  //just working with 3 elements at the moment
       Element actual = arrayOfElements[i];  //get the actual element
-      float distance = getDistance(actual);  //get distance between this and actual
+      distance = getDistance(actual);  //get distance between this and actual
 //DUMMY SEPERATION DETECTION DISTANCE =100
-      if ((distance > 0) && (distance<100)) {  //do only if actual is inside detectionradius
-        Vector3 inverseDistance = actual.location-location;  //calculate the distancevector heading towards this
-        inverseDistance = inverseDistance.normalise(); //does this work correctly?  //normalise the distancevector
-        inverseDistance = inverseDistance/*/distance*/;  //devide distancevector by distance (the closer the bigger gets the distancevector -> steeringvector)
-        *steering = *steering + inverseDistance;  //add up all significant steeringvectors
+      if ((distance > 0) && (distance < 200)) {  //do only if actual is inside detectionradius
+        *inverseDistance = (0,0,0);
+        *inverseDistance = location-actual.location;  //calculate the distancevector heading towards this
+        //*inverseDistance = inverseDistance->normalise(); //does this work correctly?  //normalise the distancevector
+        if ((distance < 100) && (distance >= 80)) {*inverseDistance = *inverseDistance*2;}
+        if ((distance < 80) && (distance >= 60)) {*inverseDistance = *inverseDistance*5;}
+        if ((distance < 60) && (distance >= 40)) {*inverseDistance = *inverseDistance*10;}
+        if ((distance < 40) && (distance > 0)) {*inverseDistance = *inverseDistance*20;}
+      //  *inverseDistance = *inverseDistance/distance;  //devide distancevector by distance (the closer the bigger gets the distancevector -> steeringvector)
+        *steering = *steering + *inverseDistance;  //add up all significant steeringvectors
         numberOfNeighbour++;  //counts the elements inside the detectionradius
       }
@@ -96,4 +112,5 @@
     *steering = *steering / (float)numberOfNeighbour;  //devide the sum of steeringvectors by the number of elements -> separation steeringvector
     }
+    cout<<*steering<<endl;
     return *steering;
   }
@@ -102,10 +119,11 @@
     Vector3* steering = new Vector3(0,0,0); //steeringvector
     int numberOfNeighbour = 0;  //number of observed neighbours
+    float distance = 0;
     //go through all elements
-    for(int i=0; i<3; i++) {  //just working with 3 elements at the moment
+    for(int i=0; i<9; i++) {  //just working with 3 elements at the moment
       Element actual = arrayOfElements[i];  //get the actual element
       float distance = getDistance(actual);  //get distance between this and actual
 //DUMMY ALIGNMENT DETECTION DISTANCE = 1000
-      if ((distance > 0) && (distance<1000)) {  //check if actual element is inside detectionradius
+      if ((distance > 0) && (distance < 300)) {  //check if actual element is inside detectionradius
         *steering = *steering + actual.speed;  //add up all speedvectors inside the detectionradius
         numberOfNeighbour++;  //counts the elements inside the detectionradius
@@ -121,10 +139,11 @@
     Vector3* steering = new Vector3(0,0,0); //steeringvector
     int numberOfNeighbour = 0;  //number of observed neighbours
+    float distance = 0;
     //go through all elements
-    for(int i=0; i<3; i++) {  //just working with 3 elements at the moment
+    for(int i=0; i<9; i++) {  //just working with 3 elements at the moment
       Element actual = arrayOfElements[i];  //get the actual element
       float distance = getDistance(actual);  //get distance between this and actual
 // DUMMY COHESION DETECTION DISTANCE = 1000
-      if ((distance > 0) && (distance<1000)) {  //check if actual element is inside detectionradius
+      if ((distance > 0) && (distance < 5000)) {  //check if actual element is inside detectionradius
         *steering = *steering + actual.location;  //add up all locations of elements inside the detectionradius
         numberOfNeighbour++;  //counts the elements inside the detectionradius
@@ -133,8 +152,8 @@
     if(numberOfNeighbour > 0) {
     *steering = *steering  / (float)numberOfNeighbour;  //devide the sum steeringvector by the number of elements -> cohesion steeringvector
+    *steering = *steering - this->location;  // (?) Koordinatensystem?
     }
     return *steering;
   }
- 
 };
 
Index: code/branches/AI/src/orxonox.cc
===================================================================
--- code/branches/AI/src/orxonox.cc	(revision 326)
+++ code/branches/AI/src/orxonox.cc	(revision 426)
@@ -35,4 +35,5 @@
 #include <CEGUI/CEGUI.h>
 #include <OgreCEGUIRenderer.h>
+#include <OgreMath.h>
 
 #include <string>
@@ -42,4 +43,5 @@
 #include "loader/LevelLoader.h"
 #include "Flocking.h"
+#include "AIClass.h"
 
 // some tests to see if enet works without includsion
@@ -78,9 +80,11 @@
 //my-stuff
 //globale definition eines Arrays welches alle nodes enthält
-Vector3 ElementLocationArray[3];
-Vector3 ElementSpeedArray[3];
-Vector3 ElementAccelerationArray[3];
-
-Element arrayOfElements[3];
+Vector3 ElementLocationArray[9];
+Vector3 ElementSpeedArray[9];
+Vector3 ElementAccelerationArray[9];
+
+Element arrayOfElements[9];
+
+ // float time = 0;
 
 
@@ -105,13 +109,47 @@
       SceneManager *mgr = root_->getSceneManager("Default SceneManager");
 
-
-
       arrayOfElements[0].update(arrayOfElements, evt);
       arrayOfElements[1].update(arrayOfElements, evt);
       arrayOfElements[2].update(arrayOfElements, evt);
+      arrayOfElements[3].update(arrayOfElements, evt);
+      arrayOfElements[4].update(arrayOfElements, evt);
+      arrayOfElements[5].update(arrayOfElements, evt);
+      arrayOfElements[6].update(arrayOfElements, evt);
+      arrayOfElements[7].update(arrayOfElements, evt);
+      arrayOfElements[8].update(arrayOfElements, evt);
+
+ /*   arrayOfElements[0].update(arrayOfElements, evt);
+      arrayOfElements[1].update(arrayOfElements, evt);
+      arrayOfElements[2].update(arrayOfElements, evt);
+      arrayOfElements[3].update(arrayOfElements, evt);
+      arrayOfElements[4].update(arrayOfElements, evt);   */
+
+
+      for(int i=0; i<9; i++) {
+
+         arrayOfElements[i].speed = 0.995*arrayOfElements[i].speed + arrayOfElements[i].acceleration*evt.timeSinceLastFrame;
+
+         arrayOfElements[i].location = arrayOfElements[i].location + arrayOfElements[i].speed*evt.timeSinceLastFrame;
+
+         arrayOfElements[i].acceleration  = (0,0,0);
+      }
 
       mgr->getSceneNode("HeadNode1")->setPosition(arrayOfElements[0].location);
       mgr->getSceneNode("HeadNode2")->setPosition(arrayOfElements[1].location);
       mgr->getSceneNode("HeadNode3")->setPosition(arrayOfElements[2].location);
+      mgr->getSceneNode("HeadNode4")->setPosition(arrayOfElements[3].location);
+      mgr->getSceneNode("HeadNode5")->setPosition(arrayOfElements[4].location);
+      mgr->getSceneNode("HeadNode6")->setPosition(arrayOfElements[5].location);
+      mgr->getSceneNode("HeadNode7")->setPosition(arrayOfElements[6].location);
+      mgr->getSceneNode("HeadNode8")->setPosition(arrayOfElements[7].location);
+      mgr->getSceneNode("HeadNode9")->setPosition(arrayOfElements[8].location);
+
+
+      /*
+
+      mgr->getSceneNode("HeadNode9")->setPosition(Vector3(200*cos(10*time),0,0));
+      time = time + evt.timeSinceLastFrame;
+
+     */
 
 
@@ -292,22 +330,85 @@
     Entity* ent2 = mgr->createEntity("Head2", "ogrehead.mesh");
     Entity* ent3 = mgr->createEntity("Head3", "ogrehead.mesh");
-    SceneNode *node1 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode1", Vector3(0,100,0));
-    SceneNode *node2 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode2", Vector3(100,0,0));
-    SceneNode *node3 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode3", Vector3(-100,0,0));
+    Entity* ent4 = mgr->createEntity("Head4", "ogrehead.mesh");
+    Entity* ent5 = mgr->createEntity("Head5", "ogrehead.mesh");
+    Entity* ent6 = mgr->createEntity("Head6", "ogrehead.mesh");
+    Entity* ent7 = mgr->createEntity("Head7", "ogrehead.mesh");
+    Entity* ent8 = mgr->createEntity("Head8", "ogrehead.mesh");
+    Entity* ent9 = mgr->createEntity("Head9", "ogrehead.mesh");
+    SceneNode *node1 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode1", Vector3(100,300,100));
+    SceneNode *node2 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode2", Vector3(300,0,200));
+    SceneNode *node3 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode3", Vector3(-300,0,-100));
+    SceneNode *node4 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode4", Vector3(-100,-300,150));
+    SceneNode *node5 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode5", Vector3(150,150,-100));
+    SceneNode *node6 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode6", Vector3(150,-150,-100));
+    SceneNode *node7 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode7", Vector3(-150,-150,0));
+    SceneNode *node8 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode8", Vector3(-150,150,0));
+    SceneNode *node9 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode9", Vector3(0,0,0));  
+
+// follwing camera
+
+ //  Camera *cam = mgr->getCamera("Camera");
+ //  node1->attachObject(cam);
+
+
+
+
     node1->attachObject(ent1);
     node2->attachObject(ent2);
     node3->attachObject(ent3);
+    node4->attachObject(ent4);
+    node5->attachObject(ent5);
+    node6->attachObject(ent6);
+    node7->attachObject(ent7);
+    node8->attachObject(ent8);
+    node9->attachObject(ent9);
     ElementLocationArray[0] = node1->getPosition();
     ElementLocationArray[1] = node2->getPosition();
     ElementLocationArray[2] = node3->getPosition();
+    ElementLocationArray[3] = node4->getPosition();
+    ElementLocationArray[4] = node5->getPosition();
+    ElementLocationArray[5] = node6->getPosition();
+    ElementLocationArray[6] = node7->getPosition();
+    ElementLocationArray[7] = node8->getPosition();
+    ElementLocationArray[8] = node9->getPosition();
+/*
+ElementLocationArray[5] = node6->getPosition();
+ElementLocationArray[6] = node7->getPosition();*/
     ElementSpeedArray[0] = (0,0,0);
     ElementSpeedArray[1] = (0,0,0);
     ElementSpeedArray[2] = (0,0,0);
+    ElementSpeedArray[3] = (0,0,0);
+    ElementSpeedArray[4] = (0,0,0);
+    ElementSpeedArray[5] = (0,0,0);
+    ElementSpeedArray[6] = (0,0,0);
+    ElementSpeedArray[7] = (0,0,0);
+    ElementSpeedArray[8] = (0,0,0);
+/*
+ElementSpeedArray[5] = (0,0,0);
+ElementSpeedArray[6] = (0,0,0); */
     ElementAccelerationArray[0] = (0,0,0);
     ElementAccelerationArray[1] = (0,0,0);
     ElementAccelerationArray[2] = (0,0,0);
-    arrayOfElements[0].setValues( ElementLocationArray[0], ElementSpeedArray[0], ElementAccelerationArray[0] );
-    arrayOfElements[1].setValues( ElementLocationArray[1], ElementSpeedArray[1], ElementAccelerationArray[1] );
-    arrayOfElements[2].setValues( ElementLocationArray[2], ElementSpeedArray[2], ElementAccelerationArray[2] );
+    ElementAccelerationArray[3] = (0,0,0);
+    ElementAccelerationArray[4] = (0,0,0);
+    ElementAccelerationArray[5] = (0,0,0);
+    ElementAccelerationArray[6] = (0,0,0);
+    ElementAccelerationArray[7] = (0,0,0);
+    ElementAccelerationArray[8] = (0,0,0);
+/*
+ElementAccelerationArray[5] = (0,0,0);
+ElementAccelerationArray[6] = (0,0,0); */
+    arrayOfElements[0].setValues( ElementLocationArray[0], ElementSpeedArray[0], ElementAccelerationArray[0], true);
+    arrayOfElements[1].setValues( ElementLocationArray[1], ElementSpeedArray[1], ElementAccelerationArray[1], true);
+    arrayOfElements[2].setValues( ElementLocationArray[2], ElementSpeedArray[2], ElementAccelerationArray[2], true);
+    arrayOfElements[3].setValues( ElementLocationArray[3], ElementSpeedArray[3], ElementAccelerationArray[3], true);
+    arrayOfElements[4].setValues( ElementLocationArray[4], ElementSpeedArray[4], ElementAccelerationArray[4], true);
+    arrayOfElements[5].setValues( ElementLocationArray[5], ElementSpeedArray[5], ElementAccelerationArray[5], true);
+    arrayOfElements[6].setValues( ElementLocationArray[6], ElementSpeedArray[6], ElementAccelerationArray[6], true);
+    arrayOfElements[7].setValues( ElementLocationArray[7], ElementSpeedArray[7], ElementAccelerationArray[7], true);
+    arrayOfElements[8].setValues( ElementLocationArray[8], ElementSpeedArray[8], ElementAccelerationArray[8], false);
+/*
+arrayOfElements[5].setValues( ElementLocationArray[5], ElementSpeedArray[5], ElementAccelerationArray[5], false);
+arrayOfElements[6].setValues( ElementLocationArray[6], ElementSpeedArray[6], ElementAccelerationArray[6], false);*/
 
 
@@ -320,4 +421,10 @@
     arrayOfElements[i]->update(arrayOfElements);
     }  */
+
+//testing AIPilot -> function steer
+  //  AIPilot temp;
+  //  Vector3 foo = temp.steer(Vector3(0,0,1));
+
+
     }
 };
