[Orxonox-commit 3940] r8614 - in code/branches/presentation: . data/levels src/orxonox/graphics src/orxonox/worldentities

dafrick at orxonox.net dafrick at orxonox.net
Thu May 26 17:40:16 CEST 2011


Author: dafrick
Date: 2011-05-26 17:40:16 +0200 (Thu, 26 May 2011)
New Revision: 8614

Modified:
   code/branches/presentation/
   code/branches/presentation/data/levels/myTestLevel.oxw
   code/branches/presentation/src/orxonox/graphics/Billboard.cc
   code/branches/presentation/src/orxonox/graphics/Billboard.h
   code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.cc
   code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.h
Log:
Merging spaceboundaries2 branch into presentation branch.



Property changes on: code/branches/presentation
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/ai:6592-7033
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/steering:5949-6091,8140-8595
/code/branches/tetris:8100-8563
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
   + /code/branches/ai:6592-7033
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/steering:5949-6091,8140-8595
/code/branches/tetris:8100-8563
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890

Modified: code/branches/presentation/data/levels/myTestLevel.oxw
===================================================================
--- code/branches/presentation/data/levels/myTestLevel.oxw	2011-05-26 15:23:31 UTC (rev 8613)
+++ code/branches/presentation/data/levels/myTestLevel.oxw	2011-05-26 15:40:16 UTC (rev 8614)
@@ -29,10 +29,12 @@
   >
 
     <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"/>
-    <SpawnPoint team=0 position="0,0,0" lookat="2,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+    <SpawnPoint team=0 position="0,0,0" direction="1,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
-    <SpaceBoundaries warnDistance="1" maxDistance="200" showDistance="100" healthDecrease="0.1" position="0,0,0"/>
+    <SpaceBoundaries warnDistance="1" maxDistance="200" showDistance="100" reactionMode="0" healthDecrease="0.9" position="0,0,0"/>
     
+    <Billboard position="0,0,0" colour="1.0,1.0,1.0" material="Flares/backlightflare" scale=1 />
+    
   </Scene>
 </Level>
 

Modified: code/branches/presentation/src/orxonox/graphics/Billboard.cc
===================================================================
--- code/branches/presentation/src/orxonox/graphics/Billboard.cc	2011-05-26 15:23:31 UTC (rev 8613)
+++ code/branches/presentation/src/orxonox/graphics/Billboard.cc	2011-05-26 15:40:16 UTC (rev 8614)
@@ -22,6 +22,7 @@
  *   Author:
  *      Fabian 'x3n' Landau
  *   Co-authors:
+ *      Maurus Kaufmann
  *      ...
  *
  */
@@ -29,7 +30,6 @@
 #include "Billboard.h"
 
 #include "OgreBillboard.h"
-#include "OgreBillboardSet.h"
 
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
@@ -45,7 +45,7 @@
         RegisterObject(Billboard);
 
         this->colour_ = ColourValue::White;
-        //this->rotation_ = 0;
+        this->rotation_ = 0;
 
         this->registerVariables();
     }
@@ -65,14 +65,14 @@
 
         XMLPortParam(Billboard, "material", setMaterial, getMaterial, xmlelement, mode);
         XMLPortParam(Billboard, "colour",   setColour,   getColour,   xmlelement, mode).defaultValues(ColourValue::White);
-        //XMLPortParam(Billboard, "rotation", setRotation, getRotation, xmlelement, mode).defaultValues(0);
+        XMLPortParam(Billboard, "rotation", setRotation, getRotation, xmlelement, mode).defaultValues(0);
     }
 
     void Billboard::registerVariables()
     {
         registerVariable(this->material_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
         registerVariable(this->colour_,   VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
-        //registerVariable(this->rotation_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
+        registerVariable(this->rotation_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
     }
 
     void Billboard::changedMaterial()
@@ -88,7 +88,7 @@
                 if (this->billboard_.getBillboardSet())
                      this->attachOgreObject(this->billboard_.getBillboardSet());
                 this->billboard_.setVisible(this->isVisible());
-                //this->changedRotation();
+                this->changedRotation();
             }
         }
         else
@@ -113,7 +113,7 @@
             this->billboard_.setColour(this->colour_);
     }
 
