Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9523 for code


Ignore:
Timestamp:
Dec 16, 2012, 6:07:37 PM (12 years ago)
Author:
jo
Message:

Merging the Racingbot branch into the presentationHS12 branch.

Location:
code/branches/presentationHS12
Files:
9 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS12

  • code/branches/presentationHS12/data/levels/presentationHS12.oxw

    r9521 r9523  
    6060
    6161    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    62     <SpawnPoint team=0 position="-800,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
     62    <SpawnPoint team=0 position="-900,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
    6363    <!--SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=bigship /-->
    6464    <!--SpawnPoint team=0 position="-900,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipcollateraldamage /-->
     
    6767    <SpaceRaceManager>
    6868        <checkpoints>
    69             <RaceCheckPoint name="checkpoint1" position="000,0,0" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="0" islast="false" nextcheckpoints="1,2,3">
     69            <RaceCheckPoint name="checkpoint1" position="000,0,0" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="0" islast="false" nextcheckpoints="1,2,3">
    7070                <attached>
    7171                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     
    7373            </RaceCheckPoint>
    7474<!--- first three alternative paths --->
    75             <RaceCheckPoint name="checkpoint2" position="1300,0,-800" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="1" islast="false" nextcheckpoints="7,-1,-1">
     75            <RaceCheckPoint name="checkpoint2" position="1300,0,-800" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="1" islast="false" nextcheckpoints="7,-1,-1">
    7676                <attached>
    7777                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90/>
     
    7979            </RaceCheckPoint>
    8080
    81             <RaceCheckPoint name="checkpoint3" position="1200,-400,0" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="2" islast="false" nextcheckpoints="5,-1,-1">
    82                 <attached>
    83                     <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
    84                 </attached>
    85             </RaceCheckPoint>
    86 
    87             <RaceCheckPoint name="checkpoint4" position="1200,100,700" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="3" islast="false" nextcheckpoints="6,-1,-1">
     81            <RaceCheckPoint name="checkpoint3" position="1200,-400,0" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="2" islast="false" nextcheckpoints="5,-1,-1">
     82                <attached>
     83                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     84                </attached>
     85            </RaceCheckPoint>
     86
     87            <RaceCheckPoint name="checkpoint4" position="1200,100,700" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="3" islast="false" nextcheckpoints="6,-1,-1">
    8888                <attached>
    8989                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     
    9292
    9393<!--- second three alternative paths --->
    94             <!--RaceCheckPoint name="checkpoint5" position="2000,500,-400" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="4" islast="false" nextcheckpoints="7,-1,-1">
     94            <!--RaceCheckPoint name="checkpoint5" position="2000,500,-400" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="4" islast="false" nextcheckpoints="7,-1,-1">
    9595                <attached>
    9696                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     
    9898            </RaceCheckPoint-->
    9999
    100             <RaceCheckPoint name="checkpoint6" position="2000,0,0" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="5" islast="false" nextcheckpoints="8,9,-1">
    101                 <attached>
    102                     <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
    103                 </attached>
    104             </RaceCheckPoint>
    105 
    106             <RaceCheckPoint name="checkpoint7" position="2000,-500,400" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="6" islast="false" nextcheckpoints="10,-1,-1">
     100            <RaceCheckPoint name="checkpoint6" position="2000,0,0" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="5" islast="false" nextcheckpoints="8,9,-1">
     101                <attached>
     102                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     103                </attached>
     104            </RaceCheckPoint>
     105
     106            <RaceCheckPoint name="checkpoint7" position="2000,-500,400" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="6" islast="false" nextcheckpoints="10,-1,-1">
    107107                <attached>
    108108                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     
    113113<!--- third generation --->
    114114
    115             <RaceCheckPoint name="checkpoint8" position="5000,0,-3000" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="7" islast="false" nextcheckpoints="12,-1,-1">
     115            <RaceCheckPoint name="checkpoint8" position="5000,0,-3000" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="7" islast="false" nextcheckpoints="12,-1,-1">
    116116                <attached>
    117117                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=135 />
     
    119119            </RaceCheckPoint>
    120120
    121             <RaceCheckPoint name="checkpoint9" position="3500,800,0" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="8" islast="false" nextcheckpoints="11,-1,-1">
    122                 <attached>
    123                     <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
    124                 </attached>
    125             </RaceCheckPoint>
    126 
    127             <RaceCheckPoint name="checkpoint10" position="3500,-800,0" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="9" islast="false" nextcheckpoints="11,-1,-1">
    128                 <attached>
    129                     <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
    130                 </attached>
    131             </RaceCheckPoint>
    132 
    133             <RaceCheckPoint name="checkpoint11" position="3500,0,1000" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="10" islast="false" nextcheckpoints="12,-1,-1">
     121            <RaceCheckPoint name="checkpoint9" position="3500,800,0" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="8" islast="false" nextcheckpoints="11,-1,-1">
     122                <attached>
     123                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     124                </attached>
     125            </RaceCheckPoint>
     126
     127            <RaceCheckPoint name="checkpoint10" position="3500,-800,0" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="9" islast="false" nextcheckpoints="11,-1,-1">
     128                <attached>
     129                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     130                </attached>
     131            </RaceCheckPoint>
     132
     133            <RaceCheckPoint name="checkpoint11" position="3500,0,1000" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="10" islast="false" nextcheckpoints="12,-1,-1">
    134134                <attached>
    135135                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     
    138138
    139139<!-- Intermediate Solo Gate -->
    140             <RaceCheckPoint name="checkpoint12" position="4500,0,-100" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="11" islast="false" nextcheckpoints="12,-1,-1">
     140            <RaceCheckPoint name="checkpoint12" position="4500,0,-100" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="11" islast="false" nextcheckpoints="12,-1,-1">
    141141                <attached>
    142142                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=90 />
     
    145145
    146146<!----  First Common Point  ---->
    147             <RaceCheckPoint name="checkpoint13" position="6000,0,2000" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="12" islast="false" nextcheckpoints="13,14,-1">
     147            <RaceCheckPoint name="checkpoint13" position="6000,0,2000" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="12" islast="false" nextcheckpoints="13,14,-1">
    148148                <attached>
    149149                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=100 pitch=45 />
     
    152152
    153153<!-- Two Paths (1) -->
    154             <RaceCheckPoint name="checkpoint14" position="7500,-1500,2500" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="13" islast="false" nextcheckpoints="15,-1,-1">
     154            <RaceCheckPoint name="checkpoint14" position="7500,-1500,2500" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="13" islast="false" nextcheckpoints="15,-1,-1">
    155155                <attached>
    156156                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=100 pitch=130 roll=1 />
    157                     <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.6,0.4,0.1" scale=3 />
    158                 </attached>
    159             </RaceCheckPoint>
    160 
    161             <RaceCheckPoint name="checkpoint15" position="7500,-1500,1500" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="14" islast="false" nextcheckpoints="16,-1,-1">
     157                </attached>
     158            </RaceCheckPoint>
     159
     160            <RaceCheckPoint name="checkpoint15" position="7500,-1500,1500" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="14" islast="false" nextcheckpoints="16,-1,-1">
    162161                <attached>
    163162                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=100 pitch=90 />
     
    166165
    167166<!-- Two Paths (2) -->
    168             <RaceCheckPoint name="checkpoint16" position="9000,-3000, 3000" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="15" islast="false" nextcheckpoints="17,-1,-1">
     167            <RaceCheckPoint name="checkpoint16" position="9000,-3000, 3000" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="15" islast="false" nextcheckpoints="17,-1,-1">
    169168                <attached>
    170169                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=100 pitch=130 roll=1 />
    171                     <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=3 />
    172                 </attached>
    173             </RaceCheckPoint>
    174 
    175             <RaceCheckPoint name="checkpoint17" position="9000,-3000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="16" islast="false" nextcheckpoints="17,-1,-1">
     170                </attached>
     171            </RaceCheckPoint>
     172
     173            <RaceCheckPoint name="checkpoint17" position="9000,-3000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="16" islast="false" nextcheckpoints="17,-1,-1">
    176174                <attached>
    177175                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=100 pitch=110 />
     
    180178
    181179<!-- GOAL -->
    182             <RaceCheckPoint name="checkpoint18" position="12000,-4000,2000" direction="0,-1,1" collisionType="static" scale="1" distance="70" checkpointindex="17" islast="true">
     180            <RaceCheckPoint name="checkpoint18" position="12000,-4000,2000" direction="0,-1,1" collisionType="static" scale="1" distance="100" checkpointindex="17" islast="true">
    183181                <attached>
    184182                    <Model mass="50" scale="6" mesh="BigSpacegate.mesh" yaw=100 pitch=135 />
     
    187185        </checkpoints>
    188186    </SpaceRaceManager>
    189 
    190 
    191 
    192187
    193188
     
    296291      </attached>
    297292    </StaticEntity>
     293
     294   <!-- Docking -->
     295    <Dock position="2830,20,50" roll=0 yaw=0 >
     296        <animations>
     297            <MoveToDockingTarget target="destroyer" />
     298        </animations>
     299        <effects>
     300            <DockToShip target="spaceShip" />
     301        </effects>
     302        <events>
     303            <execute>
     304                <EventListener event="dockMe" />
     305            </execute>
     306            <activity>
     307                <EventListener event=notGameEnd />
     308            </activity>
     309        </events>
     310        <attached>
     311                    <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 />
     312        <BlinkingBillboard position="10,0,0" material="Examples/Flare" colour="1, 0.3, 1, 0.1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     313        <BlinkingBillboard position="20,0,0" material="Examples/Flare" colour="1, 0.3, 1, 0.1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     314        <BlinkingBillboard position="30,0,0" material="Examples/Flare" colour="1, 0.3, 1, 0.1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     315        <BlinkingBillboard position="0,10,0" material="Examples/Flare" colour="0.3, 1, 1, 0.1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     316        <BlinkingBillboard position="0,20,0" material="Examples/Flare" colour="0.3, 1, 1, 0.1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     317        <BlinkingBillboard position="0,30,0" material="Examples/Flare" colour="0.3, 1, 1, 0.1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     318        <BlinkingBillboard position="0,0,10" material="Examples/Flare" colour="0.3, 0.3, 1, 1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     319        <BlinkingBillboard position="0,0,20" material="Examples/Flare" colour="0.3, 0.3, 1, 1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     320        <BlinkingBillboard position="0,0,30" material="Examples/Flare" colour="0.3, 0.3, 1, 1" amplitude=0.2 frequency=0.4 phase=0 quadratic=1 />
     321            <DistanceTrigger position="0,0,0" distance="200" target="Pawn"
     322                beaconMode="exclude" targetname="bcnDestroyer" name="dockMe"
     323            />
     324        </attached>
     325
     326    </Dock>
     327    <SpaceShip
     328        template            = "spaceshipcollateraldamage"
     329        team                = "0"
     330        position            = "2890,-40,6"
     331        orientation         = "-0.14, 0.68, 0.68, 0.223"
     332        lookat              = "0,0,0"
     333        roll                = "180"
     334        name                = "collateralDamage"
     335        radarname           = "Collateral Damage" >
     336        <!--
     337        pitch               = "90"
     338        yaw                 = "0"-->
     339      <attached>
     340        <DockingTarget name="spaceShip" />
     341        <DistanceTriggerBeacon name="bcnDestroyer" />
     342        <DockingTarget name="destroyer" />
     343      </attached>
     344    </SpaceShip>
     345
    298346    <!-- triple large belt around the planet  -->
    299347    <?lua
     
    335383    </Planet>
    336384
    337 
    338 <!-- INTERACTIVE LEVEL -->
     385<StaticEntity position="6750,-750,2000" yaw=0 pitch=0>
     386    <attached>
     387        <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" />
     388        <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" />
     389        <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" />
     390        <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" />
     391        <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" />
     392    </attached>
     393</StaticEntity>
     394<SpaceShip position="6750,-740,2000" pitch="90" yaw="0" roll="0" radarname="Automatic Turret">
     395    <templates>
     396        <Template link=spaceshipturret />
     397    </templates>
     398    <controller>
     399        <WaypointPatrolController alertnessradius=1000 team=10>
     400        </WaypointPatrolController>
     401     </controller>
     402</SpaceShip>
     403
     404
     405    <!--- Some Randomn Asteroids  --->
     406    <?lua
     407      for i = 1, 250, 1
     408      do
     409      j = math.random()
     410    ?>
     411
     412    <MovableEntity
     413      position = "<?lua print(math.random()* 15000 - 1000) ?>,<?lua print(math.random() * 12000 - 4000) ?>,<?lua print(math.random() * 12000 - 4000) ?>"
     414      collisionType = dynamic
     415      linearDamping = 0.8
     416      angularDamping = 0
     417      scale = "<?lua print(j * 150)?>"
     418      collisiondamage = 1
     419      enablecollisiondamage = true
     420    >
     421      <attached>
     422        <Model mass="<?lua print(j * 1000) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     423      </attached>
     424      <collisionShapes>
     425        <SphereCollisionShape radius="<?lua print(j * 350) ?>" />
     426      </collisionShapes>
     427    </MovableEntity>
     428
     429    <?lua
     430      end
     431    ?>
     432
     433
     434
     435
     436
     437
     438<!-- INTERACTIVE PART -->
    339439    <DistanceTrigger name="start" position="-900,0,0"  target="Pawn" distance=100 stayActive="true" delay=0.5 />
    340440    <DistanceTrigger name="spawnBots" position="-900,0,0"  target="Pawn" distance=100 stayActive="true" delay=4.5 />
     441    <DistanceTrigger name="creditPetar" position="2000,0,0"  target="Pawn" distance=100 stayActive="true" delay=0.5 />
     442    <DistanceTrigger name="creditDario" position="4500,0,-100"  target="Pawn" distance=200 stayActive="true" delay=5 />
    341443
    342444    <SimpleNotification message="Sound Effetcs by Mike." broadcast="true">
     
    348450    </SimpleNotification>
    349451
    350     <Script code="addBots 3" onLoad="false">
     452    <SimpleNotification message="Racing Bots by Michael." broadcast="true">
    351453        <events>
    352454            <trigger>
     
    354456            </trigger>
    355457        </events>
     458    </SimpleNotification>
     459
     460    <SimpleNotification message="Planetary Destroyer by Petar." broadcast="true">
     461        <events>
     462            <trigger>
     463                <EventListener event=creditPetar />
     464            </trigger>
     465        </events>
     466    </SimpleNotification>
     467
     468    <SimpleNotification message="Collateral Damage by Raphael." broadcast="true">
     469        <events>
     470            <trigger>
     471                <EventListener event=dockMe />
     472            </trigger>
     473        </events>
     474    </SimpleNotification>
     475
     476    <SimpleNotification message="Automatic Turret by Dario." broadcast="true">
     477        <events>
     478            <trigger>
     479                <EventListener event=creditDario />
     480            </trigger>
     481        </events>
     482    </SimpleNotification>
     483
     484    <Script code="addBots 3" onLoad="false">
     485        <events>
     486            <trigger>
     487                <EventListener event=spawnBots />
     488            </trigger>
     489        </events>
    356490    </Script>
    357491
    358492
    359493<!-- SOUNDS & MUSIC -->
    360             <WorldSound name="scoreSound" position="-900,0,0" source="sounds/ReadyGo.ogg" >
     494            <WorldSound name="scoreSound" position="-920,0,0" source="sounds/ReadyGo.ogg" >
    361495              <events>
    362496                <play>
  • code/branches/presentationHS12/src/modules/gametypes/CMakeLists.txt

    r9016 r9523  
    55  OldSpaceRace.cc
    66  OldRaceCheckPoint.cc
     7  SpaceRaceBot.cc
     8  SpaceRaceController.cc
    79)
    810
  • code/branches/presentationHS12/src/modules/gametypes/GametypesPrereqs.h

    r9016 r9523  
    6767    class SpaceRace;
    6868    class OldSpaceRace;
     69    class SpaceRaceManager;
     70    class SpaceRaceBot;
     71    class SpaceRaceController;
    6972}
    7073
  • code/branches/presentationHS12/src/modules/gametypes/RaceCheckPoint.cc

    r9348 r9523  
    4343    CreateFactory(RaceCheckPoint);
    4444
    45     RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
     45    RaceCheckPoint::RaceCheckPoint(BaseObject* creator) : DistanceMultiTrigger(creator),
     46            RadarViewable(creator, static_cast<WorldEntity*> (this))
    4647    {
    4748        RegisterObject(RaceCheckPoint);
    48 
    4949        this->setDistance(100);
    5050        this->setBeaconMode("off");
     
    6060        this->bIsLast_ = false;
    6161        this->timeLimit_ = 0;
    62         this->player_ = NULL;
    63     }
    64 
    65 
    66    RaceCheckPoint::~RaceCheckPoint()
    67    {
    68    }
     62        //this->players_ = vector<PlayerInfo*>();
     63
     64        myPosition_= this->getPosition(); //eingefuegt
     65        //orxout(user_status) << "test" << std::endl;
     66    }
     67
     68    RaceCheckPoint::~RaceCheckPoint()
     69    {
     70
     71    }
    6972
    7073    void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    8689            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
    8790            if (entity)
    88                 this->player_ = entity->getPlayer();
     91                this->players_.push_back(entity->getPlayer());
    8992        }
    9093    }
     
    9598        if (this->timeLimit_ != 0)
    9699        {
    97             std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
    98                         + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
     100            std::string message = "You have " + multi_cast<std::string>(this->timeLimit_)
     101            + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
    99102            this->getGametype()->getGametypeInfo()->sendAnnounceMessage(message);
    100103            ChatManager::message(message);
     
    102105    }
    103106
     107    //Must not be called before setNextCheckpointsAsVector3 at least once has been called
     108    void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){
     109        /*std::set<int> lastcheckpoints=this->nextCheckpoints_;
     110        nextCheckpoints_.clear();
     111        std::set<int>::iterator it = lastcheckpoints.begin();
     112        if(checkpoints.x<-1){
     113            virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.x,(*it)));
     114            it++;
     115        }
     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
     118
     119        if(checkpoints.y<-1){
     120                    virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.y,(*it)));
     121                    it++;
     122        }
     123        if(checkpoints.y!=-1)
     124            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
     125
     126        if(checkpoints.z<-1){
     127                    virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.z,(*it)));
     128                    it++;
     129        }
     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);
     139    }
     140
    104141    void RaceCheckPoint::setNextCheckpointsAsVector3(const Vector3& checkpoints)
    105142    {
     
    107144
    108145        if (checkpoints.x > -1)
    109             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));
     146        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
    110147        if (checkpoints.y > -1)
    111             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
     148        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
    112149        if (checkpoints.z > -1)
    113             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
    114     }
    115 
    116     Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() const
     150        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     151
     152        this->nextCheckpointsVirtual_=nextCheckpoints_;
     153    }
     154
     155    PlayerInfo* RaceCheckPoint::getPlayer(unsigned int clientID) const
     156    {
     157        if (players_.size() > 0)
     158        {
     159            for (int i = 0; i < players_.size(); i++)
     160            {
     161                if (this->players_[i]->getClientID() == clientID)
     162                {
     163                    return players_[i];
     164                }
     165            }
     166        }
     167        return NULL;
     168    }
     169
     170    bool RaceCheckPoint::playerWasHere(PlayerInfo* player) const
     171    {
     172        if (players_.size() > 0)
     173        {
     174            for (int i = 0; i < players_.size(); i++)
     175            {
     176                if (this->players_[i] == player)
     177                {
     178                    return true;
     179                }
     180            }
     181        }
     182        return false;
     183    }
     184
     185    Vector3 RaceCheckPoint::getNextCheckpointsAsVector3()
     186    {
     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();
     199        int j[3];
     200        j[0]=changeVirtualToRealCheckPoint(checkpoints.x);
     201        j[1]=changeVirtualToRealCheckPoint(checkpoints.y);
     202        j[2]=changeVirtualToRealCheckPoint(checkpoints.z);
     203
     204
     205        return Vector3(j[0],j[1],j[2]);
     206
     207
     208    }
     209
     210    int RaceCheckPoint::changeVirtualToRealCheckPoint(int checkpointID) {
     211        int temp=checkpointID;
     212        while(temp<-1){
     213            temp = this->virtualToRealCheckPoints_[temp];
     214        }
     215        return temp;
     216    }
     217
     218
     219    Vector3 RaceCheckPoint::getVirtualNextCheckpointsAsVector3() const
    117220    {
    118221        Vector3 checkpoints = Vector3(-1, -1, -1);
    119222
    120223        size_t count = 0;
    121         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)
    122225        {
    123226            switch (count)
  • code/branches/presentationHS12/src/modules/gametypes/RaceCheckPoint.h

    r9263 r9523  
    3737{
    3838    /**
    39     @brief
    40         The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
    41         Don't forget to control the indexes of your check points and to set one last check point
    42     */
    43     class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable
     39     @brief
     40     The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
     41     Don't forget to control the indexes of your check points and to set one last check point
     42     */
     43    class _GametypesExport RaceCheckPoint: public DistanceMultiTrigger,
     44            public RadarViewable
    4445    {
    4546        public:
     
    5051
    5152            inline void setCheckpointIndex(int checkpointIndex)
    52                 { this->checkpointIndex_ = checkpointIndex; }
     53            {
     54                this->checkpointIndex_ = checkpointIndex;
     55            }
    5356            inline int getCheckpointIndex() const
    54                 { return this->checkpointIndex_; }
     57            {
     58                return this->checkpointIndex_;
     59            }
    5560
    5661            void setNextCheckpointsAsVector3(const Vector3& checkpoints);
    57             Vector3 getNextCheckpointsAsVector3() const;
    58             const std::set<int>& getNextCheckpoints() const
    59                 { return this->nextCheckpoints_; }
     62            Vector3 getNextCheckpointsAsVector3();
     63            Vector3 getVirtualNextCheckpointsAsVector3() const;
     64            void setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints);
     65            int changeVirtualToRealCheckPoint(int);
    6066
     67            const std::set<int>& getVirtualNextCheckpoints() const
     68            {
     69                return this->nextCheckpointsVirtual_;
     70            }
     71
     72            const std::set<int>& getNextCheckpoints()
     73            {
     74                return nextCheckpoints_;
     75                std::set<int> temp;
     76                std::set<int> temp2=getVirtualNextCheckpoints();
     77                for (std::set<int>::iterator it = temp2.begin(); it!=temp2.end(); ++it){
     78                    temp.insert(changeVirtualToRealCheckPoint((*it)));
     79                }
     80                return temp;
     81            }
    6182            inline void setLast(bool isLast)
    62                 { this->bIsLast_ = isLast; }
     83            {
     84                this->bIsLast_ = isLast;
     85            }
    6386            inline bool isLast() const
    64                 { return this->bIsLast_; }
     87            {
     88                return this->bIsLast_;
     89            }
    6590
    6691            virtual void setTimelimit(float timeLimit);
    6792            inline float getTimeLimit() const
    68                 { return this->timeLimit_; }
     93            {
     94                return this->timeLimit_;
     95            }
    6996
    70             inline PlayerInfo* getPlayer() const
    71                 { return this->player_; }
     97            PlayerInfo* getPlayer(unsigned int clientID) const;
     98
     99            bool playerWasHere(PlayerInfo* ) const;
     100
    72101            inline void resetPlayer()
    73                 { this->player_ = NULL; }
     102            {
     103                this->players_.clear();
     104            }
    74105
    75106        protected:
     107
    76108            virtual void fire(bool bIsTriggered, BaseObject* originator);
    77109
    78110            inline const WorldEntity* getWorldEntity() const
    79                 { return this; }
     111            {
     112                return this;
     113            }
    80114
    81115        private:
    82             int checkpointIndex_;           ///< The index of this check point. The race starts with the check point with the index 0
     116
     117            int checkpointIndex_; ///< The index of this check point. The race starts with the check point with the index 0
    83118            std::set<int> nextCheckpoints_; ///< the indexes of the next check points
    84             bool bIsLast_;                  ///< True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
    85             float timeLimit_;               ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
    86             PlayerInfo* player_;            ///< The player that reached the checkpoint
     119            bool bIsLast_; ///< True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
     120            float timeLimit_; ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
     121            std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
     122            Vector3 myPosition_;
     123            std::set<int>  nextCheckpointsVirtual_;
     124            std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed
    87125    };
    88126}
  • code/branches/presentationHS12/src/modules/gametypes/SpaceRace.cc

    r9348 r9523  
    3535#include "util/Convert.h"
    3636#include "util/Math.h"
    37 
     37#include "SpaceRaceBot.h"
    3838#include "items/Engine.h"
    3939
     
    4646        RegisterObject(SpaceRace);
    4747
     48        this->botclass_ = Class(SpaceRaceBot);//ClassByString("")
    4849        this->cantMove_ = false;
    4950        this->bTimeIsUp_ = false;
  • code/branches/presentationHS12/src/modules/gametypes/SpaceRaceController.cc

    r9513 r9523  
    4242#include "BulletCollision/CollisionShapes/btCollisionShape.h"
    4343
     44
    4445namespace orxonox
    4546{
     
    5758;        std::vector<RaceCheckPoint*> checkpoints;
    5859
    59         virtualCheckPointIndex=-2;
    60         for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it)
     60        virtualCheckPointIndex = -2;
     61        for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it != ObjectList<SpaceRaceManager>::end(); ++it)
    6162        {
    6263            checkpoints = it->getAllCheckpoints();
    63             nextRaceCheckpoint_=it->findCheckpoint(0);
     64            nextRaceCheckpoint_ = it->findCheckpoint(0);
    6465        }
    6566
    6667        OrxAssert(!checkpoints.empty(), "No Checkpoints in Level");
    67         checkpoints_=checkpoints;
     68        checkpoints_ = checkpoints;
    6869        /*orxout()<<"es gibt: "<<checkpoints_.size()<<"checkpoints"<<endl;
    6970        for(std::vector<RaceCheckPoint*>::iterator it=checkpoints_.begin(); it!=checkpoints_.end(); it++)
     
    8687        }//ausgabe*/
    8788
    88         for( std::vector<RaceCheckPoint*>::iterator it = checkpoints.begin(); it!=checkpoints.end(); ++it)
     89        for (std::vector<RaceCheckPoint*>::iterator it = checkpoints.begin(); it != checkpoints.end(); ++it)
    8990        {
    9091            std::set<int> nextCheckPoints = ((*it)->getNextCheckpoints());
     
    9596                    RaceCheckPoint* point2 = findCheckpoint((*numb));
    9697
    97                     if(point2 != NULL)
    98                     placeVirtualCheckpoints((*it), point2);
     98                    //if(point2 != NULL)
     99                    //placeVirtualCheckpoints((*it), point2);
    99100                }
    100101            }
     
    124125
    125126        int i;
    126         for (i=-2; findCheckpoint(i)!= NULL; i--)
     127        for (i = -2; findCheckpoint(i) != NULL; i--)
    127128        {
    128129            continue;
     
    140141        XMLPortParam(ArtificialController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f);
    141142        XMLPortObject(ArtificialController, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode);
    142 
    143143    }
    144144
     
    149149    std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(std::vector<RaceCheckPoint*> allCheckpoints)
    150150    {
    151         std::map<RaceCheckPoint*, int> * zaehler = new std::map<RaceCheckPoint*, int>(); // counts how many times the checkpoit was reached (for simulation)
     151        std::map<RaceCheckPoint*, int> * zaehler = new std::map<RaceCheckPoint*, int>(); // counts how many times the checkpoint was reached (for simulation)
    152152        for (unsigned int i = 0; i < allCheckpoints.size(); i++)
    153153        {
     
    158158        std::vector<RaceCheckPoint*> returnVec;
    159159        returnVec.clear();
    160         for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler->begin(); iter!= zaehler->end(); iter++)
     160        for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler->begin(); iter != zaehler->end(); iter++)
    161161        {
    162162            if (iter->second == maxWays)
     
    188188            for (std::set<int>::iterator it = currentCheckpoint->getVirtualNextCheckpoints().begin(); it!= currentCheckpoint->getVirtualNextCheckpoints().end(); ++it)
    189189            {
    190                 if(currentCheckpoint==findCheckpoint(*it))
     190                if(currentCheckpoint == findCheckpoint(*it))
    191191                {
    192192                    //orxout() << currentCheckpoint->getCheckpointIndex()<<endl;
    193193                    continue;
    194194                }
    195                 if(findCheckpoint(*it)==NULL){orxout()<<"Problematic Point: "<<(*it)<<endl;}
     195                if(findCheckpoint(*it) == NULL)
     196                    {orxout()<<"Problematic Point: "<<(*it)<<endl;}
    196197                numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler);
    197198            }
     
    219220    RaceCheckPoint* SpaceRaceController::nextPointFind(RaceCheckPoint* raceCheckpoint)
    220221    {
    221         int distances[] =
    222         {   -1, -1, -1};
     222        int distances[] = {-1, -1, -1};
    223223        int temp_i = 0;
    224224        for (std::set<int>::iterator it =raceCheckpoint->getVirtualNextCheckpoints().begin(); it!= raceCheckpoint->getVirtualNextCheckpoints().end(); ++it)
     
    266266        {
    267267            int minimum = std::numeric_limits<int>::max();
    268             for (std::set<int>::iterator it = currentCheckPoint->getVirtualNextCheckpoints().begin(); it!= currentCheckPoint->getVirtualNextCheckpoints().end(); ++it)
     268            for (std::set<int>::iterator it = currentCheckPoint->getVirtualNextCheckpoints().begin(); it != currentCheckPoint->getVirtualNextCheckpoints().end(); ++it)
    269269            {
    270270                int dist_currentCheckPoint_currentPosition = static_cast<int> ((currentPosition- currentCheckPoint->getPosition()).length());
    271271
    272                 minimum= std::min(minimum, dist_currentCheckPoint_currentPosition + recCalculateDistance(findCheckpoint(*it), currentCheckPoint->getPosition()));
     272                minimum = std::min(minimum, dist_currentCheckPoint_currentPosition + recCalculateDistance(findCheckpoint(*it), currentCheckPoint->getPosition()));
    273273                // minimum of distanz from 'currentPosition' to the next static Checkpoint
    274274            }
     
    306306    }
    307307
    308     RaceCheckPoint* SpaceRaceController::addVirtualCheckPoint( RaceCheckPoint* previousCheckpoint, int indexFollowingCheckPoint , Vector3 virtualCheckPointPosition )
     308    /*RaceCheckPoint* SpaceRaceController::addVirtualCheckPoint( RaceCheckPoint* previousCheckpoint, int indexFollowingCheckPoint , Vector3 virtualCheckPointPosition )
    309309    {
    310310        orxout()<<"add VCP at"<<virtualCheckPointPosition.x<<", "<<virtualCheckPointPosition.y<<", "<<virtualCheckPointPosition.z<<endl;
     
    343343         temp=previousCheckpoint->getNextCheckpointsAsVector3();
    344344         orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<":       "<<temp.x<<", "<<temp.y<<", "<<temp.z<<";       ";
    345          orxout()<<endl;*/
     345         orxout()<<endl;*//*
    346346        return newTempRaceCheckPoint;
    347     }
     347    }*/
    348348
    349349    SpaceRaceController::~SpaceRaceController()
     
    358358    {
    359359        if (this->getControllableEntity() == NULL || this->getControllableEntity()->getPlayer() == NULL )
    360         {   orxout()<<this->getControllableEntity()<< " in tick"<<endl; return;}
     360        {
     361            //orxout()<< this->getControllableEntity() << " in tick"<<endl;
     362            return;
     363        }
    361364        //FOR virtual Checkpoints
    362365        if(nextRaceCheckpoint_->getCheckpointIndex() < 0)
     
    374377        {//Checkpoint erreicht
    375378
    376             currentRaceCheckpoint_=nextRaceCheckpoint_;
     379            currentRaceCheckpoint_ = nextRaceCheckpoint_;
    377380            OrxAssert(nextRaceCheckpoint_, "next race checkpoint undefined");
    378381            nextRaceCheckpoint_ = nextPointFind(nextRaceCheckpoint_);
    379             lastPositionSpaceship=this->getControllableEntity()->getPosition();
     382            lastPositionSpaceship = this->getControllableEntity()->getPosition();
    380383            //orxout()<< "CP "<< currentRaceCheckpoint_->getCheckpointIndex()<<" chanched to: "<< nextRaceCheckpoint_->getCheckpointIndex()<<endl;
    381384        }
     
    383386        {
    384387            nextRaceCheckpoint_ = adjustNextPoint();
    385             lastPositionSpaceship=this->getControllableEntity()->getPosition();
     388            lastPositionSpaceship = this->getControllableEntity()->getPosition();
    386389        }
    387390
    388391        // Abmessung fuer MINDISTANCE gut;
    389392
    390         else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt< MINDISTANCE )
    391         {
    392             this->moveToPosition(Vector3(rnd()*100,rnd()*100,rnd()*100));
     393        else if((lastPositionSpaceship - this->getControllableEntity()->getPosition()).length()/dt < MINDISTANCE )
     394        {
     395            this->moveToPosition(Vector3(rnd()*100, rnd()*100, rnd()*100));
    393396            this->spin();
    394397            //orxout(user_status) << "Mindistance reached" << std::endl;
     
    396399        }
    397400        //orxout(user_status) << "dt= " << dt << ";  distance= " << (lastPositionSpaceship-this->getControllableEntity()->getPosition()).length() <<std::endl;
    398         lastPositionSpaceship=this->getControllableEntity()->getPosition();
     401        lastPositionSpaceship = this->getControllableEntity()->getPosition();
    399402        this->moveToPosition(nextRaceCheckpoint_->getPosition());
    400403    }
     
    403406    bool SpaceRaceController::vergleicheQuader(Vector3 pointToPoint, Vector3 groesse)
    404407    {
    405         if(abs(pointToPoint.x)<groesse.x)
    406         return true;
    407         if(abs(pointToPoint.y)<groesse.y)
    408         return true;
    409         if(abs(pointToPoint.z)<groesse.z)
    410         return true;
     408        if(abs(pointToPoint.x) < groesse.x)
     409            return true;
     410        if(abs(pointToPoint.y) < groesse.y)
     411            return true;
     412        if(abs(pointToPoint.z) < groesse.z)
     413            return true;
     414        return false;
    411415
    412416    }
     
    415419    {
    416420
    417         Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector
    418         Vector3 centerCP1=racepoint1->getPosition();
     421        Vector3 cP1ToCP2 = (racepoint2->getPosition() - racepoint1->getPosition()) / (racepoint2->getPosition() - racepoint1->getPosition()).length(); //unit Vector
     422        Vector3 centerCP1 = racepoint1->getPosition();
    419423        btVector3 positionObject;
    420424        btScalar radiusObject;
    421425
    422         for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it!=allObjects.end(); ++it)
    423         {
    424             for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++)
     426        for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it != allObjects.end(); ++it)
     427        {
     428            for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++)
    425429            {
    426430                btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
     
    441445    }
    442446
    443     void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2,std::vector<StaticEntity*> allObjects)
     447    /*void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2, std::vector<StaticEntity*> allObjects)
    444448    {
    445449        Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector
     
    448452        btScalar radiusObject;
    449453
    450         for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it!=allObjects.end(); ++it)
    451         {
    452             for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++)
     454        for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it != allObjects.end(); ++it)
     455        {
     456            for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++)
    453457            {
    454458                btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
     
    458462                currentShape->getBoundingSphere(positionObject,radiusObject);
    459463                Vector3 positionObjectNonBT(positionObject.x(), positionObject.y(), positionObject.z());
    460                 if((powf((cP1ToCP2.dotProduct(centerCP1-positionObjectNonBT)),2)-(centerCP1-positionObjectNonBT).dotProduct(centerCP1-positionObjectNonBT)+powf(radiusObject, 2))>0)
    461                 {
    462                     Vector3 zufall;
    463                     Vector3 objectmiddle=positionObjectNonBT;
    464                     do
    465                     {
     464                                Vector3 norm_r_CP = cP1ToCP2.crossProduct(centerCP1-positionObjectNonBT);
     465
     466                                if(norm_r_CP.length() == 0){
     467                                        Vector3 zufall;
     468                    do{
    466469                        zufall=Vector3(rnd(),rnd(),rnd());//random
    467                     }while((zufall.crossProduct(objectmiddle-racepoint1->getPosition())).length()==0);
    468 
    469                     Vector3 normalvec=zufall.crossProduct(objectmiddle-racepoint1->getPosition());
    470                     // a'/b'=a/b => a' =b'*a/b
    471                     float laengeNormalvec=(objectmiddle-racepoint1->getPosition()).length()/sqrt((objectmiddle-racepoint1->getPosition()).squaredLength()-radiusObject*radiusObject)*radiusObject;
    472                     RaceCheckPoint* newVirtualCheckpoint=addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), objectmiddle+normalvec/normalvec.length()*laengeNormalvec);
    473                     //placeVirtualCheckpoints(newVirtualCheckpoint, racepoint2);
    474                     return;
    475                 }
    476 
    477             }
    478         }
    479 
    480     }
    481 
    482     void SpaceRaceController::placeVirtualCheckpoints(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2)
     470                    }while((zufall.crossProduct(cP1ToCP2)).length() == 0);
     471                                        norm_r_CP=zufall.crossProduct(cP1ToCP2);
     472                                }
     473                                Vector3 VecToVCP = norm_r_CP.crossProduct(cP1ToCP2);
     474                                float distanzToCP1 = sqrt(powf(radiusObject,4)/(powf((centerCP1-positionObjectNonBT).length(), 2)-powf(radiusObject,2))+powf(radiusObject,2));
     475                                float distanzToCP2 = sqrt(powf(radiusObject,4)/(powf((racepoint2->getPosition()-positionObjectNonBT).length(), 2)-powf(radiusObject,2))+powf(radiusObject,2));
     476                float distanz = std::max(distanzToCP1,distanzToCP2);
     477                                //float distanz = 0.0f; //TEMPORARY
     478                                Vector3 newCheckpointPositionPos = positionObjectNonBT+(distanz*VecToVCP)/VecToVCP.length();
     479                                Vector3 newCheckpointPositionNeg = positionObjectNonBT-(distanz*VecToVCP)/VecToVCP.length();
     480                                if((newCheckpointPositionPos - centerCP1).length() + (newCheckpointPositionPos - (centerCP1+cP1ToCP2)).length() < (newCheckpointPositionNeg - centerCP1).length() + (newCheckpointPositionNeg - (centerCP1+cP1ToCP2)).length() )
     481                                {
     482                                        RaceCheckPoint* newVirtualCheckpoint = addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), newCheckpointPositionPos);
     483                                }
     484                                else
     485                                {
     486                                        RaceCheckPoint* newVirtualCheckpoint = addVirtualCheckPoint(racepoint1,racepoint2->getCheckpointIndex(), newCheckpointPositionNeg);
     487                                }
     488                                return;
     489            }
     490        }
     491
     492    }*/
     493
     494    /*void SpaceRaceController::placeVirtualCheckpoints(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2)
    483495    {
    484496        Vector3 point1 = racepoint1->getPosition();
     
    489501        {
    490502
    491             if (dynamic_cast<RaceCheckPoint*>(*it)!=NULL)
    492             {   continue;} // does not work jet
     503            if (dynamic_cast<RaceCheckPoint*>(*it) != NULL)
     504            {
     505                continue;
     506            } // does not work jet
    493507
    494508            problematicObjects.insert(problematicObjects.end(), *it);
     
    589603        //        }
    590604
    591     }
     605    }*/
    592606}
  • code/branches/presentationHS12/src/modules/gametypes/SpaceRaceController.h

    r9513 r9523  
    3232#include "gametypes/Gametype.h"
    3333#include "gametypes/RaceCheckPoint.h"
     34#include "util/Math.h"
    3435
    3536namespace orxonox
     
    5758            // same as SpaceRaceManager, but needed to add virtuell Checkpoints ( Checkpoints which don't exist but needed to avoid collisions with big Objects)
    5859            RaceCheckPoint* findCheckpoint(int index) const;
    59             RaceCheckPoint
    60                     * addVirtualCheckPoint(RaceCheckPoint*, int , Vector3);
    61             void placeVirtualCheckpoints(RaceCheckPoint*, RaceCheckPoint*);
     60            //RaceCheckPoint * addVirtualCheckPoint(RaceCheckPoint*, int , Vector3);
     61            //void placeVirtualCheckpoints(RaceCheckPoint*, RaceCheckPoint*);
    6262            bool vergleicheQuader(Vector3, Vector3);
    6363            bool directLinePossible(RaceCheckPoint*, RaceCheckPoint*, std::vector<StaticEntity*>);
    64             void computeVirtualCheckpoint(RaceCheckPoint*, RaceCheckPoint*, std::vector<StaticEntity*>);
     64            //void computeVirtualCheckpoint(RaceCheckPoint*, RaceCheckPoint*, std::vector<StaticEntity*>);
    6565
    6666        public:
  • code/branches/presentationHS12/src/modules/gametypes/SpaceRaceManager.cc

    r9348 r9523  
    3838#include "util/Math.h"
    3939
    40 
    41 
    4240namespace orxonox
    4341{
    4442    CreateFactory(SpaceRaceManager);
    4543
    46     SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
     44    SpaceRaceManager::SpaceRaceManager(BaseObject* creator) :
     45        BaseObject(creator)
    4746    {
    4847        RegisterObject(SpaceRaceManager);
    49 
     48        this->race_ = orxonox_cast<SpaceRace*>(this->getGametype().get());
     49        assert(race_);
     50        //amountOfPlayers=(race_->getPlayers()).size();
    5051        this->firstcheckpointvisible_ = false;
    5152    }
     
    5455    {
    5556        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    56             this->checkpoints_[i]->destroy();
     57        this->checkpoints_[i]->destroy();
    5758    }
    5859
     
    6162        SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
    6263
    63         XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
     64        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint, xmlelement, mode);
    6465    }
    6566
     
    6768    {
    6869        SUPER(SpaceRaceManager,tick,dt);
     70
     71        this->players_ = this->race_->getPlayers();
    6972
    7073        if (this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
     
    7477        }
    7578
    76         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     79        for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)
    7780        {
    78             if (this->checkpoints_[i]->getPlayer() != NULL)
    79                 this->checkpointReached(this->checkpoints_[i], this->checkpoints_[i]->getPlayer());
     81
     82            for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     83            {
     84                if (this->checkpoints_[i]->playerWasHere(it->first)){
     85                this->checkpointReached(this->checkpoints_[i], it->first /*this->checkpoints_[i]->getPlayer()*/);
     86                }
     87            }
    8088        }
     89
    8190    }
    8291
     
    8998    {
    9099        if (index < this->checkpoints_.size())
    91             return this->checkpoints_[index];
     100        return this->checkpoints_[index];
    92101        else
    93             return 0;
     102        return 0;
     103    }
     104
     105    std::vector<RaceCheckPoint*> SpaceRaceManager::getAllCheckpoints()
     106    {
     107        return checkpoints_;
    94108    }
    95109
    96110    /**
    97         @brief Returns the checkpoint with the given checkpoint-index (@see RaceCheckPoint::getCheckpointIndex).
    98     */
     111     @brief Returns the checkpoint with the given checkpoint-index (@see RaceCheckPoint::getCheckpointIndex).
     112     */
    99113    RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const
    100114    {
    101115        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    102             if (this->checkpoints_[i]->getCheckpointIndex() == index)
    103                 return this->checkpoints_[i];
     116        if (this->checkpoints_[i]->getCheckpointIndex() == index)
     117        return this->checkpoints_[i];
    104118        return 0;
    105119    }
     
    107121    bool SpaceRaceManager::reachedValidCheckpoint(RaceCheckPoint* oldCheckpoint, RaceCheckPoint* newCheckpoint, PlayerInfo* player) const
    108122    {
    109         if (oldCheckpoint)
     123        if (oldCheckpoint != NULL)
    110124        {
    111125            // the player already visited an old checkpoint; see which checkpoints are possible now
    112126            const std::set<int>& possibleCheckpoints = oldCheckpoint->getNextCheckpoints();
    113127            for (std::set<int>::const_iterator it = possibleCheckpoints.begin(); it != possibleCheckpoints.end(); ++it)
    114                 if (this->findCheckpoint(*it) == newCheckpoint)
    115                     return true;
     128            if (this->findCheckpoint(*it) == newCheckpoint)
     129            return true;
    116130            return false;
    117131        }
     
    128142        assert(gametype);
    129143        if (!gametype)
    130             return;
     144        return;
    131145
    132         RaceCheckPoint* oldCheckpoint = gametype->getCheckpointReached(player);
     146        RaceCheckPoint* oldCheckpoint = gametype->getCheckpointReached(player); // returns the last from player reached checkpoint
    133147
    134148        if (this->reachedValidCheckpoint(oldCheckpoint, newCheckpoint, player))
     
    152166                // adjust the radarvisibility
    153167                gametype->newCheckpointReached(newCheckpoint, player);
    154                 this->updateRadarVisibility(oldCheckpoint, newCheckpoint);
     168                if(player->isHumanPlayer())
     169                    this->updateRadarVisibility(oldCheckpoint, newCheckpoint);
    155170            }
    156171        }
    157172
    158         newCheckpoint->resetPlayer();
     173        // newCheckpoint->resetPlayer(); loescht playerpointer TODO: check if problems occur
    159174    }
    160175
     
    165180            const std::set<int>& oldVisible = oldCheckpoint->getNextCheckpoints();
    166181            for (std::set<int>::const_iterator it = oldVisible.begin(); it != oldVisible.end(); ++it)
    167                 this->findCheckpoint(*it)->setRadarVisibility(false);
     182            this->findCheckpoint(*it)->setRadarVisibility(false);
    168183        }
    169184
     
    174189            const std::set<int>& newVisible = newCheckpoint->getNextCheckpoints();
    175190            for (std::set<int>::const_iterator it = newVisible.begin(); it != newVisible.end(); ++it)
    176                 this->findCheckpoint(*it)->setRadarVisibility(true);
     191            this->findCheckpoint(*it)->setRadarVisibility(true);
    177192        }
    178193    }
  • code/branches/presentationHS12/src/modules/gametypes/SpaceRaceManager.h

    r9348 r9523  
    6767            void checkpointReached(RaceCheckPoint* newCheckpoint, PlayerInfo* player);
    6868
     69            std::vector<RaceCheckPoint*> getAllCheckpoints();
     70
    6971            void tick(float dt);
    7072
     
    7678            std::vector<RaceCheckPoint*> checkpoints_;
    7779            bool firstcheckpointvisible_; ///< true if the first check point is visible.
     80            SpaceRace* race_; // needed to get the players
     81            //int amountOfPlayers;
     82            std::map<PlayerInfo*, Player> players_;
    7883    };
    7984}
Note: See TracChangeset for help on using the changeset viewer.