Changeset 6310
- Timestamp:
- Dec 9, 2009, 10:58:26 PM (15 years ago)
- Location:
- code/branches/presentation2/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
r6295 r6310 67 67 overlaySize_ = 0.08; 68 68 arrowsSize_ = 0.4; 69 70 damageOverlayTime_ = 0.6; 71 69 72 controlMode_ = 0; 70 73 acceleration_ = 0; 71 74 accelerating_ = false; 72 75 firemode_ = -1; 76 73 77 showArrows_ = true; 74 78 showOverlays_ = false; 79 showDamageOverlay_ = true; 75 80 76 81 //currentPitch_ = 1; … … 91 96 centerOverlay_->hide(); 92 97 93 if (showArrows_) 98 if ( showDamageOverlay_ ) 99 { 100 damageOverlayTop_ = new OrxonoxOverlay(this); 101 damageOverlayTop_->setBackgroundMaterial("Orxonox/DamageOverlayTop"); 102 damageOverlayTop_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5)); 103 damageOverlayTop_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\ 104 damageOverlayTop_->hide(); 105 106 damageOverlayRight_ = new OrxonoxOverlay(this); 107 damageOverlayRight_->setBackgroundMaterial("Orxonox/DamageOverlayRight"); 108 damageOverlayRight_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5)); 109 damageOverlayRight_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\ 110 damageOverlayRight_->hide(); 111 112 damageOverlayBottom_ = new OrxonoxOverlay(this); 113 damageOverlayBottom_->setBackgroundMaterial("Orxonox/DamageOverlayBottom"); 114 damageOverlayBottom_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5)); 115 damageOverlayBottom_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\ 116 damageOverlayBottom_->hide(); 117 118 damageOverlayLeft_ = new OrxonoxOverlay(this); 119 damageOverlayLeft_->setBackgroundMaterial("Orxonox/DamageOverlayLeft"); 120 damageOverlayLeft_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5)); 121 damageOverlayLeft_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\ 122 damageOverlayLeft_->hide(); 123 } 124 125 if ( showArrows_ ) 94 126 { 95 127 arrowsOverlay1_ = new OrxonoxOverlay(this); … … 168 200 169 201 if ( !controlPaused_ ) { 170 if (this->getControllableEntity() && this->getControllableEntity()->getIdentifier()->getName() == "SpaceShip")202 if (this->getControllableEntity() && (this->getControllableEntity()->getIdentifier()->getName() == "SpaceShip" || this->getControllableEntity()->getIdentifier()->getName() == "Rocket")) 171 203 this->showOverlays(); 172 204 … … 180 212 else 181 213 hideArrows(); 214 215 if ( this->showDamageOverlay_ && ( this->damageOverlayTT_ > 0 || this->damageOverlayTR_ > 0 || this->damageOverlayTB_ > 0 || this->damageOverlayTL_ > 0 ) ) { 216 this->damageOverlayTT_ -= dt; 217 this->damageOverlayTR_ -= dt; 218 this->damageOverlayTB_ -= dt; 219 this->damageOverlayTL_ -= dt; 220 if ( this->damageOverlayTT_ <= 0 ) 221 this->damageOverlayTop_->hide(); 222 if ( this->damageOverlayTR_ <= 0 ) 223 this->damageOverlayRight_->hide(); 224 if ( this->damageOverlayTB_ <= 0 ) 225 this->damageOverlayBottom_->hide(); 226 if ( this->damageOverlayTL_ <= 0 ) 227 this->damageOverlayLeft_->hide(); 228 } 182 229 } 183 230 } … … 251 298 252 299 void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) { 253 Vector3 posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA()); 254 //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB()); 255 //posA and posB are almost identical 256 257 Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation() * (posA - this->getControllableEntity()->getPosition()); 258 259 COUT(0) << relativeHit << endl; 260 //COUT(0) << "Damage: " << damage << " Point A: " << posA << " Point B: " << posB << endl; 300 if ( showDamageOverlay_ ) { 301 Vector3 posA; 302 if ( originator ) 303 posA = originator->getWorldPosition(); 304 else 305 posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA()); 306 //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB()); 307 //posA and posB are almost identical 308 309 Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation().UnitInverse() * (this->getControllableEntity()->getWorldPosition() - posA); 310 311 //back is z positive 312 //x is left positive 313 //y is down positive 314 relativeHit.normalise(); 315 COUT(0) << relativeHit << endl; 316 317 float threshold = 0.3; 318 // && abs(relativeHit.y) < 0.5 319 if ( relativeHit.x > threshold) // Left 320 { 321 this->damageOverlayLeft_->show(); 322 this->damageOverlayTL_ = this->damageOverlayTime_; 323 //this->damageOverlayLeft_->setBackgroundAlpha(0.3); 324 } 325 if ( relativeHit.x < -threshold) //Right 326 { 327 this->damageOverlayRight_->show(); 328 this->damageOverlayTR_ = this->damageOverlayTime_; 329 //this->damageOverlayRight_->setBackgroundAlpha(0.3); 330 } 331 if ( relativeHit.y > threshold) //Top 332 { 333 this->damageOverlayTop_->show(); 334 this->damageOverlayTT_ = this->damageOverlayTime_; 335 //this->damageOverlayTop_->setBackgroundAlpha(0.3); 336 } 337 if ( relativeHit.y < -threshold) //Bottom 338 { 339 this->damageOverlayBottom_->show(); 340 this->damageOverlayTB_ = this->damageOverlayTime_; 341 //this->damageOverlayBottom_->setBackgroundAlpha(0.3); 342 } 343 344 } 261 345 } 262 346 … … 485 569 this->centerOverlay_->hide(); 486 570 571 if ( showDamageOverlay_ ) { 572 this->damageOverlayTop_->hide(); 573 this->damageOverlayRight_->hide(); 574 this->damageOverlayBottom_->hide(); 575 this->damageOverlayLeft_->hide(); 576 } 577 487 578 this->hideArrows(); 488 579 } -
code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
r6295 r6310 81 81 OrxonoxOverlay* crossHairOverlay_; 82 82 OrxonoxOverlay* centerOverlay_; 83 84 OrxonoxOverlay* damageOverlayTop_; 85 OrxonoxOverlay* damageOverlayRight_; 86 OrxonoxOverlay* damageOverlayBottom_; 87 OrxonoxOverlay* damageOverlayLeft_; 88 float damageOverlayTime_; 89 float damageOverlayTT_; 90 float damageOverlayTR_; 91 float damageOverlayTB_; 92 float damageOverlayTL_; 93 83 94 OrxonoxOverlay* arrowsOverlay1_; 84 95 OrxonoxOverlay* arrowsOverlay2_; 85 96 OrxonoxOverlay* arrowsOverlay3_; 86 97 OrxonoxOverlay* arrowsOverlay4_; 98 87 99 float overlaySize_; 88 100 float arrowsSize_; … … 91 103 int firemode_; 92 104 bool showArrows_; 105 bool showDamageOverlay_; 93 106 bool showOverlays_; 94 107 ClassTreeMask targetMask_; -
code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.cc
r6218 r6310 39 39 #include <OgrePanelOverlayElement.h> 40 40 #include <OgreRenderWindow.h> 41 #include <OgreMaterialManager.h> 42 #include <OgreTechnique.h> 43 #include <OgrePass.h> 41 44 42 45 #include "util/Convert.h" … … 370 373 } 371 374 } 375 376 void OrxonoxOverlay::setBackgroundAlpha(float alpha) { 377 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 378 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 379 tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha); 380 } 372 381 } -
code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.h
r6108 r6310 158 158 const std::string& getBackgroundMaterial() const; 159 159 160 void setBackgroundAlpha(float alpha); 161 160 162 virtual void changedVisibility(); 161 163 … … 205 207 BaseObject* owner_; 206 208 OverlayGroup* group_; 209 Ogre::Pass* backgroundAlphaPass_; 207 210 }; 208 211
Note: See TracChangeset
for help on using the changeset viewer.