Index: branches/ai/src/ai/ai_module.h
===================================================================
--- branches/ai/src/ai/ai_module.h	(revision 10075)
+++ branches/ai/src/ai/ai_module.h	(revision 10112)
@@ -3,5 +3,9 @@
 #define _AI_MODULE_H
 
+
+class NPC2;
 class AITeamMember;
+class WorldEntity;
+
 
 class AIModule{
@@ -10,4 +14,5 @@
    virtual ~AIModule() {}
    virtual void process() {}
+   virtual void process(float dt) {}
    void setDifficulty(int newDifficulty);
    void setOwner(AITeamMember* newOwner);
@@ -15,4 +20,5 @@
    int difficulty;
    AITeamMember* owner;
+   NPC2* myNPC;
 };
 
Index: branches/ai/src/ai/movement_module.cc
===================================================================
--- branches/ai/src/ai/movement_module.cc	(revision 10075)
+++ branches/ai/src/ai/movement_module.cc	(revision 10112)
@@ -25,49 +25,136 @@
 
 #include "shell_command.h"
-SHELL_COMMAND(aiacc, MovementModule, setAccleration);
-
-
-//class AIEngine;
-
-MovementModule::MovementModule(){
-	//MovementModule::aa=100.0f;
-	//a=100.0f;
-	//std::cout << "MovementModule created...\n";
-}
-
-MovementModule::~MovementModule(){
-}
-
-
-void MovementModule::setAccleration(float newValue)
-{
-	std::cout << "Setting a to: "<< newValue << "\n";
-	//MovementModule::aa=newValue;
-}
-
-
-
-
-float MovementModule::getSize(WorldEntity* object)
-{
-	//does not work...
+SHELL_COMMAND(setDistanceToPlayer, MovementModule, setDistanceToPlayer);
+SHELL_COMMAND(setDistanceToNPC, MovementModule, setDistanceToNPC);
+SHELL_COMMAND(setMaxAccleartion, MovementModule, setMaxAccleartion);
+
+float MovementModule::distanceToPlayer=15;
+float MovementModule::distanceToNPC=2;
+float MovementModule::maxAccleration=200.0f;
+
+void MovementModule::setDistanceToPlayer(float newValue){ distanceToPlayer=newValue; }
+void MovementModule::setDistanceToNPC(float newValue){ distanceToNPC=newValue; }
+void MovementModule::setMaxAccleartion(float newValue){ maxAccleration=newValue; }
+
+
+
+
+
+
+std::vector<Vector>	MovementModule::hidingPoint;
+std::vector<float>	MovementModule::hidingPointSize;
+
+std::vector<NPC2*> MovementModule::npcList;
+std::vector<Vector> MovementModule::npcPosition;
+std::vector<float> MovementModule::npcRadius;
+std::vector<int> MovementModule::npcSwarm;
+std::vector<int> MovementModule::npcTeam;
+
+Vector MovementModule::playerPosition;
+Vector MovementModule::playerMovement;
+float MovementModule::playerRadius;
+
+std::vector<Vector> MovementModule::swarmCenter;
+std::vector<int> MovementModule::swarmMemberCount;
+
+
+
+
+
+MovementModule::MovementModule(NPC2* object){ this->myNPC=object; }
+MovementModule::~MovementModule(){}
+
+
+
+
+float MovementModule::getRadius(WorldEntity* object)
+{
 	AABB* aabb = object->getModelAABB();
-	Vector a = aabb->getAxisX();
-	Vector b = aabb->getAxisY();
-	Vector c = aabb->getAxisZ();
-
-	float da=a.len();
-	float db=b.len();
-	float dc=c.len();
-	float size;
-
-	if(da>db){
-		size=(dc>da)?dc:da;
+	if( aabb == NULL)return -1;
+	
+	float a = aabb->halfLength[0];
+	float b = aabb->halfLength[1];
+	float c = aabb->halfLength[2];
+
+	if(a>b){
+		return (c>a)?c:a;
 	}else{
-		size=(dc>db)?dc:db;
-	}
-
-	return size;
-}
+		return (c>b)?c:b;
+	}
+}
+
+
+
+
+void MovementModule::collectInformation(float dt)
+{
+	//return if already processed..
+	if(dt==this->oldDT)return;
+	this->oldDT=dt;
+	
+	
+	//clear old Information..
+	hidingPoint.clear();
+	hidingPointSize.clear();
+
+	npcList.clear();
+	npcPosition.clear();
+	npcRadius.clear();
+	npcSwarm.clear();
+	npcTeam.clear();
+	
+	swarmCenter.clear();
+	swarmMemberCount.clear();
+	
+	
+	//get all NPCs..
+	for(ObjectList<NPC2>::const_iterator it = NPC2::objectList().begin(); it != NPC2::objectList().end(); ++it)
+	{
+		npcList.push_back(*it);
+		npcRadius.push_back(getRadius(*it));
+		npcPosition.push_back((*it)->getAbsCoor());
+		npcSwarm.push_back((*it)->swarm);
+		npcTeam.push_back((*it)->team);
+	}
+	
+	
+	//Swarm Information
+	unsigned int tmpSwarm;
+	for(unsigned int i=0;i<npcList.size();i++){
+		tmpSwarm = npcSwarm.at(i);
+		if(tmpSwarm > swarmMemberCount.size()){
+			//swarmMemberCount.insert(swarmMemberCount.size(), tmpSwarm - swarmMemberCount.size(), 0);
+			//swarmCenter.insert(swarmCenter.size(), tmpSwarm - swarmCenter.size(), Vector(0,0,0));
+		}
+		//swarmMemberCount.at(tmpSwarm)++;
+		//swarmCenter.at(tmpSwarm)=swarmCenter.at(tmpSwarm)+npcPosition.at(i);
+	}
+	for(unsigned int i=0;i<swarmCenter.size();i++){
+		//swarmCenter.at(i)=swarmCenter.at(i)/swarmMemberCount.at(i);
+	}
+	
+	
+	//get information about Player
+	Player* pl = State::getPlayer();
+	if( pl != NULL){
+		playerPosition = pl->getPlayable()->getAbsCoor();
+		playerRadius=getRadius( pl->getPlayable() );
+		//PRINTF(0)("Player Radius: %f\n",playerRadius);
+	}
+	
+	
+	//calculate hiding Points..
+	
+}
+
+
+
+
+
+
+
+
+
+
 
 
@@ -76,85 +163,89 @@
 void MovementModule::process()
 {
-	float dt=AIEngine::getInstance()->dtS;
-	if( owner == NULL) return;
-	Vector myAbsPos = owner->getAbsCoor();
-
-	//PRINTF(0)(" NPC abs coor: %f, %f, %f\n", myAbsPos.x, myAbsPos.y, myAbsPos.z);
-
-	Player* pl = State::getPlayer();
-	if( pl == NULL) return;
-	Vector playerAbsPos = pl->getPlayable()->getAbsCoor();
-
-	//PRINTF(0)(" Player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z);
-
-	////////////
-
-	//if(aa<0)aa=100.0f;
-	float a=200.0f;
+	this->process(AIEngine::getInstance()->dtS);
+}
+
+
+void MovementModule::process(float dt)
+{
+	collectInformation(dt);
+	
+	if(myNPC == NULL)return;
+	
+	Vector myPosition = myNPC->getAbsCoor();
+	float myRadius = getRadius(myNPC);
+	int mySwarm = myNPC->swarm;
+	int myTeam = myNPC->team;
+	
+	Vector vectorToPlayer = playerPosition - myPosition;
+	
+	Vector tmpVector;
+	float tmpFloat;
+	
+	Vector npcCollision;
+	Vector swarmVector;
+	Vector playerCollision;
+	
+
+
+	//float a=200.0f;
 	float vMax=200.0f;
-	
-	//float keepDist= this->getSize(owner);//+ this->getSize(pl->getPlayable());
-	//std::cout << "Distance: " << keepDist << "\n";
-
-
-	Vector vectorToPlayer = playerAbsPos - myAbsPos;
-	float dist=vectorToPlayer.len();
-	//Vector nVectorToPlayer=vectorToPlayer/dist*(dist-keepDist);
-
-
-	// std::vector<Vector> collisonCorrection;
-	// get all npcs
-
-	Vector tmpNPCpos;
-	float tmpDist;
-	Vector tmpCorrectionVect;
-	Vector antiNPCCollision;
-
-	for (ObjectList<NPC2>::const_iterator it = NPC2::objectList().begin();
-			 it != NPC2::objectList().end();
-			 ++it)
+	//float safetyDistance=2.0f;
+
+
+	//Anti Player Collision
+	tmpFloat=vectorToPlayer.len()-playerRadius-myRadius-distanceToPlayer;
+	if(tmpFloat<0.1)tmpFloat=0.1;
+	playerCollision=vectorToPlayer/(tmpFloat*tmpFloat)*(-1);
+	
+	
+	
+	for (unsigned int i=0;i<npcList.size();i++)
 	{
-		if(*it==owner)continue;
-		tmpNPCpos=(*it)->getAbsCoor();
-		tmpCorrectionVect = myAbsPos-tmpNPCpos;
-		
-		tmpDist=tmpCorrectionVect.len()-16;
-		if(tmpDist<0.1)tmpDist=0.1;
-		tmpCorrectionVect=tmpCorrectionVect/(tmpDist*tmpDist);
-		
-		antiNPCCollision=antiNPCCollision+tmpCorrectionVect;
-	}
-
-
-
-	Vector antiPlayerCollision=vectorToPlayer*(-1);
-	tmpDist=antiPlayerCollision.len()-45;
-	if(tmpDist<0.1)tmpDist=0.1;
-	antiPlayerCollision=antiPlayerCollision/(tmpDist*tmpDist);
-	
-	Vector correction=antiPlayerCollision*50+antiNPCCollision*50+vectorToPlayer-v;
-	//Vector nCorrection=
+		if(npcList.at(i)==myNPC)continue;
+		
+		//Anti NPC Collision
+		tmpVector=myPosition-npcPosition.at(i);
+		tmpFloat=tmpVector.len()-myRadius-npcRadius.at(i)-distanceToNPC;
+		
+		if(tmpFloat<0.1)tmpFloat=0.1;
+		tmpVector=tmpVector/(tmpFloat*tmpFloat);
+		
+		npcCollision=npcCollision+tmpVector;
+		
+		//Schwarmverhalten
+		if(npcSwarm.at(i) == mySwarm){
+		
+		
+		}
+	}
+
+
+
+	
+	
+	Vector correction=playerCollision*50+npcCollision*50+vectorToPlayer-myMovement;
 	correction.y=0;
 	float correctionLen=correction.len();
