Index: code/branches/AI/src/Flocking.h
===================================================================
--- code/branches/AI/src/Flocking.h	(revision 233)
+++ code/branches/AI/src/Flocking.h	(revision 325)
@@ -1,3 +1,9 @@
+//
+//
+//      TODO: testing orxonox -flocking interface
+//            testing algorithm
 
+// ueberpruefen ob vektoren relativ richtig berechnet werden
+//
 //My Flocking Class
 
@@ -7,4 +13,6 @@
 #include <Ogre.h>
 #include <OgreVector3.h>
+
+#include <iostream>
 
 
@@ -22,6 +30,17 @@
     Vector3 acceleration;  // accelerationvector of the element
 
+  Element() {
+    acceleration = (0,0,0);
+    speed = (0,0,0);
+    location = (0,0,0);
+  }
 
   Element(Vector3 location_, Vector3 speed_, Vector3 acceleration_) {
+    acceleration = acceleration_;
+    speed = speed_;
+    location = location_;
+  }
+
+  void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_) {
     acceleration = acceleration_;
     speed = speed_;
@@ -36,86 +55,88 @@
 
 //EINF[GEN DES ELEMENTS
-  void update(Element* arrayOfElements) {
+  void update(Element arrayOfElements[], const FrameEvent& time) {
     calculateAcceleration(arrayOfElements);  //updates the acceleration
-    calculateSpeed();  //updates the speed
-    calculateLocation();  //updates the location
+    calculateSpeed(time);  //updates the speed
+    calculateLocation(time);  //updates the location
   }
 
 //EINF[GEN DES ELEMENTS
-  void calculateAcceleration(Element* arrayOfElements) {
+  void calculateAcceleration(Element arrayOfElements[]) {
   //calculates the accelerationvector based on the steeringvectors of
   //separtion, alignment and cohesion.
-  acceleration = acceleration + separation(arrayOfElements) + 2*alignment(arrayOfElements) + 2*cohesion(arrayOfElements);
+  acceleration = separation(arrayOfElements) + alignment(arrayOfElements) + cohesion(arrayOfElements);
   }
 
-  void calculateSpeed() {
-  speed = speed + acceleration;
-  //speed = speed.normalise();
+  void calculateSpeed(const FrameEvent& time) {
+    speed = speed + acceleration*time.timeSinceLastFrame;
   }
 
-  void calculateLocation() {
-  location = location + speed;
-  acceleration = (0,0,0);  //set acceleration to zero for the next calculation
+  void calculateLocation(const FrameEvent& time) {
+    location = location + speed*time.timeSinceLastFrame;
   }
 
-  Vector3 separation(Element* arrayOfElements) {
-    Vector3 steering; //steeringvector
-    int numberOfNeighbour;  //number of observed neighbours
+
+  Vector3 separation(Element arrayOfElements[]) {
+    Vector3* steering = new Vector3(0,0,0); //steeringvector
+    int numberOfNeighbour = 0;  //number of observed neighbours
     //go through all elements
-    for(int i=1; i<3; i++) {  //just working with 3 elements at the moment
+    for(int i=0; i<3; 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 SEPERATION DETECTION DISTANCE = 25
-      if ((distance > 0) && (distance<1)) {  //do only if actual is inside detectionradius
+//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
+        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
       }
     }
     if(numberOfNeighbour > 0) {
-    steering = steering / (float)numberOfNeighbour;  //devide the sum of steeringvectors by the number of elements -> separation steeringvector
+    *steering = *steering / (float)numberOfNeighbour;  //devide the sum of steeringvectors by the number of elements -> separation steeringvector
     }
-    return steering;
+    // cout << *steering << endl;
+    return *steering;
   }
 
-  Vector3 alignment(Element* arrayOfElements) {
-    Vector3 steering; //steeringvector
-    int numberOfNeighbour;  //number of observed neighbours
+  Vector3 alignment(Element arrayOfElements[]) {
+    Vector3* steering = new Vector3(0,0,0); //steeringvector
+    int numberOfNeighbour = 0;  //number of observed neighbours
     //go through all elements
-    for(int i=1; i<3; i++) {  //just working with 3 elements at the moment
+    for(int i=0; i<3; 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 = 50
+//DUMMY ALIGNMENT DETECTION DISTANCE = 1000
       if ((distance > 0) && (distance<1000)) {  //check if actual element is inside detectionradius
-        steering = steering + actual.speed;  //add up all speedvectors inside the detectionradius
+        *steering = *steering + actual.speed;  //add up all speedvectors inside the detectionradius
         numberOfNeighbour++;  //counts the elements inside the detectionradius
       }
     }
     if(numberOfNeighbour > 0) {
-    steering = steering / (float)numberOfNeighbour;  //devide the sum of steeringvectors by the number of elements -> alignment steeringvector
+    *steering = *steering / (float)numberOfNeighbour;  //devide the sum of steeringvectors by the number of elements -> alignment steeringvector
     }
-    return steering;
+    cout << *steering << endl;
+    return *steering;
   }
 
-  Vector3 cohesion(Element* arrayOfElements) {
-    Vector3 steering; //steeringvector
-    int numberOfNeighbour;  //number of observed neighbours
+  Vector3 cohesion(Element arrayOfElements[]) {
+    Vector3* steering = new Vector3(0,0,0); //steeringvector
+    int numberOfNeighbour = 0;  //number of observed neighbours
     //go through all elements
-    for(int i=1; i<3; i++) {  //just working with 3 elements at the moment
+    for(int i=0; i<3; 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 = 50
+// DUMMY COHESION DETECTION DISTANCE = 1000
       if ((distance > 0) && (distance<1000)) {  //check if actual element is inside detectionradius
-        steering = steering + actual.location;  //add up all locations of elements inside the detectionradius
+        *steering = *steering + actual.location;  //add up all locations of elements inside the detectionradius
         numberOfNeighbour++;  //counts the elements inside the detectionradius
       }
      }
     if(numberOfNeighbour > 0) {
-    steering = steering  / (float)numberOfNeighbour;  //devide the sum steeringvector by the number of elements -> cohesion steeringvector
+    *steering = *steering  / (float)numberOfNeighbour;  //devide the sum steeringvector by the number of elements -> cohesion steeringvector
     }
+    return *steering;
   }
-
+ 
 };
 
Index: code/branches/AI/src/orxonox.cc
===================================================================
--- code/branches/AI/src/orxonox.cc	(revision 233)
+++ code/branches/AI/src/orxonox.cc	(revision 325)
@@ -78,9 +78,9 @@
 //my-stuff
 //globale definition eines Arrays welches alle nodes enthält
-Vector3 ElementLocationArray[2];
-Vector3 ElementSpeedArray[2];
-Vector3 ElementAccelerationArray[2];
-
-Element* arrayOfElements[2];
+Vector3 ElementLocationArray[3];
+Vector3 ElementSpeedArray[3];
+Vector3 ElementAccelerationArray[3];
+
+Element arrayOfElements[3];
 
 
@@ -104,11 +104,18 @@
     void moving(const FrameEvent& evt) {
       SceneManager *mgr = root_->getSceneManager("Default SceneManager");
-      arrayOfElements[0]->update(*arrayOfElements);
-      mgr->getSceneNode("HeadNode1")->translate(0.000000001*evt.timeSinceLastFrame*arrayOfElements[0]->location);
-      arrayOfElements[1]->update(*arrayOfElements);
-      mgr->getSceneNode("HeadNode2")->translate(0.000000001*evt.timeSinceLastFrame*arrayOfElements[1]->location);
-      arrayOfElements[2]->update(*arrayOfElements);
-      mgr->getSceneNode("HeadNode3")->translate(0.000000001*evt.timeSinceLastFrame*arrayOfElements[2]->location);
-      //mgr->getSceneNode("HeadNode1")->yaw((Radian)10*evt.timeSinceLastFrame);
+
+
+
+      arrayOfElements[0].update(arrayOfElements, evt);
+      arrayOfElements[1].update(arrayOfElements, evt);
+      arrayOfElements[2].update(arrayOfElements, evt);
+
+      mgr->getSceneNode("HeadNode1")->setPosition(arrayOfElements[0].location);
+      mgr->getSceneNode("HeadNode2")->setPosition(arrayOfElements[1].location);
+      mgr->getSceneNode("HeadNode3")->setPosition(arrayOfElements[2].location);
+
+
+
+    //  mgr->getSceneNode("HeadNode1")->yaw((Radian)10*evt.timeSinceLastFrame);
     }
 
@@ -291,6 +298,4 @@
     node2->attachObject(ent2);
     node3->attachObject(ent3);
-    //Camera* cam  = mgr->getCamera("Camera");
-    //node1->attachObject(cam);
     ElementLocationArray[0] = node1->getPosition();
     ElementLocationArray[1] = node2->getPosition();
@@ -302,7 +307,7 @@
     ElementAccelerationArray[1] = (0,0,0);
     ElementAccelerationArray[2] = (0,0,0);
-    arrayOfElements[0] = new Element( ElementLocationArray[0], ElementSpeedArray[0], ElementAccelerationArray[0] );
-    arrayOfElements[1] = new Element( ElementLocationArray[1], ElementSpeedArray[1], ElementAccelerationArray[1] );
-    arrayOfElements[2] = new Element( ElementLocationArray[2], ElementSpeedArray[2], ElementAccelerationArray[2] );
+    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] );
 
 
