Changeset 9512 for code/branches
- Timestamp:
- Dec 14, 2012, 4:17:08 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
r9508 r9512 64 64 myPosition_= this->getPosition(); //eingefuegt 65 65 //orxout(user_status) << "test" << std::endl; 66 67 68 66 } 69 67 … … 109 107 //Must not be called before setNextCheckpointsAsVector3 at least once has been called 110 108 void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){ 111 std::set<int> lastcheckpoints=this->nextCheckpoints_;109 /*std::set<int> lastcheckpoints=this->nextCheckpoints_; 112 110 nextCheckpoints_.clear(); 113 111 std::set<int>::iterator it = lastcheckpoints.begin(); … … 116 114 it++; 117 115 } 118 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly 116 if(checkpoints.x!=-1) 117 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly 119 118 120 119 if(checkpoints.y<-1){ … … 122 121 it++; 123 122 } 124 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5)); 123 if(checkpoints.y!=-1) 124 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5)); 125 125 126 126 if(checkpoints.z<-1){ … … 128 128 it++; 129 129 } 130 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5)); 130 if(checkpoints.z!=-1) 131 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));*/ 132 nextCheckpointsVirtual_.clear(); 133 if(checkpoints.x!=-1) 134 nextCheckpointsVirtual_.insert(checkpoints.x); 135 if(checkpoints.y!=-1) 136 nextCheckpointsVirtual_.insert(checkpoints.y); 137 if(checkpoints.z!=-1) 138 nextCheckpointsVirtual_.insert(checkpoints.z); 131 139 } 132 140 … … 141 149 if (checkpoints.z > -1) 142 150 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5)); 151 152 this->nextCheckpointsVirtual_=nextCheckpoints_; 143 153 } 144 154 … … 175 185 Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() 176 186 { 177 Vector3 checkpoints = getVirtualNextCheckpointsAsVector3(); 187 Vector3 checkpoints(-1,-1,-1); int count=0; 188 for (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ ){ 189 switch (count) 190 { 191 case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break; 192 case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break; 193 case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break; 194 } 195 ++count; 196 } 197 return checkpoints; 198 //= getVirtualNextCheckpointsAsVector3(); 178 199 int j[3]; 179 200 j[0]=changeVirtualToRealCheckPoint(checkpoints.x); … … 201 222 202 223 size_t count = 0; 203 for (std::set<int>::iterator it = this->nextCheckpoints _.begin(); it != this->nextCheckpoints_.end(); ++it)224 for (std::set<int>::iterator it = this->nextCheckpointsVirtual_.begin(); it != this->nextCheckpointsVirtual_.end(); ++it) 204 225 { 205 226 switch (count) -
code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h
r9508 r9512 67 67 const std::set<int>& getVirtualNextCheckpoints() const 68 68 { 69 return this->nextCheckpoints _;69 return this->nextCheckpointsVirtual_; 70 70 } 71 std::set<int> getNextCheckpoints() 71 72 const std::set<int>& getNextCheckpoints() 72 73 { 74 return nextCheckpoints_; 73 75 std::set<int> temp; 74 76 std::set<int> temp2=getVirtualNextCheckpoints(); … … 119 121 std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint 120 122 Vector3 myPosition_; 123 std::set<int> nextCheckpointsVirtual_; 121 124 std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed 122 125 }; -
code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc
r9508 r9512 54 54 ArtificialController(creator) 55 55 { 56 RegisterObject(SpaceRaceController) ;57 std::vector<RaceCheckPoint*> checkpoints;56 RegisterObject(SpaceRaceController) 57 ; std::vector<RaceCheckPoint*> checkpoints; 58 58 59 59 virtualCheckPointIndex=-2; … … 66 66 OrxAssert(!checkpoints.empty(), "No Checkpoints in Level"); 67 67 checkpoints_=checkpoints; 68 orxout()<<"es gibt: "<<checkpoints_.size()<<"checkpoints"<<endl; 69 for(std::vector<RaceCheckPoint*>::iterator it=checkpoints_.begin(); it!=checkpoints_.end(); it++) 70 { 71 orxout()<<"Checkpoint "<<(*it)->getCheckpointIndex()<<"; NExtReal: "; 72 std::set<int> temp =(*it)->getNextCheckpoints(); 73 for (std::set<int>::iterator ii =temp.begin(); ii!=temp.end(); ii++) 74 { 75 orxout()<<(*ii)<<", "; 76 } 77 78 orxout()<<" NextVirtual: "; 79 temp=(*it)->getVirtualNextCheckpoints(); 80 for (std::set<int>::iterator ii =temp.begin(); ii!=temp.end(); ii++) 81 { 82 orxout()<<(*ii)<<", "; 83 } 84 orxout()<<endl<<endl; 85 86 }//ausgabe 68 87 69 88 for( std::vector<RaceCheckPoint*>::iterator it = checkpoints.begin(); it!=checkpoints.end(); ++it) 70 89 { 71 90 std::set<int> nextCheckPoints = ((*it)->getNextCheckpoints()); 72 if(!nextCheckPoints.empty()) { 73 for (std::set<int>::iterator numb = nextCheckPoints.begin(); numb!=nextCheckPoints.end(); numb++) { 91 if(!nextCheckPoints.empty()) 92 { 93 for (std::set<int>::iterator numb = nextCheckPoints.begin(); numb!=nextCheckPoints.end(); numb++) 94 { 74 95 RaceCheckPoint* point2 = findCheckpoint((*numb)); 75 96 76 97 if(point2 != NULL) 77 98 placeVirtualCheckpoints((*it), point2); 78 99 } 79 100 } 80 101 } 102 for(std::vector<RaceCheckPoint*>::iterator it=checkpoints_.begin(); it!=checkpoints_.end(); it++) 103 { 104 orxout()<<"Checkpoint "<<(*it)->getCheckpointIndex()<<"; NExtReal: "; 105 std::set<int> temp =(*it)->getNextCheckpoints(); 106 for (std::set<int>::iterator ii =temp.begin(); ii!=temp.end(); ii++) 107 { 108 orxout()<<(*ii)<<", "; 109 } 110 111 orxout()<<" NextVirtual: "; 112 temp=(*it)->getVirtualNextCheckpoints(); 113 for (std::set<int>::iterator ii =temp.begin(); ii!=temp.end(); ii++) 114 { 115 orxout()<<(*ii)<<", "; 116 } 117 orxout()<<endl; 118 119 }//ausgabe 120 orxout()<<"es gibt: "<<checkpoints_.size()<<"checkpoints"<<endl; 81 121 staticRacePoints_ = findStaticCheckpoints(checkpoints); 82 122 // initialisation of currentRaceCheckpoint_ … … 84 124 85 125 int i; 86 for (i=-2; findCheckpoint(i)!= NULL; i--){ 126 for (i=-2; findCheckpoint(i)!= NULL; i--) 127 { 87 128 continue; 88 129 } … … 147 188 for (std::set<int>::iterator it = currentCheckpoint->getVirtualNextCheckpoints().begin(); it!= currentCheckpoint->getVirtualNextCheckpoints().end(); ++it) 148 189 { 149 if(currentCheckpoint==findCheckpoint(*it)){ 190 if(currentCheckpoint==findCheckpoint(*it)) 191 { 150 192 orxout() << currentCheckpoint->getCheckpointIndex()<<endl; 151 193 continue; 152 194 } 153 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler); 195 if(findCheckpoint(*it)==NULL){orxout()<<"Problematic Point: "<<(*it)<<endl;} 196 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler); 154 197 } 155 198 (*zaehler)[currentCheckpoint] += numberOfWays; … … 266 309 { 267 310 RaceCheckPoint* newTempRaceCheckPoint; 268 for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it){ 311 for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it) 312 { 269 313 newTempRaceCheckPoint = new RaceCheckPoint((*it)); 270 314 } … … 276 320 277 321 Vector3 temp = previousCheckpoint->getVirtualNextCheckpointsAsVector3(); 322 orxout()<<"temp bei 0: ="<< temp.x<< temp.y<< temp.z<<endl; 278 323 checkpoints_.insert(checkpoints_.end(), newTempRaceCheckPoint); 279 324 int positionInNextCheckPoint; … … 281 326 { 282 327 if(previousCheckpoint->getVirtualNextCheckpointsAsVector3()[i] == indexFollowingCheckPoint) 283 328 positionInNextCheckPoint=i; 284 329 } 285 330 switch(positionInNextCheckPoint) … … 291 336 previousCheckpoint->setNextVirtualCheckpointsAsVector3(temp); //Existiert internes Problem bei negativen index fueer next Checkpoint 292 337 virtualCheckPointIndex--; 338 orxout()<<"temp bei 1: ="<< temp.x<< temp.y<< temp.z<<endl; 339 orxout()<<"temp nach ausgabe: "<<previousCheckpoint->getVirtualNextCheckpointsAsVector3().x<<previousCheckpoint->getVirtualNextCheckpointsAsVector3().y<<previousCheckpoint->getVirtualNextCheckpointsAsVector3().z<<endl; 293 340 //OrxAssert(virtualCheckPointIndex < -1, "TO much virtual cp"); 294 341 /*orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<", following:"<<indexFollowingCheckPoint<<" : "<<temp.x<<", "<<temp.y<<", "<<temp.z<<"; "; 295 temp=previousCheckpoint->getNextCheckpointsAsVector3();296 orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<": "<<temp.x<<", "<<temp.y<<", "<<temp.z<<"; ";297 orxout()<<endl;*/342 temp=previousCheckpoint->getNextCheckpointsAsVector3(); 343 orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<": "<<temp.x<<", "<<temp.y<<", "<<temp.z<<"; "; 344 orxout()<<endl;*/ 298 345 return newTempRaceCheckPoint; 299 346 } … … 339 386 340 387 // Abmessung fuer MINDISTANCE gut; 388 341 389 else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt< MINDISTANCE ) 342 390 { … … 363 411 } 364 412 365 bool SpaceRaceController::directLinePossible(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2,std::vector<StaticEntity*> allObjects){ 413 bool SpaceRaceController::directLinePossible(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2,std::vector<StaticEntity*> allObjects) 414 { 366 415 367 416 Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector … … 370 419 btScalar radiusObject; 371 420 372 for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it!=allObjects.end(); ++it){ 373 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++){ 421 for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it!=allObjects.end(); ++it) 422 { 423 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++) 424 { 374 425 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape(); 375 426 if(currentShape == NULL) 376 427 continue; 377 428 378 429 currentShape->getBoundingSphere(positionObject,radiusObject); 379 430 Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 380 if((powf((cP1ToCP2.dotProduct(centerCP1-positionObjectNonBT)),2)-(centerCP1-positionObjectNonBT).dotProduct(centerCP1-positionObjectNonBT)+powf(radiusObject, 2))>0){ 431 if((powf((cP1ToCP2.dotProduct(centerCP1-positionObjectNonBT)),2)-(centerCP1-positionObjectNonBT).dotProduct(centerCP1-positionObjectNonBT)+powf(radiusObject, 2))>0) 432 { 381 433 return false; 382 434 } … … 388 440 } 389 441 390 void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2,std::vector<StaticEntity*> allObjects){ 391 Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector 392 Vector3 centerCP1=racepoint1->getPosition(); 393 btVector3 positionObject; 394 btScalar radiusObject; 395 396 for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it!=allObjects.end(); ++it){ 397 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++){ 398 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape(); 399 if(currentShape == NULL) 400 continue; 401 402 currentShape->getBoundingSphere(positionObject,radiusObject); 403 Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 404 if((powf((cP1ToCP2.dotProduct(centerCP1-positionObjectNonBT)),2)-(centerCP1-positionObjectNonBT).dotProduct(centerCP1-positionObjectNonBT)+powf(radiusObject, 2))>0){ 405 Vector3 zufall; 406 Vector3 objectmiddle=positionObjectNonBT; 407 do{ 408 zufall=Vector3(rnd(),rnd(),rnd());//random 409 }while((zufall.crossProduct(objectmiddle-racepoint1->getPosition())).length()==0); 410 411 412 Vector3 normalvec=zufall.crossProduct(objectmiddle-racepoint1->getPosition()); 413 // a'/b'=a/b => a' =b'*a/b 414 float laengeNormalvec=(objectmiddle-racepoint1->getPosition()).length()/sqrt((objectmiddle-racepoint1->getPosition()).squaredLength()-radiusObject*radiusObject)*radiusObject; 415 RaceCheckPoint* newVirtualCheckpoint=addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), objectmiddle+normalvec/normalvec.length()*laengeNormalvec); 416 //placeVirtualCheckpoints(newVirtualCheckpoint, racepoint2); 417 return; 418 } 419 420 } 442 void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2,std::vector<StaticEntity*> allObjects) 443 { 444 Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector 445 Vector3 centerCP1=racepoint1->getPosition(); 446 btVector3 positionObject; 447 btScalar radiusObject; 448 449 for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it!=allObjects.end(); ++it) 450 { 451 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++) 452 { 453 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape(); 454 if(currentShape == NULL) 455 continue; 456 457 currentShape->getBoundingSphere(positionObject,radiusObject); 458 Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 459 if((powf((cP1ToCP2.dotProduct(centerCP1-positionObjectNonBT)),2)-(centerCP1-positionObjectNonBT).dotProduct(centerCP1-positionObjectNonBT)+powf(radiusObject, 2))>0) 460 { 461 Vector3 zufall; 462 Vector3 objectmiddle=positionObjectNonBT; 463 do 464 { 465 zufall=Vector3(rnd(),rnd(),rnd());//random 466 }while((zufall.crossProduct(objectmiddle-racepoint1->getPosition())).length()==0); 467 468 Vector3 normalvec=zufall.crossProduct(objectmiddle-racepoint1->getPosition()); 469 // a'/b'=a/b => a' =b'*a/b 470 float laengeNormalvec=(objectmiddle-racepoint1->getPosition()).length()/sqrt((objectmiddle-racepoint1->getPosition()).squaredLength()-radiusObject*radiusObject)*radiusObject; 471 RaceCheckPoint* newVirtualCheckpoint=addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), objectmiddle+normalvec/normalvec.length()*laengeNormalvec); 472 //placeVirtualCheckpoints(newVirtualCheckpoint, racepoint2); 473 return; 421 474 } 422 475 423 } 424 425 476 } 477 } 478 479 } 426 480 427 481 void SpaceRaceController::placeVirtualCheckpoints(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2) … … 441 495 } 442 496 443 if(!directLinePossible(racepoint1, racepoint2, problematicObjects)) { 497 if(!directLinePossible(racepoint1, racepoint2, problematicObjects)) 498 { 499 orxout()<<"From "<<racepoint1->getCheckpointIndex()<<" to "<<racepoint2->getCheckpointIndex()<<"produces: "<< virtualCheckPointIndex<<endl; 444 500 computeVirtualCheckpoint(racepoint1, racepoint2, problematicObjects); 445 501 } 446 502 447 448 // 449 // do{ 450 // zufall=Vector3(rnd(),rnd(),rnd());//random 451 // }while((zufall.crossProduct(objectmiddle-racepoint1->getPosition())).length()==0); 452 // 453 // Vector3 normalvec=zufall.crossProduct(objectmiddle-racepoint1->getPosition()); 454 // // a'/b'=a/b => a' =b'*a/b 455 // float laengeNormalvec=(objectmiddle-racepoint1->getPosition()).length()/sqrt((objectmiddle-racepoint1->getPosition()).squaredLength()-radius*radius)*radius; 456 // addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), objectmiddle+normalvec/normalvec.length()*laengeNormalvec); 457 458 // Vector3 richtungen [6]; 459 // richtungen[0]= Vector3(1,0,0); 460 // richtungen[1]= Vector3(-1,0,0); 461 // richtungen[2]= Vector3(0,1,0); 462 // richtungen[3]= Vector3(0,-1,0); 463 // richtungen[4]= Vector3(0,0,1); 464 // richtungen[5]= Vector3(0,0,-1); 465 // 466 // for (int i = 0; i< 6; i++) 467 // { 468 // const int STEPS=100; 469 // const float PHI=1.1; 470 // bool collision=false; 471 // 472 // for (int j =0; j<STEPS; j++) 473 // { 474 // Vector3 tempPosition=(point1 - (point2-point1+richtungen[i]*PHI)*(float)j/STEPS); 475 // for (std::vector<StaticEntity*>::iterator it = problematicObjects.begin(); it!=problematicObjects.end(); ++it) 476 // { 477 // btVector3 positionObject; 478 // btScalar radiusObject; 479 // if((*it)==NULL) 480 // { orxout()<<"Problempoint 1.1"<<endl; continue;} 481 // //TODO: Probably it points on a wrong object 482 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++) 483 // { 484 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==NULL) 485 // { continue;} 486 // 487 // orxout()<<"Problempoint 2.1"<<endl; 488 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject); 489 // Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 490 // if (((tempPosition - positionObjectNonBT).length()<radiusObject) && (vergleicheQuader((tempPosition-positionObjectNonBT),(*it)->getScale3D()))) 491 // { 492 // collision=true; break; 493 // } 494 // } 495 // if(collision) break; 496 // } 497 // if(collision)break; 498 // } 499 // if(collision) continue; 500 // // no collision => possible Way 501 // for (float j =0; j<STEPS; j++) 502 // { 503 // Vector3 possiblePosition=(point1 - (point2-point1+richtungen[i]*PHI)*j/STEPS); 504 // collision=false; 505 // for(int ij=0; ij<STEPS; j++) 506 // { 507 // Vector3 tempPosition=(possiblePosition - (point2-possiblePosition)*(float)ij/STEPS); 508 // for (std::vector<StaticEntity*>::iterator it = problematicObjects.begin(); it!=problematicObjects.end(); ++it) 509 // { 510 // btVector3 positionObject; 511 // btScalar radiusObject; 512 // if((*it)==NULL) 513 // { orxout()<<"Problempoint 1"<<endl; continue;} 514 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++) 515 // { 516 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==NULL) 517 // { orxout()<<"Problempoint 2.2"<<endl; continue;} 518 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject); 519 // Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 520 // if (((tempPosition-positionObjectNonBT).length()<radiusObject) && (vergleicheQuader((tempPosition-positionObjectNonBT),(*it)->getScale3D()))) 521 // { 522 // collision=true; break; 523 // } 524 // } 525 // if(collision) break; 526 // } 527 // if(collision)break; 528 // //addVirtualCheckPoint(racepoint1, racepoint2->getCheckpointIndex(), possiblePosition); 529 // return; 530 // } 531 // 532 // } 533 // } 503 // 504 // do{ 505 // zufall=Vector3(rnd(),rnd(),rnd());//random 506 // }while((zufall.crossProduct(objectmiddle-racepoint1->getPosition())).length()==0); 507 // 508 // Vector3 normalvec=zufall.crossProduct(objectmiddle-racepoint1->getPosition()); 509 // // a'/b'=a/b => a' =b'*a/b 510 // float laengeNormalvec=(objectmiddle-racepoint1->getPosition()).length()/sqrt((objectmiddle-racepoint1->getPosition()).squaredLength()-radius*radius)*radius; 511 // addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), objectmiddle+normalvec/normalvec.length()*laengeNormalvec); 512 513 // Vector3 richtungen [6]; 514 // richtungen[0]= Vector3(1,0,0); 515 // richtungen[1]= Vector3(-1,0,0); 516 // richtungen[2]= Vector3(0,1,0); 517 // richtungen[3]= Vector3(0,-1,0); 518 // richtungen[4]= Vector3(0,0,1); 519 // richtungen[5]= Vector3(0,0,-1); 520 // 521 // for (int i = 0; i< 6; i++) 522 // { 523 // const int STEPS=100; 524 // const float PHI=1.1; 525 // bool collision=false; 526 // 527 // for (int j =0; j<STEPS; j++) 528 // { 529 // Vector3 tempPosition=(point1 - (point2-point1+richtungen[i]*PHI)*(float)j/STEPS); 530 // for (std::vector<StaticEntity*>::iterator it = problematicObjects.begin(); it!=problematicObjects.end(); ++it) 531 // { 532 // btVector3 positionObject; 533 // btScalar radiusObject; 534 // if((*it)==NULL) 535 // { orxout()<<"Problempoint 1.1"<<endl; continue;} 536 // //TODO: Probably it points on a wrong object 537 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++) 538 // { 539 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==NULL) 540 // { continue;} 541 // 542 // orxout()<<"Problempoint 2.1"<<endl; 543 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject); 544 // Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 545 // if (((tempPosition - positionObjectNonBT).length()<radiusObject) && (vergleicheQuader((tempPosition-positionObjectNonBT),(*it)->getScale3D()))) 546 // { 547 // collision=true; break; 548 // } 549 // } 550 // if(collision) break; 551 // } 552 // if(collision)break; 553 // } 554 // if(collision) continue; 555 // // no collision => possible Way 556 // for (float j =0; j<STEPS; j++) 557 // { 558 // Vector3 possiblePosition=(point1 - (point2-point1+richtungen[i]*PHI)*j/STEPS); 559 // collision=false; 560 // for(int ij=0; ij<STEPS; j++) 561 // { 562 // Vector3 tempPosition=(possiblePosition - (point2-possiblePosition)*(float)ij/STEPS); 563 // for (std::vector<StaticEntity*>::iterator it = problematicObjects.begin(); it!=problematicObjects.end(); ++it) 564 // { 565 // btVector3 positionObject; 566 // btScalar radiusObject; 567 // if((*it)==NULL) 568 // { orxout()<<"Problempoint 1"<<endl; continue;} 569 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++) 570 // { 571 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==NULL) 572 // { orxout()<<"Problempoint 2.2"<<endl; continue;} 573 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject); 574 // Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z()); 575 // if (((tempPosition-positionObjectNonBT).length()<radiusObject) && (vergleicheQuader((tempPosition-positionObjectNonBT),(*it)->getScale3D()))) 576 // { 577 // collision=true; break; 578 // } 579 // } 580 // if(collision) break; 581 // } 582 // if(collision)break; 583 // //addVirtualCheckPoint(racepoint1, racepoint2->getCheckpointIndex(), possiblePosition); 584 // return; 585 // } 586 // 587 // } 588 // } 534 589 535 590 }
Note: See TracChangeset
for help on using the changeset viewer.