-/*
+
     void Billboard::changedRotation()
     {
         if (this->billboard_.getBillboardSet())
@@ -127,12 +127,48 @@
             }
         }
     }
-*/
 
+
     void Billboard::changedVisibility()
     {
         SUPER(Billboard, changedVisibility);
 
         this->billboard_.setVisible(this->isVisible());
     }
+    
+    void Billboard::setBillboardType(Ogre::BillboardType bbt)
+    {
+        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
+        if( bSet != NULL )
+        {
+            bSet->setBillboardType(bbt);
+        }
+    }
+    
+    void Billboard::setCommonDirection(Vector3 vec)
+    {
+        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
+        if( bSet != NULL )
+        {
+            bSet->setCommonDirection( vec );
+        }
+    }
+            
+    void Billboard::setCommonUpVector(Vector3 vec)
+    {
+        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
+        if( bSet != NULL )
+        {
+            bSet->setCommonUpVector( vec );
+        }
+    }
+    
+    void Billboard::setDefaultDimensions(float width, float height)
+    {
+        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
+        if( bSet != NULL )
+        {
+            bSet->setDefaultDimensions(width, height);
+        }
+    }
 }

Modified: code/branches/presentation/src/orxonox/graphics/Billboard.h
===================================================================
--- code/branches/presentation/src/orxonox/graphics/Billboard.h	2011-05-26 15:23:31 UTC (rev 8613)
+++ code/branches/presentation/src/orxonox/graphics/Billboard.h	2011-05-26 15:40:16 UTC (rev 8614)
@@ -22,6 +22,7 @@
  *   Author:
  *      Fabian 'x3n' Landau
  *   Co-authors:
+ *      Maurus Kaufmann
  *      ...
  *
  */
@@ -31,6 +32,8 @@
 
 #include "OrxonoxPrereqs.h"
 
+#include "OgreBillboardSet.h"
+
 #include "util/Math.h"
 #include "tools/BillboardSet.h"
 #include "interfaces/TeamColourable.h"
@@ -61,16 +64,25 @@
             inline const ColourValue& getColour() const
                 { return this->colour_; }
 
-/*
+
             inline void setRotation(const Radian& rotation)
                 { this->rotation_ = rotation; this->changedRotation(); }
             inline const Radian& getRotation() const
                 { return this->rotation_; }
-*/
 
+
             virtual void setTeamColour(const ColourValue& colour)
                 { this->setColour(colour); }
+                
+            void setBillboardType(Ogre::BillboardType bbt);
+            
+            void setCommonDirection(Vector3 vec); //!< normalised Vector vec as argument
+            
+            void setCommonUpVector(Vector3 vec); //!< normalised Vector vec as argument
+            
+            void setDefaultDimensions(float width, float height);
 
+
         protected:
             inline BillboardSet& getBillboardSet()
                 { return this->billboard_; }
@@ -80,12 +92,12 @@
         private:
             void registerVariables();
             void changedMaterial();
-            //void changedRotation();
+            void changedRotation();
 
             BillboardSet billboard_;
             std::string material_;
             ColourValue colour_;
-            //Radian rotation_;
+            Radian rotation_;
     };
 }
 

Modified: code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.cc	2011-05-26 15:23:31 UTC (rev 8613)
+++ code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.cc	2011-05-26 15:40:16 UTC (rev 8614)
@@ -36,34 +36,26 @@
 #include "infos/PlayerInfo.h"
 #include "interfaces/RadarViewable.h"
 #include "graphics/Billboard.h"
+#include <OgreBillboardSet.h>
 
