Changeset 8767 for code/trunk/src/modules/objects/SpaceBoundaries.cc
- Timestamp:
- Jul 20, 2011, 11:27:45 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/objects/SpaceBoundaries.cc
r8706 r8767 58 58 { 59 59 this->pawnsIn_.clear(); 60 60 61 61 for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++) 62 62 { … … 69 69 } 70 70 } 71 71 72 72 void SpaceBoundaries::checkWhoIsIn() 73 73 { … … 94 94 } 95 95 } 96 96 97 97 void SpaceBoundaries::positionBillboard(const Vector3& position, float alpha) 98 98 { … … 124 124 this->billboards_[current].billy->setCommonUpVector(upVector); 125 125 } 126 126 127 127 void SpaceBoundaries::setBillboardOptions(Billboard *billy) 128 128 { … … 135 135 } 136 136 } 137 137 138 138 void SpaceBoundaries::removeAllBillboards() 139 139 { … … 144 144 } 145 145 } 146 146 147 147 void SpaceBoundaries::setMaxDistance(float r) 148 148 { … … 153 153 return this->maxDistance_; 154 154 } 155 155 156 156 void SpaceBoundaries::setWarnDistance(float r) 157 157 { … … 162 162 return this->warnDistance_; 163 163 } 164 164 165 165 void SpaceBoundaries::setShowDistance(float r) 166 166 { … … 171 171 return this->showDistance_; 172 172 } 173 173 174 174 void SpaceBoundaries::setHealthDecrease(float amount) 175 175 { … … 180 180 return this->healthDecrease_; 181 181 } 182 182 183 183 void SpaceBoundaries::setReaction(int mode) 184 184 { … … 200 200 XMLPortParam(SpaceBoundaries, "reactionMode", setReaction, getReaction, xmlelement, mode); 201 201 } 202 202 203 203 void SpaceBoundaries::tick(float dt) 204 204 { 205 205 this->checkWhoIsIn(); 206 206 this->removeAllBillboards(); 207 207 208 208 float distance; 209 209 bool humanItem; … … 247 247 } 248 248 } 249 249 250 250 float SpaceBoundaries::computeDistance(WorldEntity *item) 251 251 { … … 258 258 } 259 259 } 260 260 261 261 void SpaceBoundaries::displayWarning(const std::string warnText) 262 { 262 { 263 263 // TODO 264 264 } 265 265 266 266 void SpaceBoundaries::displayBoundaries(Pawn *item, float alpha) 267 267 { 268 268 269 269 Vector3 direction = item->getPosition() - this->getPosition(); 270 270 direction.normalise(); 271 271 272 272 Vector3 boundaryPosition = this->getPosition() + direction * this->maxDistance_; 273 273 274 274 this->positionBillboard(boundaryPosition, alpha); 275 275 } 276 276 277 277 void SpaceBoundaries::conditionalBounceBack(Pawn *item, float currentDistance, float dt) 278 278 { … … 281 281 Vector3 velocity = item->getVelocity(); 282 282 float normalSpeed = item->getVelocity().dotProduct(normal); 283 283 284 284 /* Check, whether the Pawn would leave the boundary in the next tick, if so send it back. */ 285 285 if( this->reaction_ == 0 && currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure" … … 292 292 } 293 293 } 294 294 295 295 void SpaceBoundaries::bounceBack(Pawn *item, Vector3 *normal, Vector3 *velocity) 296 296 { … … 299 299 Vector3 acceleration = item->getAcceleration(); 300 300 acceleration = acceleration.reflect(*normal); 301 301 302 302 item->lookAt( *velocity + this->getPosition() ); 303 303 304 304 item->setAcceleration(acceleration * dampingFactor); 305 305 item->setVelocity(*velocity * dampingFactor); 306 306 307 307 item->setPosition( item->getPosition() - *normal * 10 ); // Set the position of the Pawn to be well inside the boundary. 308 308 } 309 309 310 310 bool SpaceBoundaries::isHumanPlayer(Pawn *item) 311 311 { … … 319 319 return false; 320 320 } 321 321 322 322 }
Note: See TracChangeset
for help on using the changeset viewer.