Index: branches/adm/src/world_entities/npcs/adm_turret.cc
===================================================================
--- branches/adm/src/world_entities/npcs/adm_turret.cc	(revision 10676)
+++ branches/adm/src/world_entities/npcs/adm_turret.cc	(revision 10677)
@@ -22,4 +22,5 @@
 #include "loading/load_param.h"
 #include "debug.h"
+#include "loading/load_param_xml.h"
 
 ObjectListDefinition(AdmTurret);
@@ -54,29 +55,7 @@
 	}
 }
-
-void AdmTurret::init()
-{
-	this->registerObject(this, AdmTurret::_objectList);
-
-	// load the 3 parts of the turret
-	// this-> loadModel ("...", , )
-	// this-> loadModel ("...", , )
-	// this-> loadModel ("...", , )
-
-	//Cannon Node: 2 Cannons fixed left and right of the main turret
-	this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
-	this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
-	this->cannonNode.setParent(this);
-	// this->cannonNode.setRelCoor( , , )
-
-	//Sensor Node: Sensor rotating independently from main turret (like Radar)
-	this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
-	this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
-	this->sensorNode.setParent(this);
-	// this->sensorNode.setRelCoor( , , )
-
-	// initialise Weapons here
-}
-
+/**
+* XML Loader
+*/
 void AdmTurret::loadParams(const TiXmlElement* root)
 {
@@ -86,29 +65,18 @@
 
 		LoadParam(root, "target", this, AdmTurret, setTarget)
-			.describe("the filename of the World Entity, that is to be shot at")
+			.describe("The filename of the World Entity, that is to be shot at")
 			.defaultValues("");
-	}
-}
-
-void AdmTurret::tick(float dt)
-{
-}
-
-void AdmTurret::draw() const
-{
-}
-
-void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location)
-{
-}
-
-void AdmTurret::activate()
-{
-}
-
-void AdmTurret::deactivate()
-{
-}
-
+
+		LoadParamXML(root, "Cannons", this, AdmTurret, addCannons)
+  			.describe("add cannons to ADM");
+		LoadParamXML(root, "Sensor", this, AdmTurret, addSensor)
+  			.describe("add sensor to ADM");
+
+	}
+}
+
+/**
+* Sets Target onto the World Entity with filename "target", given as String
+*/
 void AdmTurret::setTarget(const std::string& target)
 {
@@ -120,6 +88,86 @@
 	else
 	{
-		PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str());
-	}
+		PRINTF(1)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str());
+	}
+}
+
+void AdmTurret::init()
+{
+	this->registerObject(this, AdmTurret::_objectList);
+
+	
+	// this-> loadModel ("models/guns/turret1.obj", ,1 )
+	
+
+	//Cannon Node: 2 Cannons fixed left and right of the main turret
+	
+	// this->sensor.setRelCoor( , , )
+
+	// initialise Weapons here
+}
+
+void AdmTurret::tick(float dt)
+{
+  WorldEntity::tick(dt);
+
+  //rotate sensor 2PI/sec
+  this->sensor->setAbsDir( this->sensor->getAbsDir() * Quaternion( PI*2*dt, Vector( 0, 1, 0 ) ) );
+
+
+  Vector playerPos = this->myTarget->getAbsCoor();
+  this->moveTowards( playerPos - ( this->cannons->getAbsCoor() ),  dt);
+}
+
+void AdmTurret::draw() const
+{
+  WorldEntity::draw();
+
+
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+
+  glPushAttrib(GL_ENABLE_BIT);
+
+  glDisable(GL_LIGHTING);
+  glDisable(GL_TEXTURE_2D);
+  glDisable(GL_BLEND);
+  glLineWidth(2.0);
+
+
+  Vector mp = this->cannons->getAbsCoor();
+  Vector op = this->cannons->getAbsDir().apply( Vector(-1, 0, 0) );
+  op *= 100;
+  op += mp;
+
+  glColor3f(1.0, 0.0, 0.0 );
+  glBegin(GL_LINE_STRIP);
+    glVertex3f(mp.x, mp.y, mp.z);
+    glVertex3f(op.x, op.y, op.z);
+  glEnd();
+
+  op = this->myTarget->getAbsCoor() - ( this->cannons->getAbsCoor() );
+  op += mp;
+
+  glColor3f(0.0, 1.0, 0.0 );
+  glBegin(GL_LINE_STRIP);
+    glVertex3f(mp.x, mp.y, mp.z);
+    glVertex3f(op.x, op.y, op.z);
+  glEnd();
+  
+  glPopAttrib();
+  glPopMatrix();
+  
+}
+
+void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location)
+{
+}
+
+void AdmTurret::activate()
+{
+}
+
+void AdmTurret::deactivate()
+{
 }
 
