Changeset 8513 for code/branches/spaceboundaries2/src/orxonox/worldentities
- Timestamp:
- May 19, 2011, 4:16:55 PM (14 years ago)
- Location:
- code/branches/spaceboundaries2/src/orxonox/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc
r8506 r8513 84 84 float distance = this->computeDistance(currentPawn); 85 85 if(distance <= this->maxDistance_) 86 { 87 pawnsIn_.push_back(currentPawn); 88 } 89 } else if (this->reaction_ == 2) { 90 float distance = this->computeDistance(currentPawn); 91 if(distance >= this->maxDistance_) 86 92 { 87 93 pawnsIn_.push_back(currentPawn); … … 122 128 if(billy != NULL) 123 129 { 124 billy->setMaterial(" Shield");130 billy->setMaterial("Grid"); 125 131 billy->setVisible(true); 126 132 } … … 216 222 } 217 223 } 218 if( humanItem &&(this->maxDistance_ - distance) < this->showDistance_ )224 if(/* humanItem &&*/ abs(this->maxDistance_ - distance) < this->showDistance_ ) 219 225 { 220 226 this->displayBoundaries(currentPawn); // Zeige Grenze an! … … 233 239 this->conditionalBounceBack(currentPawn, distance, dt); 234 240 } 241 if( this->reaction_ == 2 && (distance - 100 < this->maxDistance_) ) 242 { 243 this->conditionalBounceBack(currentPawn, distance, dt); 244 } 235 245 } 236 246 } … … 273 283 /* Checke, ob das Pawn innerhalb des nächsten Ticks, das erlaubte Gebiet verlassen würde. 274 284 Falls ja: Spicke es zurück. */ 275 if( currentDistance + normalSpeed * dt > this->maxDistance_ - 20 ) // -20: "security measure" 276 { 277 float dampingFactor = 0.5; 278 velocity = velocity.reflect(normal); 279 Vector3 acceleration = item->getAcceleration(); 280 acceleration = acceleration.reflect(normal); 281 282 item->lookAt( velocity + this->getPosition() ); 283 284 item->setAcceleration(acceleration * dampingFactor); 285 item->setVelocity(velocity * dampingFactor); 286 287 item->setPosition( item->getPosition() - normal * 10 ); 288 } 285 if( this->reaction_ == 0 && currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure" 286 { 287 bounceBack(item, &normal, &velocity); 288 } else if (this->reaction_ == 2 && currentDistance - normalSpeed * dt < this->maxDistance_ + 10 ) // 10: "security measure" 289 { 290 normal = normal * (-1); 291 bounceBack(item, &normal, &velocity); 292 } 293 } 294 295 void SpaceBoundaries::bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity) 296 { 297 float dampingFactor = 0.5; 298 *velocity = velocity->reflect(*normal); 299 Vector3 acceleration = item->getAcceleration(); 300 acceleration = acceleration.reflect(*normal); 301 302 item->lookAt( *velocity + this->getPosition() ); 303 304 item->setAcceleration(acceleration * dampingFactor); 305 item->setVelocity(*velocity * dampingFactor); 306 307 item->setPosition( item->getPosition() - *normal * 10 ); // Setze das SpaceShip noch etwas von der Grenze weg. 289 308 } 290 309 -
code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.h
r8506 r8513 27 27 */ 28 28 29 /* TODO: - Textmessages und Billboards sollen teils nur bei einem humanPlayer angezeigt werden, nicht bei allen (vgl. Netzwerk-Spiel mit mehreren humanPlayers) 29 /* TODO: - Bei Reaction_ == 2 ist die Reflexion noch nicht ganz so top!! Vielleicht auch so belassen, ist ja nicht unbedingt schlecht. 30 31 - Textmessages und Billboards sollen teils nur bei einem humanPlayer angezeigt werden, nicht bei allen (vgl. Netzwerk-Spiel mit mehreren humanPlayers) 30 32 beachte hierzu folgende statische Funktion: 'static unsigned int Host::getPlayerID()' 31 33 (file:///home/kmaurus/orxonox/spaceBoundaries/build/doc/api/html/classorxonox_1_1_host.html#9c1e3b39e3b42e467dfbf42902911ce2) … … 67 69 0: Reflect the space ship (default). 68 70 1: Decrease Health of the space ship after having left the allowed area. 71 2: Inverted Version of 0. Prohibit to fly INTO a defined area. 69 72 - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0). 70 73 Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease) … … 88 91 SpaceBoundaries(BaseObject* creator); 89 92 ~SpaceBoundaries(); 90 91 void checkWhoIsIn(); //!< Update the list 'pawnsIn_'.92 93 void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'.94 void setBillboardOptions(Billboard *billy);95 void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0.96 93 97 94 void setMaxDistance(float r); … … 117 114 struct billboardAdministration{ bool usedYet; Billboard* billy; }; 118 115 116 // Variabeln:: 119 117 std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle. 120 118 121 119 std::vector<billboardAdministration> billboards_; 122 120 123 int reaction_; //!< Werte: 0, 1. 0: Reflektion an Boundaries (Standard). 1: Health-Abzug-Modus. 121 int reaction_; //!< Werte: 0, 1, 2. 122 //!< 0: Reflektion an Boundaries (Standard). 123 //!< 1: Health-Abzug-Modus. 124 //!< 2: Invertierte Version von 0. Verbiete es, in ein Gebiet hinein zu fliegen. 124 125 float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'. 125 126 float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst. … … 129 130 //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung) 130 131 132 131 133 RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar. 132 134 135 136 // Funktionen:: 133 137 float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen. 134 138 void displayWarning(const std::string warnText); 135 139 void displayBoundaries(Pawn *item); 136 140 void conditionalBounceBack(Pawn *item, float currentDistance, float dt); 141 void bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity); 137 142 bool isHumanPlayer(Pawn *item); 143 144 void checkWhoIsIn(); //!< Update the list 'pawnsIn_'. 145 146 void positionBillboard(const Vector3 position); //!< Display a Billboard at the position 'position'. 147 void setBillboardOptions(Billboard *billy); 148 void removeAllBillboards(); //!< Hide all elements of '*billboard_' and set their attribute 'usedYet' to 0. 138 149 139 150 };
Note: See TracChangeset
for help on using the changeset viewer.