-	if(correctionLen>a*dt)correction=correction/correctionLen*a*dt;
-	v+=correction;
-
-	float vLen=v.len();
-	if(vLen>vMax)v/vLen*vMax;
+	if(correctionLen>maxAccleration*dt)correction=correction/correctionLen*maxAccleration*dt;
+	myMovement+=correction;
+
+	float movementLen=myMovement.len();
+	if(movementLen>vMax)myMovement/movementLen*vMax;
 
 	//Move NPC...
-	owner->shiftCoor(v*dt);
+	myNPC->shiftCoor(myMovement * dt);
 
 	//Rotate NPC
-	Vector view = v+correction;
+	Vector view = myMovement;
 	//if(vectorToPlayer.dot(v)<0){
 	//	view = v.cross( Vector(0,1,0) ).getNormalized();
 	//}else{
-		view = v.cross( Vector(0,-1,0) ).getNormalized();
+	view = myMovement.cross( Vector(0,-1,0) ).getNormalized();
 	//}
 	//if(dist<keepDist)view=view*-1;
-	//owner->setAbsDir( Quaternion( view, Vector(0,1,0)));
-	owner->setAbsDirSoft( Quaternion( view, Vector(0,1,0)),1.1);
-}
-
-
+	//myNPC->setAbsDir( Quaternion( view, Vector(0,1,0)));
+	myNPC->setAbsDirSoft( Quaternion( view, Vector(0,1,0)),3);
+}
+
+
Index: branches/ai/src/ai/movement_module.h
===================================================================
--- branches/ai/src/ai/movement_module.h	(revision 10075)
+++ branches/ai/src/ai/movement_module.h	(revision 10112)
@@ -6,16 +6,53 @@
 #include "player.h"
 #include "playable.h"