+
 namespace orxonox
 {
     CreateFactory(SpaceBoundaries);
 
     SpaceBoundaries::SpaceBoundaries(BaseObject* creator) : StaticEntity(creator)
     {
-        /* Standardwerte, die zum Tragen kommen,
-         * falls im XML-File keine Werte spezifiziert wurden. */
+        RegisterObject(SpaceBoundaries);
+
         this->setMaxDistance(3000);
-        this->setWarnDistance(2000);
-        this->setShowDistance(2500);
-        this->setHealthDecrease(1);
+        this->setWarnDistance(this->getMaxDistance());
+        this->setShowDistance(this->getMaxDistance());
         this->setReaction(0);
-        
-        RegisterObject(SpaceBoundaries);
-        
-        // Show Boundaries on the radar.
-        this->centerRadar_ = new RadarViewable(this, this);
-        this->centerRadar_->setRadarObjectShape(RadarViewable::Dot);
-        this->centerRadar_->setRadarVisibility(false);
     }
     SpaceBoundaries::~SpaceBoundaries()
     {
         if (this->isInitialized())
         {
-            delete this->centerRadar_;
-        
             this->pawnsIn_.clear();
         
             for( std::vector<billboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)
@@ -83,9 +75,20 @@
         for(ObjectListIterator<Pawn> current = ObjectList<Pawn>::begin(); current != ObjectList<Pawn>::end(); ++current)
         {
             Pawn* currentPawn = *current;
-            float distance = this->computeDistance(currentPawn);
-            if(distance <= this->maxDistance_)
+            if( this->reaction_ == 0 )
             {
+                float distance = this->computeDistance(currentPawn);
+                if(distance <= this->maxDistance_)
+                {
+                    pawnsIn_.push_back(currentPawn);
+                }
+            } else if (this->reaction_ == 2) {
+                float distance = this->computeDistance(currentPawn);
+                if(distance >= this->maxDistance_)
+                {
+                    pawnsIn_.push_back(currentPawn);
+                }
+            } else {
                 pawnsIn_.push_back(currentPawn);
             }
         }
@@ -104,15 +107,20 @@
         if( current == this->billboards_.end() )
         {
             Billboard *tmp = new Billboard(this);
+            tmp->setPosition(position);
             this->setBillboardOptions( tmp );
-            tmp->setPosition(position);
+            Vector3 normalisedVec = (position - this->getPosition()).normalisedCopy(); /* Vektor von Kugelmitte nach aussen */
+            tmp->setCommonDirection ( -1.0 * normalisedVec );
+            tmp->setCommonUpVector( Vector3::UNIT_Z );
             billboardAdministration tmp2 = { true, tmp };
             this->billboards_.push_back( tmp2 );
-            
         } else {
             current->billy->setPosition(position);
             current->billy->setVisible(true);
             current->usedYet = true;
+            Vector3 normalisedVec = (position - this->getPosition()).normalisedCopy(); /* Vektor von Kugelmitte nach aussen */
+            current->billy->setCommonDirection ( -1.0 * normalisedVec );
+            current->billy->setCommonUpVector( Vector3::UNIT_Z );
         }
     }
     
@@ -120,7 +128,9 @@
     {
         if(billy != NULL)
         {
-            billy->setMaterial("Shield");
+            billy->setMaterial("Grid");
+            billy->setBillboardType(Ogre::BBT_PERPENDICULAR_COMMON);
+            billy->setDefaultDimensions(150, 150);
             billy->setVisible(true);
         }
     }
@@ -185,6 +195,7 @@
 
         XMLPortParam(SpaceBoundaries, "maxDistance", setMaxDistance, getMaxDistance, xmlelement, mode);
         XMLPortParam(SpaceBoundaries, "warnDistance", setWarnDistance, getWarnDistance, xmlelement, mode);
+        XMLPortParam(SpaceBoundaries, "showDistance", setShowDistance, getShowDistance, xmlelement, mode);
         XMLPortParam(SpaceBoundaries, "healthDecrease", setHealthDecrease, getHealthDecrease, xmlelement, mode);
         XMLPortParam(SpaceBoundaries, "reactionMode", setReaction, getReaction, xmlelement, mode);
     }
@@ -193,7 +204,6 @@
     {
         this->checkWhoIsIn();
         this->removeAllBillboards();
-        //COUT(0) << "Groesse der Liste: " << (int) pawnsIn_.size() << std::endl;
         
         float distance;
         bool humanItem;
@@ -204,33 +214,35 @@
             {
                 distance = this->computeDistance(currentPawn);
                 humanItem = this->isHumanPlayer(currentPawn);
-                //COUT(0) << "Distanz:" << distance << std::endl; // message for debugging
-                if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an!
+                COUT(5) << "Distance:" << distance << std::endl; // message for debugging
+                if(distance > this->warnDistance_ && distance < this->maxDistance_) // Display warning
                 {
-                    //COUT(0) << "You are near by the boundaries!" << std::endl; // message for debugging
                     if(humanItem)
                     {
-                        //COUT(0) << "humanItem ist true" << std::endl;
-                        this->displayWarning("Attention! You are near by the boundaries!");
+                        this->displayWarning("Attention! You are close to the boundary!");
                     }
                 }
-                if( (this->maxDistance_ - distance) < this->showDistance_ )
+                if(/* humanItem &&*/ abs(this->maxDistance_ - distance) < this->showDistance_ )
                 {
-                    this->displayBoundaries(currentPawn); // Zeige Grenze an!
+                    this->displayBoundaries(currentPawn); // Show the boundary
                 }
                 if(distance > this->maxDistance_ && (this->reaction_ == 1) )
                 {
                     if( humanItem )
                     {
-                        //COUT(0) << "Health should be decreasing!" << std::endl;
+                        COUT(5) << "Health should be decreasing!" << std::endl;
                         this->displayWarning("You are out of the area now!");
                     }
                     currentPawn->removeHealth( (distance - this->maxDistance_) * this->healthDecrease_);
                 }
-                if( (this->reaction_ == 0) && (distance + 100 > this->maxDistance_)) // Annahme: Ein Pawn kann von einem Tick bis zum nächsten nicht mehr als 100 Distanzeinheiten zurücklegen.
+                if( (this->reaction_ == 0) && (distance + 100 > this->maxDistance_)) // Exception: A Pawn can't move more than 100 units per tick.
                 {
                     this->conditionalBounceBack(currentPawn, distance, dt);
                 }
+                if( this->reaction_ == 2 && (distance - 100 < this->maxDistance_) )
+                {
+                    this->conditionalBounceBack(currentPawn, distance, dt);
+                }
             }
         }
     }
