Changeset 10075 in orxonox.OLD for branches/ai
- Timestamp:
- Dec 13, 2006, 11:01:36 PM (18 years ago)
- Location:
- branches/ai/src/ai
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/ai/movement_module.cc
r10071 r10075 25 25 26 26 #include "shell_command.h" 27 /*SHELL_COMMAND(model, WorldEntity, loadModel) 28 ->describe("sets the Model of the WorldEntity") 29 ->defaultValues("models/ships/fighter.obj", 1.0f);*/ 27 SHELL_COMMAND(aiacc, MovementModule, setAccleration); 30 28 31 29 … … 33 31 34 32 MovementModule::MovementModule(){ 33 //MovementModule::aa=100.0f; 34 //a=100.0f; 35 35 //std::cout << "MovementModule created...\n"; 36 36 } … … 40 40 41 41 42 void MovementModule::setAccleration(float newValue) 43 { 44 std::cout << "Setting a to: "<< newValue << "\n"; 45 //MovementModule::aa=newValue; 46 } 47 48 49 50 42 51 float MovementModule::getSize(WorldEntity* object) 43 52 { 53 //does not work... 44 54 AABB* aabb = object->getModelAABB(); 45 55 Vector a = aabb->getAxisX(); … … 80 90 //////////// 81 91 82 float a=50.0f; 83 float keepDist= this->getSize(owner);//+ this->getSize(pl->getPlayable()); 84 std::cout << "Distance: " << keepDist << "\n"; 92 //if(aa<0)aa=100.0f; 93 float a=200.0f; 94 float vMax=200.0f; 95 96 //float keepDist= this->getSize(owner);//+ this->getSize(pl->getPlayable()); 97 //std::cout << "Distance: " << keepDist << "\n"; 85 98 86 99 87 100 Vector vectorToPlayer = playerAbsPos - myAbsPos; 88 101 float dist=vectorToPlayer.len(); 89 Vector nVectorToPlayer=vectorToPlayer/dist*(dist-keepDist); 90 91 92 102 //Vector nVectorToPlayer=vectorToPlayer/dist*(dist-keepDist); 93 103 94 104 … … 96 106 // get all npcs 97 107 98 Vector tempNPCpos; 99 Vector tempCorrectionVect; 100 Vector antiCollision; 108 Vector tmpNPCpos; 109 float tmpDist; 110 Vector tmpCorrectionVect; 111 Vector antiNPCCollision; 101 112 102 113 for (ObjectList<NPC2>::const_iterator it = NPC2::objectList().begin(); … … 105 116 { 106 117 if(*it==owner)continue; 107 tempNPCpos=(*it)->getAbsCoor(); 108 tempCorrectionVect = myAbsPos-tempNPCpos; 109 tempCorrectionVect=tempCorrectionVect*1/(tempCorrectionVect.len()); 110 //PRINTF(0)("class: %s\n", (*it)->getCName()); 111 antiCollision=antiCollision+tempCorrectionVect; 118 tmpNPCpos=(*it)->getAbsCoor(); 119 tmpCorrectionVect = myAbsPos-tmpNPCpos; 120 121 tmpDist=tmpCorrectionVect.len()-16; 122 if(tmpDist<0.1)tmpDist=0.1; 123 tmpCorrectionVect=tmpCorrectionVect/(tmpDist*tmpDist); 124 125 antiNPCCollision=antiNPCCollision+tmpCorrectionVect; 112 126 } 113 127 114 128 115 129 116 Vector correction=antiCollision+nVectorToPlayer-v; 130 Vector antiPlayerCollision=vectorToPlayer*(-1); 131 tmpDist=antiPlayerCollision.len()-45; 132 if(tmpDist<0.1)tmpDist=0.1; 133 antiPlayerCollision=antiPlayerCollision/(tmpDist*tmpDist); 134 135 Vector correction=antiPlayerCollision*50+antiNPCCollision*50+vectorToPlayer-v; 117 136 //Vector nCorrection= 118 137 correction.y=0; … … 121 140 v+=correction; 122 141 142 float vLen=v.len(); 143 if(vLen>vMax)v/vLen*vMax; 123 144 124 145 //Move NPC... … … 127 148 //Rotate NPC 128 149 Vector view = v+correction; 129 //if(vectorToPlayer.dot(v iew)<0){130 //view = v.cross( Vector(0,1,0) ).getNormalized();150 //if(vectorToPlayer.dot(v)<0){ 151 // view = v.cross( Vector(0,1,0) ).getNormalized(); 131 152 //}else{ 132 153 view = v.cross( Vector(0,-1,0) ).getNormalized(); 133 154 //} 134 155 //if(dist<keepDist)view=view*-1; 135 owner->setAbsDir( Quaternion( view, Vector(0,1,0)));136 //owner->setAbsDirSoft( Quaternion( view, Vector(0,1,0)),1.5);156 //owner->setAbsDir( Quaternion( view, Vector(0,1,0))); 157 owner->setAbsDirSoft( Quaternion( view, Vector(0,1,0)),1.1); 137 158 } 138 159 -
branches/ai/src/ai/movement_module.h
r10071 r10075 8 8 9 9 class MovementModule : public AIModule{ 10 10 11 public: 11 12 MovementModule(); 12 13 virtual ~MovementModule(); 13 14 virtual void process(); 15 static void setAccleration(float newValue); 14 16 private: 15 17 Vector v; 16 18 float getSize(WorldEntity* object); 19 static float aa; 17 20 }; 18 21
Note: See TracChangeset
for help on using the changeset viewer.