Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2012, 4:36:01 PM (12 years ago)
Author:
purgham
Message:

26.11.12 not really working but usefull stuff for later

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

Legend:

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

    r9451 r9470  
    6363
    6464        myPosition_= this->getPosition(); //eingefuegt
    65         orxout(user_status) << "test" << std::endl;
     65        //orxout(user_status) << "test" << std::endl;
    6666
    6767    }
  • code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc

    r9459 r9470  
    4545    CreateFactory(SpaceRaceController);
    4646
    47     const int AdjustDistance = 500;
     47    const int ADJUSTDISTANCE = 500;
     48    const int MINDISTANCE=5;
    4849    /*
    4950     * Idea: Find static Point (checkpoints the spaceship has to reach)
     
    9394     * returns a vector of static Point (checkpoints the spaceship has to reach)
    9495     */
    95     std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(
    96             std::vector<RaceCheckPoint*> allCheckpoints)
     96    std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(std::vector<RaceCheckPoint*> allCheckpoints)
    9797    {
    9898        std::map<RaceCheckPoint*, int> * zaehler = new std::map<
     
    102102            zaehler->insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0));
    103103        }
    104         int maxWays = rekSimulationCheckpointsReached(zaehler->begin()->first,&allCheckpoints, zaehler);
     104        int maxWays = rekSimulationCheckpointsReached(zaehler->begin()->first, zaehler);
    105105
    106106        std::vector<RaceCheckPoint*> returnVec;
     
    122122     * return how many ways go from the given Checkpoint to the last Checkpoint (of the Game)
    123123     */
    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)
    125125    {
    126126        if (currentCheckpoint->isLast())
     
    132132        {
    133133            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);
    139137            }
    140138            (*zaehler)[currentCheckpoint] += numberOfWays;
     
    296294            lastPositionSpaceship=this->getControllableEntity()->getPosition();
    297295        }
    298         else if ((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()> AdjustDistance)
     296        else if ((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt > ADJUSTDISTANCE)
    299297        {
    300298            nextRaceCheckpoint_ = adjustNextPoint();
    301299            lastPositionSpaceship=this->getControllableEntity()->getPosition();
    302300        }
    303         //korrigieren!
    304         else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()<5){\
     301        //korrigieren! done
     302        else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt< MINDISTANCE  ){
    305303            this->moveToPosition(Vector3(rnd()*100,rnd()*100,rnd()*100));
    306304            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();
    308310        this->moveToPosition(nextRaceCheckpoint_->getPosition());
    309311
    310312
    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    }
    313352}
  • code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h

    r9459 r9470  
    5252            std::vector<RaceCheckPoint*> findStaticCheckpoints(std::vector<RaceCheckPoint*>);
    5353            std::vector<RaceCheckPoint*> staticCheckpoints();
    54             int rekSimulationCheckpointsReached(RaceCheckPoint* , std::vector<RaceCheckPoint*>* checkpoints, std::map< RaceCheckPoint*, int>*);
     54            int rekSimulationCheckpointsReached(RaceCheckPoint* , std::map< RaceCheckPoint*, int>*);
    5555            // same as SpaceRaceManager, but needed to add virtuell Checkpoints ( Checkpoints which don't exist but needed to avoid collisions with big Objects)
    5656            RaceCheckPoint* findCheckpoint(int index) const;
    5757            bool addVirtualCheckPoint(int , RaceCheckPoint* , int , Vector3 );
     58            int pointToPointDistance(Vector3, Vector3);
    5859
    5960        public:
Note: See TracChangeset for help on using the changeset viewer.