@@ -248,7 +260,7 @@
     
     void SpaceBoundaries::displayWarning(const std::string warnText)
     {   
-        
+        // TODO
     }
     
     void SpaceBoundaries::displayBoundaries(Pawn *item)
@@ -269,22 +281,32 @@
         Vector3 velocity = item->getVelocity();
         float normalSpeed = item->getVelocity().dotProduct(normal);
         
-        /* Checke, ob das Pawn innerhalb des nächsten Ticks, das erlaubte Gebiet verlassen würde.
-           Falls ja: Spicke es zurück. */
-        if( currentDistance + normalSpeed * dt > this->maxDistance_ )
+        /* Check, whether the Pawn would leave the boundary in the next tick, if so send it back. */
+        if( this->reaction_ == 0 && currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure"
         {
-            float dampingFactor = 0.5;
-            velocity = velocity.reflect(normal);
-            Vector3 acceleration = item->getAcceleration();
-            acceleration = acceleration.reflect(normal);
-            
-            item->lookAt( velocity + this->getPosition() );
-            
-            item->setAcceleration(acceleration * dampingFactor);
-            item->setVelocity(velocity * dampingFactor);
+            bounceBack(item, &normal, &velocity);
+        } else if (this->reaction_ == 2 && currentDistance - normalSpeed * dt < this->maxDistance_ + 10 ) // 10: "security measure"
+        {
+            normal = normal * (-1);
+            bounceBack(item, &normal, &velocity);
         }
     }
     
