[Orxonox-commit 3788] r8468 - in code/branches/spaceboundaries2: data/levels doc/api src/orxonox/worldentities

kmaurus at orxonox.net kmaurus at orxonox.net
Thu May 12 16:36:30 CEST 2011


Author: kmaurus
Date: 2011-05-12 16:36:30 +0200 (Thu, 12 May 2011)
New Revision: 8468

Modified:
   code/branches/spaceboundaries2/data/levels/myTestLevel.oxw
   code/branches/spaceboundaries2/doc/api/Groups.dox
   code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc
   code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.h
Log:
several small improvements

Modified: code/branches/spaceboundaries2/data/levels/myTestLevel.oxw
===================================================================
--- code/branches/spaceboundaries2/data/levels/myTestLevel.oxw	2011-05-12 14:35:25 UTC (rev 8467)
+++ code/branches/spaceboundaries2/data/levels/myTestLevel.oxw	2011-05-12 14:36:30 UTC (rev 8468)
@@ -31,7 +31,7 @@
     <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 />
     
-    <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"/>
     
   </Scene>
 </Level>

Modified: code/branches/spaceboundaries2/doc/api/Groups.dox
===================================================================
--- code/branches/spaceboundaries2/doc/api/Groups.dox	2011-05-12 14:35:25 UTC (rev 8467)
+++ code/branches/spaceboundaries2/doc/api/Groups.dox	2011-05-12 14:36:30 UTC (rev 8468)
@@ -160,3 +160,8 @@
     @defgroup Weapons Weapons
     @ingroup Modules
 */
+
+/**
+    @defgroup SpaceBoundaries Space Boundaries
+    @ingroup Modules
+*/

Modified: code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc
===================================================================
--- code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc	2011-05-12 14:35:25 UTC (rev 8467)
+++ code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc	2011-05-12 14:36:30 UTC (rev 8468)
@@ -46,9 +46,8 @@
         /* Standardwerte, die zum Tragen kommen,
          * falls im XML-File keine Werte spezifiziert wurden. */
         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);
@@ -80,9 +79,14 @@
         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 {
                 pawnsIn_.push_back(currentPawn);
             }
         }
@@ -182,6 +186,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);
     }
@@ -190,7 +195,7 @@
     {
         this->checkWhoIsIn();
         this->removeAllBillboards();
-        COUT(0) << "Groesse der Liste: " << (int) pawnsIn_.size() << std::endl;
+        COUT(4) << "Groesse der Pawn-Liste 'SpaceBoundaries::pawnsIn_': " << (int) pawnsIn_.size() << std::endl;
         
         float distance;
         bool humanItem;
@@ -201,17 +206,16 @@
             {
                 distance = this->computeDistance(currentPawn);
                 humanItem = this->isHumanPlayer(currentPawn);
-                COUT(0) << "Distanz:" << distance << std::endl; // message for debugging
+                COUT(5) << "Distanz:" << distance << std::endl; // message for debugging
                 if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an!
                 {
-                    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!");
+                        COUT(5) << "humanItem ist true" << std::endl;
+                        this->displayWarning("Attention! You are close to the boundary!");
                     }
                 }
-                if( (this->maxDistance_ - distance) < this->showDistance_ )
+                if( humanItem && (this->maxDistance_ - distance) < this->showDistance_ )
                 {
                     this->displayBoundaries(currentPawn); // Zeige Grenze an!
                 }
@@ -219,7 +223,7 @@
                 {
                     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_);
@@ -268,7 +272,7 @@
         
         /* 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_ )
+        if( currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure"
         {
             float dampingFactor = 0.5;
             velocity = velocity.reflect(normal);

Modified: code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.h
===================================================================
--- code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.h	2011-05-12 14:35:25 UTC (rev 8467)
+++ code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.h	2011-05-12 14:36:30 UTC (rev 8468)
@@ -30,9 +30,10 @@
                 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
+                Mich finde ich unter humanPlayer ...
+                
+            - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h') 
+                oder brauche groups-file.
  */
 
 #ifndef _SpaceBoundaries_H__
@@ -57,16 +58,29 @@
 /**
 @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).
        - '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.
+       - '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




More information about the Orxonox-commit mailing list