Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2012, 4:17:08 PM (11 years ago)
Author:
purgham
Message:

works but its not properly coded

Location:
code/branches/Racingbot/src/modules/gametypes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc

    r9508 r9512  
    6464        myPosition_= this->getPosition(); //eingefuegt
    6565        //orxout(user_status) << "test" << std::endl;
    66 
    67 
    6866    }
    6967
     
    109107    //Must not be called before setNextCheckpointsAsVector3 at least once has been called
    110108    void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){
    111         std::set<int> lastcheckpoints=this->nextCheckpoints_;
     109        /*std::set<int> lastcheckpoints=this->nextCheckpoints_;
    112110        nextCheckpoints_.clear();
    113111        std::set<int>::iterator it = lastcheckpoints.begin();
     
    116114            it++;
    117115        }
    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
    119118
    120119        if(checkpoints.y<-1){
     
    122121                    it++;
    123122        }
    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));
    125125
    126126        if(checkpoints.z<-1){
     
    128128                    it++;
    129129        }
    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);
    131139    }
    132140
     
    141149        if (checkpoints.z > -1)
    142150        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     151
     152        this->nextCheckpointsVirtual_=nextCheckpoints_;
    143153    }
    144154
     
    175185    Vector3 RaceCheckPoint::getNextCheckpointsAsVector3()
    176186    {
    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();
    178199        int j[3];
    179200        j[0]=changeVirtualToRealCheckPoint(checkpoints.x);
     
    201222
    202223        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)
    204225        {
    205226            switch (count)
  • code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h

    r9508 r9512  
    6767            const std::set<int>& getVirtualNextCheckpoints() const
    6868            {
    69                 return this->nextCheckpoints_;
     69                return this->nextCheckpointsVirtual_;
    7070            }
    71             std::set<int> getNextCheckpoints()
     71
     72            const std::set<int>& getNextCheckpoints()
    7273            {
     74                return nextCheckpoints_;
    7375                std::set<int> temp;
    7476                std::set<int> temp2=getVirtualNextCheckpoints();
     
    119121            std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
    120122            Vector3 myPosition_;
     123            std::set<int>  nextCheckpointsVirtual_;
    121124            std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed
    122125    };
  • code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc

    r9508 r9512  
    5454        ArtificialController(creator)
    5555    {
    56         RegisterObject(SpaceRaceController);
    57         std::vector<RaceCheckPoint*> checkpoints;
     56        RegisterObject(SpaceRaceController)
     57;        std::vector<RaceCheckPoint*> checkpoints;
    5858
    5959        virtualCheckPointIndex=-2;
     
    6666        OrxAssert(!checkpoints.empty(), "No Checkpoints in Level");
    6767        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
    6887
    6988        for( std::vector<RaceCheckPoint*>::iterator it = checkpoints.begin(); it!=checkpoints.end(); ++it)
    7089        {
    7190            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                {
    7495                    RaceCheckPoint* point2 = findCheckpoint((*numb));
    7596
    7697                    if(point2 != NULL)
    77                         placeVirtualCheckpoints((*it), point2);
     98                    placeVirtualCheckpoints((*it), point2);
    7899                }
    79100            }
    80101        }
     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;
    81121        staticRacePoints_ = findStaticCheckpoints(checkpoints);
    82122        // initialisation of currentRaceCheckpoint_
     
    84124
    85125        int i;
    86         for (i=-2; findCheckpoint(i)!= NULL; i--){
     126        for (i=-2; findCheckpoint(i)!= NULL; i--)
     127        {
    87128            continue;
    88129        }
     
    147188            for (std::set<int>::iterator it = currentCheckpoint->getVirtualNextCheckpoints().begin(); it!= currentCheckpoint->getVirtualNextCheckpoints().end(); ++it)
    148189            {
    149                 if(currentCheckpoint==findCheckpoint(*it)){
     190                if(currentCheckpoint==findCheckpoint(*it))
     191                {
    150192                    orxout() << currentCheckpoint->getCheckpointIndex()<<endl;
    151193                    continue;
    152194                }
    153                numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler);
     195                if(findCheckpoint(*it)==NULL){orxout()<<"Problematic Point: "<<(*it)<<endl;}
     196                numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler);
    154197            }
    155198            (*zaehler)[currentCheckpoint] += numberOfWays;
     
    266309    {
    267310        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        {
    269313            newTempRaceCheckPoint = new RaceCheckPoint((*it));
    270314        }
     
    276320
    277321        Vector3 temp = previousCheckpoint->getVirtualNextCheckpointsAsVector3();
     322        orxout()<<"temp bei 0: ="<< temp.x<< temp.y<< temp.z<<endl;
    278323        checkpoints_.insert(checkpoints_.end(), newTempRaceCheckPoint);
    279324        int positionInNextCheckPoint;
     
    281326        {
    282327            if(previousCheckpoint->getVirtualNextCheckpointsAsVector3()[i] == indexFollowingCheckPoint)
    283                 positionInNextCheckPoint=i;
     328            positionInNextCheckPoint=i;
    284329        }
    285330        switch(positionInNextCheckPoint)
     
    291336        previousCheckpoint->setNextVirtualCheckpointsAsVector3(temp); //Existiert internes Problem bei negativen index fueer next Checkpoint
    292337        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;
    293340        //OrxAssert(virtualCheckPointIndex < -1, "TO much virtual cp");
    294341        /*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;*/
    298345        return newTempRaceCheckPoint;
    299346    }
     
    339386
    340387        // Abmessung fuer MINDISTANCE gut;
     388
    341389        else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt< MINDISTANCE )
    342390        {
     
    363411    }
    364412
    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    {
    366415
    367416        Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector
     
    370419        btScalar radiusObject;
    371420
    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            {
    374425                btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
    375426                if(currentShape == NULL)
    376                     continue;
     427                continue;
    377428
    378429                currentShape->getBoundingSphere(positionObject,radiusObject);
    379430                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                {
    381433                    return false;
    382434                }
     
    388440    }
    389441
    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;
    421474                }
    422475
    423     }
    424 
    425 
     476            }
     477        }
     478
     479    }
    426480
    427481    void SpaceRaceController::placeVirtualCheckpoints(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2)
     
    441495        }
    442496
    443         if(!directLinePossible(racepoint1, racepoint2, problematicObjects)) {
     497        if(!directLinePossible(racepoint1, racepoint2, problematicObjects))
     498        {
     499            orxout()<<"From "<<racepoint1->getCheckpointIndex()<<" to "<<racepoint2->getCheckpointIndex()<<"produces: "<< virtualCheckPointIndex<<endl;
    444500            computeVirtualCheckpoint(racepoint1, racepoint2, problematicObjects);
    445501        }
    446502
    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        //        }
    534589
    535590    }
Note: See TracChangeset for help on using the changeset viewer.