+    void SpaceBoundaries::bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity)
+    {
+        float dampingFactor = 0.5;
+        *velocity = velocity->reflect(*normal);
+        Vector3 acceleration = item->getAcceleration();
+        acceleration = acceleration.reflect(*normal);
+        
+        item->lookAt( *velocity + this->getPosition() );
+        
+        item->setAcceleration(acceleration * dampingFactor);
+        item->setVelocity(*velocity * dampingFactor);
+        
+        item->setPosition( item->getPosition() - *normal * 10 ); // Set the position of the Pawn to be well inside the boundary.
+    }
+    
     bool SpaceBoundaries::isHumanPlayer(Pawn *item)
     {
         if(item != NULL)

Modified: code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.h	2011-05-26 15:23:31 UTC (rev 8613)
+++ code/branches/presentation/src/orxonox/worldentities/SpaceBoundaries.h	2011-05-26 15:40:16 UTC (rev 8614)
@@ -25,15 +25,6 @@
  *      ...
  *
  */
- 
- /* TODO:   - Textmessages und Billboards sollen teils nur bei einem humanPlayer angezeigt werden, nicht bei allen (vgl. Netzwerk-Spiel mit mehreren humanPlayers)
-                beachte hierzu folgende statische Funktion: 'static unsigned int  Host::getPlayerID()'
-                (file:///home/kmaurus/orxonox/spaceBoundaries/build/doc/api/html/classorxonox_1_1_host.html#9c1e3b39e3b42e467dfbf42902911ce2)
-                
-            - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h')
-            
-            - Wiki-SpaceBoundaries-Eintrag aktualisieren
- */
 
 #ifndef _SpaceBoundaries_H__
 #define _SpaceBoundaries_H__
@@ -48,7 +39,6 @@
 
 #include <string>
 #include <list>
-#include <map>
 #include <vector>
 
 namespace orxonox
@@ -57,16 +47,30 @@
 /**
 @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball).
 
-       Five attributes can/should be defined in the XML-File:
+       Some attributes can/should be defined in the XML-File:
+       - 'position' : absolute position of the object of SpaceBoundaries in the level (usually 0,0,0) 
+       - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).
        - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to
-                          inform the player that he'll soon be leaving the allowed area. 
-       - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).
+                          inform the player that he'll soon be leaving the allowed area. (not implemented yet!)
        - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown. 
-       - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
-                            Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
        - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries.
                             0: Reflect the space ship (default).
                             1: Decrease Health of the space ship after having left the allowed area.
+                            2: Inverted Version of 0. Prohibit to fly INTO a defined area.
+       - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).
+                            Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)
+
+Follow http://www.orxonox.net/wiki/SpaceBoundaries to get some further information.
+
+Examples:
+Two examples how one could include SpaceBoundaries in the XML-File. The first one uses reflection, the second one health decrease.
+ at code
+<SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="0" />
+ at endcode
+
+ at code
+<SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="1" healthDecrease="0.2" />
+ at endcode
 */
 
     class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable
@@ -75,12 +79,6 @@
             SpaceBoundaries(BaseObject* creator);
             ~SpaceBoundaries();
             
-            void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
-            
-            void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.
-            void setBillboardOptions(Billboard *billy);
-            void removeAllBillboards(); //!< Hide all all elements of '*billboard_' and set their attribute 'usedYet' to 0.
-            
             void setMaxDistance(float r);
             float getMaxDistance();
             
@@ -103,26 +101,37 @@
         private:
             struct billboardAdministration{ bool usedYet; Billboard* billy; };
             
+            // Variabeln::
             std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
             
             std::vector<billboardAdministration> billboards_;
         
-            int reaction_; //!< Werte: 0, 1. 0: Reflektion an Boundaries (Standard). 1: Health-Abzug-Modus.
-            float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'.
-            float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst.
-            float showDistance_; //!< Definiert, wann die Grenzen visualisiert werden sollen.
+            int reaction_; //!< Values: 0, 1, 2.
+                           //!< 0: Reflection on boundary (Standard).
+                           //!< 1: Decrease-Health-Mode.
+                           //!< 2: Inverted Version of 0. Prohibit to fly INTO a defined area.
+            float maxDistance_; //!<  Maximum allowed distance.
+            float warnDistance_; //!< Distance in which a warning is displayed.
+            float showDistance_; //!< Distance at which the boundaries are displayed.
             
-            float healthDecrease_; //!< Mass fuer die Anzahl Health-Points, die nach ueberschreiten der Entfernung 'maxDistance_' von 'this->getPosition()' abgezogen werden.
-                                   //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung)
+            float healthDecrease_; //!< Rate of health loss.
             
-            RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar.
+            //RadarViewable* centerRadar_; //!< Representation of the space boundary in the radar.
         
-            float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen.
-            void displayWarning(const std::string warnText);
+            // Funktionen::
+            float computeDistance(WorldEntity *item); //!< Compute distance to center point.
+            void displayWarning(const std::string warnText); //!< TODO: Implement.
             void displayBoundaries(Pawn *item);
             void conditionalBounceBack(Pawn *item, float currentDistance, float dt);
+            void bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity);
             bool isHumanPlayer(Pawn *item);
             
+            void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.
+            
+            void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.
+            void setBillboardOptions(Billboard *billy);
+            void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0.
+            
     };
 }
 




More information about the Orxonox-commit mailing list