+//#include "npcs/npc_test.h"
+class NPC2;
+
 
 class MovementModule : public AIModule{
 	
  public:
-   MovementModule();
+   MovementModule() {}
+   MovementModule(NPC2* object);
    virtual ~MovementModule();
    virtual void process();
-   static void setAccleration(float newValue);
+   virtual void process(float dt);
+
+   static void setDistanceToPlayer(float newValue);
+   static void setDistanceToNPC(float newValue);
+   static void setMaxAccleartion(float newValue);
+   
  private:
-	 Vector v;
-	 float getSize(WorldEntity* object);
-	 static float aa;
+	void collectInformation(float dt);
+	
+	
+	static std::vector<Vector>	hidingPoint;
+	static std::vector<float>	hidingPointSize;
+	
+	static std::vector<NPC2*> npcList;
+	static std::vector<Vector> npcPosition;
+	static std::vector<float> npcRadius;
+	static std::vector<int> npcSwarm;
+	static std::vector<int> npcTeam;
+	
+	static Vector playerPosition;
+	static Vector playerMovement;
+	static float playerRadius;
+	
+	static std::vector<Vector> swarmCenter;
+	static std::vector<int> swarmMemberCount;
+	
+	Vector myMovement;
+	float myMaxAccleration;
+	float myMaxSpeed;
+	
+	
+	float getRadius(WorldEntity* object);
+	static float aa;
+	float oldDT;
+	
+	static float maxAccleration;
+	static float distanceToPlayer;
+	static float distanceToNPC;
 };
 
