Changeset 8574 for code/branches/gameimmersion
- Timestamp:
- May 25, 2011, 6:23:51 PM (13 years ago)
- Location:
- code/branches/gameimmersion
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gameimmersion/data/defaultConfig/keybindings.ini
r8541 r8574 21 21 KeyDown="scale -1 moveFrontBack" 22 22 KeyE="scale -1 rotateRoll" 23 KeyEnd= 23 KeyEnd="boost" 24 24 KeyEquals= 25 25 KeyEscape="keyESC" … … 120 120 KeySlash= 121 121 KeySleep= 122 KeySpace= startBoost | stopBoost122 KeySpace="boost" 123 123 KeyStop= 124 124 KeySystemRequest= -
code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc
r8541 r8574 52 52 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 53 53 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 54 //SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress); 55 SetConsoleCommand("HumanController", "startBoost", &HumanController::startBoost ).addShortcut().keybindMode(KeybindMode::OnPress); 56 SetConsoleCommand("HumanController", "stopBoost", &HumanController::stopBoost ).addShortcut().keybindMode(KeybindMode::OnRelease); 54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress); 57 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 58 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 173 171 /*static*/ void HumanController::toggleBoost() 174 172 { 175 COUT(0) << "Toggling boost!"; 173 COUT(3) << "Toggling boost!" << endl; // TODO: Remove! 176 174 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 177 175 HumanController::localController_s->toggleBoosting(); … … 185 183 void HumanController::toggleBoosting(void) 186 184 { 187 /*188 185 this->boosting_ = !this->boosting_; 189 186 … … 194 191 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress); 195 192 196 this->controllableEntity_->boost(this->boosting_);*/ 197 } 198 199 void HumanController::startBoost() 200 { 201 COUT(0) << "Starting boost" << std::endl; 202 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 203 HumanController::localController_s->setBoost(true); 204 } 205 206 void HumanController::stopBoost() 207 { 208 COUT(0) << "Stopping boost" << std::endl; 209 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 210 HumanController::localController_s->setBoost(false); 211 } 212 213 void HumanController::setBoost(bool bBoost) 214 { 215 this->controllableEntity_->boost(bBoost); 216 } 193 this->controllableEntity_->boost(this->boosting_); 194 } 217 195 218 196 void HumanController::greet() -
code/branches/gameimmersion/src/orxonox/controllers/HumanController.h
r8541 r8574 64 64 static void reload(); 65 65 66 static void startBoost(); 67 static void stopBoost(); 68 static void toggleBoost(); // Static method,toggles boosting. 69 void setBoost(bool); 66 static void toggleBoost(); // Static method, toggles boosting. 70 67 /** 71 68 @brief Check whether the HumanController is in boosting mode. -
code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc
r8541 r8574 78 78 this->setConfigValues(); 79 79 this->registerVariables(); 80 81 82 83 84 85 86 87 80 81 Camera* c = CameraManager::getInstance().getActiveCamera(); 82 this->cameraOriginalPosition = c->getPosition(); 83 this->cameraOriginalOrientation = c->getOrientation(); 84 85 this->shakeFrequency_ = 15; 86 this->shakeAmplitude_ = 5; 87 this->shakeDt_ = 0; 88 88 } 89 89 … … 106 106 XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode); 107 107 XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode); 108 108 XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode); 109 109 } 110 110 … … 118 118 registerVariable(this->boostRate_, VariableDirection::ToClient); 119 119 registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient); 120 120 registerVariable(this->shakeFrequency_, VariableDirection::ToClient); 121 121 } 122 122 … … 144 144 if (this->hasLocalController()) 145 145 { 146 146 147 147 /* 148 148 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); … … 176 176 this->bBoostCooldown_ = true; 177 177 this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this))); 178 178 179 179 } 180 181 shakeCamera(dt); 180 181 shakeCamera(dt); 182 182 } 183 183 } … … 234 234 */ 235 235 void SpaceShip::boost(bool bBoost) 236 { 236 { 237 237 if(bBoost && !this->bBoostCooldown_) 238 239 238 { 239 //COUT(0) << "Boost startet!\n"; 240 240 this->bBoost_ = true; 241 241 } 242 242 if(!bBoost) 243 244 245 243 { 244 //COUT(0) << "Boost stoppt\n"; 245 this->resetCamera(); 246 246 this->bBoost_ = false; 247 247 } 248 248 } 249 249 250 250 void SpaceShip::boostCooledDown(void) 251 251 { 252 252 this->bBoostCooldown_ = false; 253 253 } 254 254 255 255 void SpaceShip::shakeCamera(float dt) 256 256 { 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 //COUT(0) << "Angle: " << angle << std::endl;272 273 274 275 276 277 278 279 257 //make sure the ship is only shaking if it's moving 258 if (this->getVelocity().squaredLength() > 80) 259 { 260 this->shakeDt_ += dt; 261 262 int frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength()); 263 264 if (this->shakeDt_ >= 1 /(frequency)) 265 { 266 this->shakeDt_ -= 1/(frequency); 267 } 268 269 Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_); 270 271 //COUT(0) << "Angle: " << angle << std::endl; 272 Camera* c = this->getCamera(); 273 274 //Shaking Camera effect 275 if (c != 0) 276 { 277 c->setOrientation(Vector3::UNIT_X, angle); 278 } 279 } 280 280 } 281 281 282 282 void SpaceShip::resetCamera() 283 283 { 284 285 //COUT(0) << "Resetting camera\n";286 287 288 289 290 291 292 293 294 295 // 296 297 284 285 //COUT(0) << "Resetting camera\n"; 286 Camera *c = this->getCamera(); 287 288 if (c == 0) 289 { 290 COUT(2) << "Failed to reset camera!"; 291 return; 292 } 293 294 shakeDt_ = 0; 295 // 296 c->setPosition(this->cameraOriginalPosition); 297 c->setOrientation(this->cameraOriginalOrientation); 298 298 } 299 299
Note: See TracChangeset
for help on using the changeset viewer.