- Timestamp:
- Dec 2, 2009, 6:46:20 PM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/data/defaultConfig/keybindings.ini
r6201 r6210 154 154 Left="fire 0" 155 155 Middle= 156 Right= "fire 1"156 Right= fire 1 | unfire 157 157 Wheel1Down="NewHumanController decelerate" 158 158 Wheel1Up="NewHumanController accelerate" -
code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
r6195 r6210 44 44 #include "Scene.h" 45 45 46 #include <cmath> 47 48 46 49 namespace orxonox 47 50 { … … 49 52 SetConsoleCommand(NewHumanController, accelerate, false).keybindMode(KeybindMode::OnPress); 50 53 SetConsoleCommand(NewHumanController, decelerate, false).keybindMode(KeybindMode::OnPress); 54 SetConsoleCommand(NewHumanController, unfire, true).keybindMode(KeybindMode::OnRelease); 51 55 52 56 CreateUnloadableFactory(NewHumanController); … … 62 66 63 67 overlaySize_ = 0.08; 68 arrowsSize_ = 0.4; 64 69 controlMode_ = 0; 65 70 acceleration_ = 0; 71 firemode_ = -1; 72 showArrows_ = true; 66 73 67 74 //currentPitch_ = 1; … … 74 81 crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_)); 75 82 crossHairOverlay_->hide(); 83 //crossHairOverlay_->setAspectCorrection(true); not working 76 84 77 85 centerOverlay_ = new OrxonoxOverlay(this); … … 80 88 centerOverlay_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\ 81 89 centerOverlay_->hide(); 90 91 if (showArrows_) 92 { 93 arrowsOverlay1_ = new OrxonoxOverlay(this); 94 arrowsOverlay1_->setBackgroundMaterial("Orxonox/DirectionArrows1"); 95 arrowsOverlay1_->setSize(Vector2(0.02727, 0.36 * arrowsSize_)); 96 arrowsOverlay1_->setPickPoint(Vector2(0.5, 0.5)); 97 arrowsOverlay1_->setPosition(Vector2(0.5, 0.5)); 98 arrowsOverlay1_->hide(); 99 100 arrowsOverlay2_ = new OrxonoxOverlay(this); 101 arrowsOverlay2_->setBackgroundMaterial("Orxonox/DirectionArrows2"); 102 arrowsOverlay2_->setSize(Vector2(0.02727, 0.59 * arrowsSize_)); 103 arrowsOverlay2_->setPickPoint(Vector2(0.5, 0.5)); 104 arrowsOverlay2_->setPosition(Vector2(0.5, 0.5)); 105 arrowsOverlay2_->hide(); 106 107 arrowsOverlay3_ = new OrxonoxOverlay(this); 108 arrowsOverlay3_->setBackgroundMaterial("Orxonox/DirectionArrows3"); 109 arrowsOverlay3_->setSize(Vector2(0.02727, 0.77 * arrowsSize_)); 110 arrowsOverlay3_->setPickPoint(Vector2(0.5, 0.5)); 111 arrowsOverlay3_->setPosition(Vector2(0.5, 0.5)); 112 arrowsOverlay3_->hide(); 113 114 arrowsOverlay4_ = new OrxonoxOverlay(this); 115 arrowsOverlay4_->setBackgroundMaterial("Orxonox/DirectionArrows4"); 116 arrowsOverlay4_->setSize(Vector2(0.02727, arrowsSize_)); 117 arrowsOverlay4_->setPickPoint(Vector2(0.5, 0.5)); 118 arrowsOverlay4_->setPosition(Vector2(0.5, 0.5)); 119 arrowsOverlay4_->hide(); 120 } 82 121 } 83 122 … … 89 128 NewHumanController::localController_s = this; 90 129 130 controlPaused_ = true; 131 91 132 //HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true); 92 133 } … … 98 139 if (this->crossHairOverlay_) 99 140 this->crossHairOverlay_->destroy(); 141 if (this->centerOverlay_) 142 this->centerOverlay_->destroy(); 143 144 if (showArrows_) 145 { 146 if (this->arrowsOverlay1_) 147 this->arrowsOverlay1_->destroy(); 148 if (this->arrowsOverlay2_) 149 this->arrowsOverlay2_->destroy(); 150 if (this->arrowsOverlay3_) 151 this->arrowsOverlay3_->destroy(); 152 if (this->arrowsOverlay4_) 153 this->arrowsOverlay4_->destroy(); 154 } 100 155 } 101 156 } … … 105 160 if (GameMode::showsGraphics()) 106 161 { 162 107 163 if( this->controllableEntity_ && !this->controllableEntity_->isInMouseLook() ) 108 164 { … … 110 166 if ( !controlPaused_ ) { 111 167 this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2)); 168 169 if ( this->controlMode_ == 0 || ( this->controlMode_ == 1 && this->firemode_ == 1 ) ) 170 alignArrows(); 171 else 172 hideArrows(); 173 112 174 this->crossHairOverlay_->show(); 113 175 this->centerOverlay_->show(); … … 117 179 this->crossHairOverlay_->hide(); 118 180 this->centerOverlay_->hide(); 181 182 hideArrows(); 119 183 } 120 184 … … 171 235 */ 172 236 237 this->firemode_ = firemode; 238 173 239 if (firemode == 1 && this->controlMode_ == 1) 174 240 { … … 180 246 HumanController::localController_s->getControllableEntity()->fire(firemode); 181 247 248 } 249 250 void NewHumanController::unfire() 251 { 252 if (NewHumanController::localController_s) 253 NewHumanController::localController_s->doUnfire(); 254 } 255 256 void NewHumanController::doUnfire() 257 { 258 COUT(0) << "dounfire" << endl; 259 this->firemode_ = -1; 260 hideArrows(); 182 261 } 183 262 … … 273 352 { 274 353 // SUPER(NewHumanController, yaw, value); 275 if (this->controlMode_ == 0 )354 if (this->controlMode_ == 0 || ( this->controllableEntity_ && this->controllableEntity_->isInMouseLook() ) ) 276 355 HumanController::yaw(value); 277 356 … … 282 361 { 283 362 // SUPER(NewHumanController, pitch, value); 284 if (this->controlMode_ == 0 )363 if (this->controlMode_ == 0 || ( this->controllableEntity_ && this->controllableEntity_->isInMouseLook() ) ) 285 364 HumanController::pitch(value); 286 365 … … 292 371 if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0) 293 372 { 294 if (NewHumanController::localController_s->controllableEntity_ && !NewHumanController::localController_s->controllableEntity_->isInMouseLook() )295 373 NewHumanController::localController_s->controlMode_ = 1; 374 NewHumanController::localController_s->hideArrows(); 296 375 } 297 376 else … … 304 383 this->currentYaw_ = 0; 305 384 this->currentPitch_ = 0; 385 if (this->getControllableEntity() && this->getControllableEntity()->getIdentifier()->getName() == "SpaceShip") { 386 this->doResumeControl(); 387 } 306 388 } 307 389 … … 330 412 void NewHumanController::doPauseControl() { 331 413 this->controlPaused_ = true; 414 332 415 this->crossHairOverlay_->hide(); 333 416 this->centerOverlay_->hide(); 417 418 hideArrows(); 419 } 420 421 void NewHumanController::alignArrows() { 422 if (showArrows_) { 423 hideArrows(); 424 425 float distance = sqrt(pow(static_cast<float>(this->currentYaw_)/2*-1,2) + pow(static_cast<float>(this->currentPitch_)/2*-1,2)); 426 427 if ( distance > 0.04 && distance <= 0.59 * arrowsSize_ / 2.0 ) { 428 this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f)); 429 430 this->arrowsOverlay1_->show(); 431 } 432 else if ( distance > 0.59 * arrowsSize_ / 2.0 && distance <= 0.77 * arrowsSize_ / 2.0 ) { 433 this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f)); 434 435 this->arrowsOverlay2_->show(); 436 } 437 else if ( distance > 0.77 * arrowsSize_ / 2.0 && distance <= arrowsSize_ / 2.0 ) { 438 this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f)); 439 440 this->arrowsOverlay3_->show(); 441 } 442 else if ( distance > arrowsSize_ / 2.0 ) { 443 this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f)); 444 445 this->arrowsOverlay4_->show(); 446 } 447 } 448 } 449 450 void NewHumanController::hideArrows() { 451 if (showArrows_) { 452 this->arrowsOverlay1_->hide(); 453 this->arrowsOverlay2_->hide(); 454 this->arrowsOverlay3_->hide(); 455 this->arrowsOverlay4_->hide(); 456 } 334 457 } 335 458 } -
code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
r6195 r6210 56 56 virtual void doFire(unsigned int firemode); 57 57 58 static void unfire(); 59 virtual void doUnfire(); 60 58 61 static void changeMode(); 59 62 … … 64 67 protected: 65 68 void updateTarget(); 69 void alignArrows(); 70 void hideArrows(); 66 71 67 72 unsigned int controlMode_; … … 72 77 OrxonoxOverlay* crossHairOverlay_; 73 78 OrxonoxOverlay* centerOverlay_; 79 OrxonoxOverlay* arrowsOverlay1_; 80 OrxonoxOverlay* arrowsOverlay2_; 81 OrxonoxOverlay* arrowsOverlay3_; 82 OrxonoxOverlay* arrowsOverlay4_; 74 83 float overlaySize_; 84 float arrowsSize_; 75 85 bool accelerating_; 76 86 float acceleration_; 87 int firemode_; 88 bool showArrows_; 77 89 ClassTreeMask targetMask_; 78 90 };
Note: See TracChangeset
for help on using the changeset viewer.