Index: branches/ai/src/world_entities/npcs/npc_test.cc
===================================================================
--- branches/ai/src/world_entities/npcs/npc_test.cc	(revision 10075)
+++ branches/ai/src/world_entities/npcs/npc_test.cc	(revision 10112)
@@ -32,4 +32,7 @@
 
 #include "class_id_DEPRECATED.h"
+#include "movement_module.h"
+#include "ai_module.h"
+
 
 ObjectListDefinitionID(NPC2, CL_NPC_TEST2);
@@ -39,9 +42,8 @@
 NPC2::NPC2(const TiXmlElement* root) : NPC(NULL)
 {
-  this->registerObject(this, NPC2::_objectList);
-
-  if (root != NULL)this->loadParams(root);
-
-  addToTeam(0);
+	this->registerObject(this, NPC2::_objectList);
+	if (root != NULL)this->loadParams(root);
+	
+	this->aiModule=new MovementModule(this); 
 }
 
@@ -60,7 +62,11 @@
 void NPC2::tick(float dt)
 {
-  // animating the md2 model
+	// animating the md2 model
 	if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID()))
-    ((MD2Model*)this->getModel(0))->tick(dt);
+		((MD2Model*)this->getModel(0))->tick(dt);
+
+	// processing AI
+	//PRINTF(0)("Processing NPC\n");
+	if(this->aiModule!=NULL)this->aiModule->process(dt);
 }
 
Index: branches/ai/src/world_entities/npcs/npc_test.h
===================================================================
--- branches/ai/src/world_entities/npcs/npc_test.h	(revision 10075)
+++ branches/ai/src/world_entities/npcs/npc_test.h	(revision 10112)
@@ -4,7 +4,9 @@
 
 #include "npc.h"
+#include "ai_module.h"
 
 class AI;
 class Shader;
+class AIModule;
 
 class NPC2 : public NPC {
@@ -17,6 +19,8 @@
   virtual void tick(float dt);
 
- private:
-
+ 	int team;
+ 	int swarm;
+	int difficulty;
+	AIModule* aiModule;
 };
 
