Changeset 11913 for code/branches/RacingBots_FS18/src/modules
- Timestamp:
- Apr 26, 2018, 4:05:17 PM (7 years ago)
- Location:
- code/branches/RacingBots_FS18/src/modules/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/RacingBots_FS18/src/modules/gametypes/SpaceRace.cc
r11860 r11913 125 125 { 126 126 engine->setActive(false); 127 engine->addSpeedMultiply(3.5f); 127 128 } 128 129 -
code/branches/RacingBots_FS18/src/modules/gametypes/SpaceRaceController.cc
r11912 r11913 235 235 } 236 236 237 /*RaceCheckPoint* SpaceRaceController::addVirtualCheckPoint( RaceCheckPoint* previousCheckpoint, int indexFollowingCheckPoint , const Vector3& virtualCheckPointPosition )238 {239 orxout()<<"add VCP at"<<virtualCheckPointPosition.x<<", "<<virtualCheckPointPosition.y<<", "<<virtualCheckPointPosition.z<<endl;240 RaceCheckPoint* newTempRaceCheckPoint;241 ObjectList<SpaceRaceManager> list;242 for (ObjectList<SpaceRaceManager>::iterator it = list.begin(); it!= list.end(); ++it)243 {244 newTempRaceCheckPoint = new RaceCheckPoint((*it));245 }246 newTempRaceCheckPoint->setVisible(false);247 newTempRaceCheckPoint->setPosition(virtualCheckPointPosition);248 newTempRaceCheckPoint->setCheckpointIndex(virtualCheckPointIndex);249 newTempRaceCheckPoint->setLast(false);250 newTempRaceCheckPoint->setNextVirtualCheckpointsAsVector3(Vector3(indexFollowingCheckPoint,-1,-1));251 252 Vector3 temp = previousCheckpoint->getVirtualNextCheckpointsAsVector3();253 //orxout()<<"temp bei 0: ="<< temp.x<< temp.y<< temp.z<<endl;254 checkpoints_.insert(checkpoints_.end(), newTempRaceCheckPoint);255 int positionInNextCheckPoint;256 for (int i = 0; i <3; i++)257 {258 if(previousCheckpoint->getVirtualNextCheckpointsAsVector3()[i] == indexFollowingCheckPoint)259 positionInNextCheckPoint=i;260 }261 switch(positionInNextCheckPoint)262 {263 case 0: temp.x=virtualCheckPointIndex; break;264 case 1: temp.y=virtualCheckPointIndex; break;265 case 2: temp.z=virtualCheckPointIndex; break;266 }267 previousCheckpoint->setNextVirtualCheckpointsAsVector3(temp); //Existiert internes Problem bei negativen index fueer next Checkpoint268 virtualCheckPointIndex--;269 //orxout()<<"temp bei 1: ="<< temp.x<< temp.y<< temp.z<<endl;270 //orxout()<<"temp nach ausgabe: "<<previousCheckpoint->getVirtualNextCheckpointsAsVector3().x<<previousCheckpoint->getVirtualNextCheckpointsAsVector3().y<<previousCheckpoint->getVirtualNextCheckpointsAsVector3().z<<endl;271 //OrxAssert(virtualCheckPointIndex < -1, "TO much virtual cp");272 orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<", following:"<<indexFollowingCheckPoint<<" : "<<temp.x<<", "<<temp.y<<", "<<temp.z<<"; ";273 temp=previousCheckpoint->getNextCheckpointsAsVector3();274 orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<": "<<temp.x<<", "<<temp.y<<", "<<temp.z<<"; ";275 orxout()<<endl;276 return newTempRaceCheckPoint;277 }*/278 279 237 SpaceRaceController::~SpaceRaceController() 280 238 { … … 380 338 381 339 } 382 383 /*void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2, const std::vector<StaticEntity*>& allObjects)384 {385 Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector386 Vector3 centerCP1=racepoint1->getPosition();387 btVector3 positionObject;388 btScalar radiusObject;389 390 for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it != allObjects.end(); ++it)391 {392 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)393 {394 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();395 if(currentShape == nullptr)396 continue;397 398 currentShape->getBoundingSphere(positionObject,radiusObject);399 Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z());400 Vector3 norm_r_CP = cP1ToCP2.crossProduct(centerCP1-positionObjectNonBT);401 402 if(norm_r_CP.length() == 0){403 Vector3 zufall;404 do{405 zufall=Vector3(rnd(),rnd(),rnd());//random406 }while((zufall.crossProduct(cP1ToCP2)).length() == 0);407 norm_r_CP=zufall.crossProduct(cP1ToCP2);408 }409 Vector3 VecToVCP = norm_r_CP.crossProduct(cP1ToCP2);410 float distanzToCP1 = sqrt(powf(radiusObject,4)/(powf((centerCP1-positionObjectNonBT).length(), 2)-powf(radiusObject,2))+powf(radiusObject,2));411 float distanzToCP2 = sqrt(powf(radiusObject,4)/(powf((racepoint2->getPosition()-positionObjectNonBT).length(), 2)-powf(radiusObject,2))+powf(radiusObject,2));412 float distanz = std::max(distanzToCP1,distanzToCP2);413 //float distanz = 0.0f; //TEMPORARY414 Vector3 newCheckpointPositionPos = positionObjectNonBT+(distanz*VecToVCP)/VecToVCP.length();415 Vector3 newCheckpointPositionNeg = positionObjectNonBT-(distanz*VecToVCP)/VecToVCP.length();416 if((newCheckpointPositionPos - centerCP1).length() + (newCheckpointPositionPos - (centerCP1+cP1ToCP2)).length() < (newCheckpointPositionNeg - centerCP1).length() + (newCheckpointPositionNeg - (centerCP1+cP1ToCP2)).length() )417 {418 RaceCheckPoint* newVirtualCheckpoint = addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), newCheckpointPositionPos);419 }420 else421 {422 RaceCheckPoint* newVirtualCheckpoint = addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), newCheckpointPositionNeg);423 }424 return;425 }426 }427 428 }*/429 430 /*void SpaceRaceController::placeVirtualCheckpoints(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2)431 {432 Vector3 point1 = racepoint1->getPosition();433 Vector3 point2 = racepoint2->getPosition();434 std::vector<StaticEntity*> problematicObjects;435 436 ObjectList<StaticEntity> list;437 for (ObjectList<StaticEntity>::iterator it = list.begin(); it!= list.end(); ++it)438 {439 440 if (dynamic_cast<RaceCheckPoint*>(*it) != nullptr)441 {442 continue;443 } // does not work jet444 445 problematicObjects.insert(problematicObjects.end(), *it);446 //it->getScale3D();// vector fuer halbe wuerfellaenge447 }448 449 if(!directLinePossible(racepoint1, racepoint2, problematicObjects))450 {451 //orxout()<<"From "<<racepoint1->getCheckpointIndex()<<" to "<<racepoint2->getCheckpointIndex()<<"produces: "<< virtualCheckPointIndex<<endl;452 computeVirtualCheckpoint(racepoint1, racepoint2, problematicObjects);453 }454 455 //456 // do{457 // zufall=Vector3(rnd(),rnd(),rnd());//random458 // }while((zufall.crossProduct(objectmiddle-racepoint1->getPosition())).length()==0);459 //460 // Vector3 normalvec=zufall.crossProduct(objectmiddle-racepoint1->getPosition());461 // // a'/b'=a/b => a' =b'*a/b462 // float laengeNormalvec=(objectmiddle-racepoint1->getPosition()).length()/sqrt((objectmiddle-racepoint1->getPosition()).squaredLength()-radius*radius)*radius;463 // addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), objectmiddle+normalvec/normalvec.length()*laengeNormalvec);464 465 // Vector3 richtungen [6];466 // richtungen[0]= Vector3(1,0,0);467 // richtungen[1]= Vector3(-1,0,0);468 // richtungen[2]= Vector3(0,1,0);469 // richtungen[3]= Vector3(0,-1,0);470 // richtungen[4]= Vector3(0,0,1);471 // richtungen[5]= Vector3(0,0,-1);472 //473 // for (int i = 0; i< 6; i++)474 // {475 // const int STEPS=100;476 // const float PHI=1.1;477 // bool collision=false;478 //479 // for (int j =0; j<STEPS; j++)480 // {481 // Vector3 tempPosition=(point1 - (point2-point1+richtungen[i]*PHI)*(float)j/STEPS);482 // for (std::vector<StaticEntity*>::iterator it = problematicObjects.begin(); it!=problematicObjects.end(); ++it)483 // {484 // btVector3 positionObject;485 // btScalar radiusObject;486 // if((*it)==nullptr)487 // { orxout()<<"Problempoint 1.1"<<endl; continue;}488 // //TODO: Probably it points on a wrong object489 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=nullptr; everyShape++)490 // {491 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==nullptr)492 // { continue;}493 //494 // orxout()<<"Problempoint 2.1"<<endl;495 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject);496 // Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z());497 // if (((tempPosition - positionObjectNonBT).length()<radiusObject) && (vergleicheQuader((tempPosition-positionObjectNonBT),(*it)->getScale3D())))498 // {499 // collision=true; break;500 // }501 // }502 // if(collision) break;503 // }504 // if(collision)break;505 // }506 // if(collision) continue;507 // // no collision => possible Way508 // for (float j =0; j<STEPS; j++)509 // {510 // Vector3 possiblePosition=(point1 - (point2-point1+richtungen[i]*PHI)*j/STEPS);511 // collision=false;512 // for(int ij=0; ij<STEPS; j++)513 // {514 // Vector3 tempPosition=(possiblePosition - (point2-possiblePosition)*(float)ij/STEPS);515 // for (std::vector<StaticEntity*>::iterator it = problematicObjects.begin(); it!=problematicObjects.end(); ++it)516 // {517 // btVector3 positionObject;518 // btScalar radiusObject;519 // if((*it)==nullptr)520 // { orxout()<<"Problempoint 1"<<endl; continue;}521 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=nullptr; everyShape++)522 // {523 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==nullptr)524 // { orxout()<<"Problempoint 2.2"<<endl; continue;}525 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject);526 // Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z());527 // if (((tempPosition-positionObjectNonBT).length()<radiusObject) && (vergleicheQuader((tempPosition-positionObjectNonBT),(*it)->getScale3D())))528 // {529 // collision=true; break;530 // }531 // }532 // if(collision) break;533 // }534 // if(collision)break;535 // //addVirtualCheckPoint(racepoint1, racepoint2->getCheckpointIndex(), possiblePosition);536 // return;537 // }538 //539 // }540 // }541 542 }*/543 340 }
Note: See TracChangeset
for help on using the changeset viewer.