@@ -146,2 +194,73 @@
 	//pj->activate();
 }
+
+void AdmTurret::addCannons( const TiXmlElement * root )
+{
+	this->cannons = new WorldEntity();
+	this->cannons->setParent(this);
+	this->cannons->loadParams( root );
+
+	this->cannons->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+	this->cannons->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
+	
+	this->cannons->toList( getOMListNumber() );
+}
+
+void AdmTurret::addSensor( const TiXmlElement * root )
+{
+	this->sensor = new WorldEntity();
+	this->sensor->setParent(this);
+	this->sensor->loadParams( root );
+
+	this->sensor->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+	this->sensor->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
+	this->sensor->toList( getOMListNumber() );
+}
+
+void AdmTurret::moveTowards( Vector targetDir, float dt )
+{
+
+if(false){
+
+
+  Quaternion cur = this->getAbsDir();
+  
+  Quaternion ry( dt, cur.apply( Vector( 0, 1, 0 ) ) );
+  
+  Quaternion tmp1 = cur * ry;
+  Quaternion tmp2 = cur * ry.inverse();
+  
+  if ( tmp1.apply( Vector(1, 0, 0) ).dot(targetDir) < tmp2.apply( Vector(1, 0, 0)).dot(targetDir) )
+    cur = tmp1;
+  else
+    cur = tmp2;
+  
+  this->setAbsDir( cur );
+}
+
+{ 
+  //targetDir = this->getAbsDir().apply( targetDir );
+  Quaternion cur = this->cannons->getAbsDir();
+  //Quaternion rx( dt, Vector( 0, 0, 1 ) );
+  Quaternion rx( dt, Vector( 0, 0, 1 ) );
+  
+  Quaternion tmp1 = cur * rx;
+  Quaternion tmp2 = cur * rx.inverse();
+
+  Quaternion dec;
+  if ( tmp1.apply(  Vector(-1, 0, 0) ).dot(targetDir) < tmp2.apply( Vector(-1, 0, 0) ).dot(targetDir) )
+    dec = tmp1;
+  else
+    dec = tmp2;
+  
+  float dp = dec.apply( Vector(-1, 0, 0) ).dot(Vector(0, 1, 0));
+  if ( true /*dp > -0.9 && dp < 0.9*/ )
+  {
+    cur = dec;
+  }
+
+  this->cannons->setAbsDir( cur );
+}
+
+
+}
Index: branches/adm/src/world_entities/npcs/adm_turret.h
===================================================================
--- branches/adm/src/world_entities/npcs/adm_turret.h	(revision 10676)
+++ branches/adm/src/world_entities/npcs/adm_turret.h	(revision 10677)
@@ -33,10 +33,15 @@
                    
       private:
-                   PNode cannonNode;
-                   PNode sensorNode;
+                   WorldEntity* cannons;
+                   WorldEntity* sensor;
                    WorldEntity* myTarget;
                    bool isVisible(const WorldEntity myTarget);
                    float aim(const WorldEntity Target);
                    void fire();
+
+		   void addCannons(const TiXmlElement* root);
+		   void addSensor(const TiXmlElement* root);
+
+		   void moveTowards( Vector targetDir, float dt );
                                             
       };
