Changeset 9470 for code/branches/Racingbot
- Timestamp:
- Nov 26, 2012, 4:36:01 PM (12 years ago)
- Location:
- code/branches/Racingbot/src/modules/gametypes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc
r9451 r9470 63 63 64 64 myPosition_= this->getPosition(); //eingefuegt 65 orxout(user_status) << "test" << std::endl;65 //orxout(user_status) << "test" << std::endl; 66 66 67 67 } -
code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc
r9459 r9470 45 45 CreateFactory(SpaceRaceController); 46 46 47 const int AdjustDistance = 500; 47 const int ADJUSTDISTANCE = 500; 48 const int MINDISTANCE=5; 48 49 /* 49 50 * Idea: Find static Point (checkpoints the spaceship has to reach) … … 93 94 * returns a vector of static Point (checkpoints the spaceship has to reach) 94 95 */ 95 std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints( 96 std::vector<RaceCheckPoint*> allCheckpoints) 96 std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(std::vector<RaceCheckPoint*> allCheckpoints) 97 97 { 98 98 std::map<RaceCheckPoint*, int> * zaehler = new std::map< … … 102 102 zaehler->insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0)); 103 103 } 104 int maxWays = rekSimulationCheckpointsReached(zaehler->begin()->first, &allCheckpoints,zaehler);104 int maxWays = rekSimulationCheckpointsReached(zaehler->begin()->first, zaehler); 105 105 106 106 std::vector<RaceCheckPoint*> returnVec; … … 122 122 * return how many ways go from the given Checkpoint to the last Checkpoint (of the Game) 123 123 */ 124 int SpaceRaceController::rekSimulationCheckpointsReached(RaceCheckPoint* currentCheckpoint, std:: vector<RaceCheckPoint*>* checkpoints, std::map<RaceCheckPoint*, int>* zaehler)124 int SpaceRaceController::rekSimulationCheckpointsReached(RaceCheckPoint* currentCheckpoint, std::map<RaceCheckPoint*, int>* zaehler) 125 125 { 126 126 if (currentCheckpoint->isLast()) … … 132 132 { 133 133 int numberOfWays = 0; // counts number of ways from this Point to the last point 134 for (std::set<int>::iterator it =lastPositionSpaceship=this->getControllableEntity()->getPosition(); 135 currentCheckpoint->getNextCheckpoints().begin(); it 136 != currentCheckpoint->getNextCheckpoints().end(); ++it) 137 { 138 numberOfWays += rekSimulationCheckpointsReached((*checkpoints)[(*it)], checkpoints, zaehler); 134 for (std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it) 135 { 136 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler); 139 137 } 140 138 (*zaehler)[currentCheckpoint] += numberOfWays; … … 296 294 lastPositionSpaceship=this->getControllableEntity()->getPosition(); 297 295 } 298 else if ((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length() > AdjustDistance)296 else if ((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt > ADJUSTDISTANCE) 299 297 { 300 298 nextRaceCheckpoint_ = adjustNextPoint(); 301 299 lastPositionSpaceship=this->getControllableEntity()->getPosition(); 302 300 } 303 //korrigieren! 304 else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length() <5){\301 //korrigieren! done 302 else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt< MINDISTANCE ){ 305 303 this->moveToPosition(Vector3(rnd()*100,rnd()*100,rnd()*100)); 306 304 this->spin(); 307 } 305 //orxout(user_status) << "Mindistance reached" << std::endl; 306 return; 307 } 308 //orxout(user_status) << "dt= " << dt << "; distance= " << (lastPositionSpaceship-this->getControllableEntity()->getPosition()).length() <<std::endl; 309 lastPositionSpaceship=this->getControllableEntity()->getPosition(); 308 310 this->moveToPosition(nextRaceCheckpoint_->getPosition()); 309 311 310 312 311 } 312 313 ObjectList<StaticEntity>::iterator it = ObjectList<StaticEntity>::begin(); 314 /*if ( it->isA(RaceCheckPoint)){ 315 orxout(user_status) << "works" << std::endl; 316 } 317 /* 318 for (ObjectList<StaticEntity>::iterator it = ObjectList<StaticEntity>::begin(); it!= ObjectList<StaticEntity>::end(); ++it) 319 { 320 if ((*it).isA(RaceCheckPoint)) 321 btVector3 temppos; 322 it-> 323 btScalar temppos; 324 btCollisionShape* temp= it->getCollisionShape(temppos, temppos); 325 it->get 326 327 } 328 */ 329 } 330 331 int SpaceRaceController::pointToPointDistance(Vector3 point1, Vector3 point2){ 332 for (ObjectList<StaticEntity>::iterator it = ObjectList<StaticEntity>::begin(); it!= ObjectList<StaticEntity>::end(); ++it) 333 { 334 if ((*it).isA(RaceCheckPoint)){break;} // does not work jet 335 336 for (int i=0; it->getAttachedCollisionShape(i)!=0; i++){ 337 btVector3 temppos; 338 btScalar tempradius; 339 it->getAttachedCollisionShape(i)->getCollisionShape()->getCollisionShape(temppos,tempradius); 340 //http://bulletphysics.com/Bullet/BulletFull/btCollisionShape_8cpp_source.html#l00032 341 //ueber shape moegliche Hindernisse bestimmen 342 } 343 it->getAttachedCollisionShape(i); 344 345 346 } 347 const int DeltaStrecke = 5; 348 for( int i=0; i*DeltaStrecke-5 < (point1-point2).length(); i++){ 349 return 0; 350 } 351 } 313 352 } -
code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h
r9459 r9470 52 52 std::vector<RaceCheckPoint*> findStaticCheckpoints(std::vector<RaceCheckPoint*>); 53 53 std::vector<RaceCheckPoint*> staticCheckpoints(); 54 int rekSimulationCheckpointsReached(RaceCheckPoint* , std:: vector<RaceCheckPoint*>* checkpoints, std::map< RaceCheckPoint*, int>*);54 int rekSimulationCheckpointsReached(RaceCheckPoint* , std::map< RaceCheckPoint*, int>*); 55 55 // same as SpaceRaceManager, but needed to add virtuell Checkpoints ( Checkpoints which don't exist but needed to avoid collisions with big Objects) 56 56 RaceCheckPoint* findCheckpoint(int index) const; 57 57 bool addVirtualCheckPoint(int , RaceCheckPoint* , int , Vector3 ); 58 int pointToPointDistance(Vector3, Vector3); 58 59 59 60 public:
Note: See TracChangeset
for help on using the changeset viewer.