Changeset 8579 for code/branches/presentation/src/orxonox
- Timestamp:
- May 25, 2011, 9:28:29 PM (14 years ago)
- Location:
- code/branches/presentation/src/orxonox
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/controllers/Controller.h
r8578 r8579 52 52 virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {}; 53 53 54 /* Override needed for different visual effects (e.g. in "NewHumanController.cc") depending on55 the DIFFERENT AMOUNT OF DAMAGE done to the shield and to the health of "victim" (see Projectile.cc, Pawn.cc)56 57 // virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) {};58 */59 60 54 void setGodMode( bool mode ){ this->bGodMode_ = mode; } 61 55 bool getGodMode(){ return this->bGodMode_; } -
code/branches/presentation/src/orxonox/controllers/HumanController.cc
r8578 r8579 42 42 extern const std::string __CC_fire_name = "fire"; 43 43 extern const std::string __CC_suicide_name = "suicide"; 44 const std::string __CC_boost_name = "boost";45 44 46 45 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); … … 52 51 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 53 52 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::keepBoost).addShortcut().keybindMode(KeybindMode::OnHold);53 SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold); 55 54 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 56 55 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 67 66 68 67 HumanController* HumanController::localController_s = 0; 69 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f;70 68 71 69 HumanController::HumanController(BaseObject* creator) : Controller(creator) … … 73 71 RegisterObject(HumanController); 74 72 75 this->controlPaused_ = false; 76 this->boosting_ = false; 73 controlPaused_ = false; 77 74 78 75 HumanController::localController_s = this; 79 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));80 this->boostingTimeout_.stopTimer();81 76 } 82 77 … … 168 163 } 169 164 170 /** 171 @brief 172 Static method,keeps boosting. 173 */ 174 /*static*/ void HumanController::keepBoost() 175 { 176 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 177 HumanController::localController_s->keepBoosting(); 178 } 179 180 /** 181 @brief 182 Starts, or keeps the boosting mode. 183 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 184 */ 185 void HumanController::keepBoosting(void) 186 { 187 if(this->boostingTimeout_.isActive()) 188 { 189 this->boostingTimeout_.stopTimer(); 190 this->boostingTimeout_.startTimer(); 191 } 192 else 193 { 194 this->boosting_ = true; 195 this->boostingTimeout_.startTimer(); 196 197 this->controllableEntity_->boost(this->boosting_); 198 COUT(4) << "Start boosting" << endl; 199 } 200 } 201 202 /** 203 @brief 204 Terminates the boosting mode. 205 */ 206 void HumanController::terminateBoosting(void) 207 { 208 this->boosting_ = false; 209 this->boostingTimeout_.stopTimer(); 210 211 this->controllableEntity_->boost(this->boosting_); 212 COUT(4) << "Stop boosting" << endl; 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 213 169 } 214 170 -
code/branches/presentation/src/orxonox/controllers/HumanController.h
r8578 r8579 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "tools/Timer.h"35 34 #include "tools/interfaces/Tickable.h" 36 35 #include "Controller.h" … … 65 64 static void reload(); 66 65 67 static void keepBoost(); // Static method, keeps boosting. 68 /** 69 @brief Check whether the HumanController is in boosting mode. 70 @return Returns true if it is, false if not. 71 */ 72 inline bool isBoosting(void) 73 { return this->boosting_; } 74 void keepBoosting(void); 75 void terminateBoosting(void); 76 66 static void boost(); 77 67 static void greet(); 78 68 static void switchCamera(); … … 102 92 static HumanController* localController_s; 103 93 bool controlPaused_; 104 105 private:106 bool boosting_; // Whether the HumanController is in boosting mode or not.107 Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.108 static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.109 110 94 }; // tolua_export 111 95 } // tolua_export -
code/branches/presentation/src/orxonox/graphics/Camera.cc
r8578 r8579 48 48 CreateFactory(Camera); 49 49 50 Camera::Camera(BaseObject* creator) : MovableEntity(creator)50 Camera::Camera(BaseObject* creator) : StaticEntity(creator) 51 51 { 52 52 RegisterObject(Camera); -
code/branches/presentation/src/orxonox/graphics/Camera.h
r8578 r8579 36 36 #include "tools/interfaces/Tickable.h" 37 37 #include "tools/interfaces/TimeFactorListener.h" 38 #include "worldentities/ MovableEntity.h"38 #include "worldentities/StaticEntity.h" 39 39 40 40 namespace orxonox 41 41 { 42 43 class _OrxonoxExport Camera : public MovableEntity, public TimeFactorListener, public WindowEventListener 42 class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener 44 43 { 45 44 friend class CameraManager; -
code/branches/presentation/src/orxonox/items/Engine.cc
r8578 r8579 204 204 this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd()))); 205 205 206 if (!this->ship_->getPermanentBoost()) 207 this->ship_->setBoost(false); 206 208 this->ship_->setSteeringDirection(Vector3::ZERO); 207 209 -
code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.cc
r8578 r8579 66 66 67 67 this->damage_ = 0; 68 this->healthdamage_ = 0;69 this->shielddamage_ = 0;70 68 71 69 this->muzzleOffset_ = Vector3::ZERO; … … 108 106 109 107 XMLPortParam(WeaponMode, "damage", setDamage, getDamage, xmlelement, mode); 110 XMLPortParam(WeaponMode, "healthdamage", setHealthDamage, getHealthDamage, xmlelement, mode);111 XMLPortParam(WeaponMode, "shielddamage", setShieldDamage, getShieldDamage, xmlelement, mode);112 108 XMLPortParam(WeaponMode, "muzzleoffset", setMuzzleOffset, getMuzzleOffset, xmlelement, mode); 113 109 } -
code/branches/presentation/src/orxonox/weaponsystem/WeaponMode.h
r8578 r8579 104 104 // Fire 105 105 inline void setDamage(float damage) 106 { this->damage_ = damage; }106 { this->damage_ = damage; } 107 107 inline float getDamage() const 108 108 { return this->damage_; } 109 inline void setHealthDamage(float healthdamage)110 { this->healthdamage_ = healthdamage; }111 inline float getHealthDamage() const112 { return this->healthdamage_; }113 114 inline void setShieldDamage(float shielddamage)115 { this->shielddamage_ = shielddamage;}116 inline float getShieldDamage() const117 { return this->shielddamage_; }118 109 119 110 inline void setMuzzleOffset(const Vector3& offset) … … 155 146 156 147 float damage_; 157 float healthdamage_;158 float shielddamage_;159 148 Vector3 muzzleOffset_; 160 149 -
code/branches/presentation/src/orxonox/worldentities/ControllableEntity.cc
r8578 r8579 84 84 this->client_angular_velocity_ = Vector3::ZERO; 85 85 86 86 87 this->setConfigValues(); 87 88 this->setPriority( Priority::VeryHigh ); -
code/branches/presentation/src/orxonox/worldentities/ControllableEntity.h
r8578 r8579 93 93 virtual void reload() {} 94 94 95 /** 96 @brief Tells the ControllableEntity to either start or stop boosting. 97 This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will. 98 @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop. 99 */ 100 virtual void boost(bool bBoost) {} 101 95 virtual void boost() {} 102 96 virtual void greet() {} 103 97 virtual void switchCamera(); -
code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.cc
r8578 r8579 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * simonmie25 * ... 26 26 * 27 27 */ … … 64 64 this->maxHealth_ = 0; 65 65 this->initialHealth_ = 0; 66 67 66 this->shieldHealth_ = 0; 68 this->initialShieldHealth_ = 0;69 this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max70 67 this->shieldAbsorption_ = 0.5; 71 72 this->reloadRate_ = 0;73 this->reloadWaitTime_ = 1.0f;74 this->reloadWaitCountdown_ = 0;75 68 76 69 this->lastHitOriginator_ = 0; … … 116 109 117 110 XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0); 118 XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);119 XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);120 111 XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0); 121 112 … … 127 118 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 128 119 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 129 130 XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);131 XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);132 120 } 133 121 … … 136 124 registerVariable(this->bAlive_, VariableDirection::ToClient); 137 125 registerVariable(this->health_, VariableDirection::ToClient); 138 registerVariable(this-> maxHealth_,VariableDirection::ToClient);126 registerVariable(this->initialHealth_, VariableDirection::ToClient); 139 127 registerVariable(this->shieldHealth_, VariableDirection::ToClient); 140 registerVariable(this->maxShieldHealth_, VariableDirection::ToClient);141 128 registerVariable(this->shieldAbsorption_, VariableDirection::ToClient); 142 129 registerVariable(this->bReload_, VariableDirection::ToServer); … … 150 137 this->bReload_ = false; 151 138 152 // TODO: use the existing timer functions instead153 if(this->reloadWaitCountdown_ > 0)154 {155 this->decreaseReloadCountdownTime(dt);156 }157 else158 {159 this->addShieldHealth(this->getReloadRate() * dt);160 this->resetReloadCountdown();161 }162 163 139 if (GameMode::isMaster()) 164 {165 140 if (this->health_ <= 0 && bAlive_) 166 141 { 167 this->fireEvent(); // Event to notify anyone who want s to know about the death.142 this->fireEvent(); // Event to notify anyone who want's to know about the death. 168 143 this->death(); 169 144 } 170 }171 145 } 172 146 … … 194 168 } 195 169 196 197 170 void Pawn::setHealth(float health) 198 171 { 199 this->health_ = std::min(health, this->maxHealth_); //Health can't be set to a value bigger than maxHealth, otherwise it will be reduced at first hit 200 } 201 202 void Pawn::setShieldHealth(float shieldHealth) 203 { 204 this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_); 205 } 206 207 void Pawn::setMaxShieldHealth(float maxshieldhealth) 208 { 209 this->maxShieldHealth_ = maxshieldhealth; 210 } 211 212 void Pawn::setReloadRate(float reloadrate) 213 { 214 this->reloadRate_ = reloadrate; 215 } 216 217 void Pawn::setReloadWaitTime(float reloadwaittime) 218 { 219 this->reloadWaitTime_ = reloadwaittime; 220 } 221 222 void Pawn::decreaseReloadCountdownTime(float dt) 223 { 224 this->reloadWaitCountdown_ -= dt; 225 } 226 227 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 172 this->health_ = std::min(health, this->maxHealth_); 173 } 174 175 void Pawn::damage(float damage, Pawn* originator) 228 176 { 229 177 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 230 178 { 231 if (shielddamage >= this->getShieldHealth()) 179 //share the dealt damage to the shield and the Pawn. 180 float shielddamage = damage*this->shieldAbsorption_; 181 float healthdamage = damage*(1-this->shieldAbsorption_); 182 183 // In case the shield can not take all the shield damage. 184 if (shielddamage > this->getShieldHealth()) 232 185 { 186 healthdamage += shielddamage-this->getShieldHealth(); 233 187 this->setShieldHealth(0); 234 this->setHealth(this->health_ - (healthdamage + damage));235 188 } 236 else 189 190 this->setHealth(this->health_ - healthdamage); 191 192 if (this->getShieldHealth() > 0) 237 193 { 238 194 this->setShieldHealth(this->shieldHealth_ - shielddamage); 239 240 // remove remaining shieldAbsorpton-Part of damage from shield241 shielddamage = damage * this->shieldAbsorption_;242 shielddamage = std::min(this->getShieldHealth(),shielddamage);243 this->setShieldHealth(this->shieldHealth_ - shielddamage);244 245 // set remaining damage to health246 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);247 195 } 248 196 249 197 this->lastHitOriginator_ = originator; 250 } 251 } 252 253 // TODO: Still valid? 254 /* HIT-Funktionen 255 Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte) 256 257 */ 258 259 void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage) 198 199 // play damage effect 200 } 201 } 202 203 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 260 204 { 261 205 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 262 206 { 263 this->damage(damage, healthdamage, shielddamage,originator);207 this->damage(damage, originator); 264 208 this->setVelocity(this->getVelocity() + force); 265 } 266 } 267 268 269 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) 209 210 // play hit effect 211 } 212 } 213 214 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 270 215 { 271 216 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 272 217 { 273 this->damage(damage, healthdamage, shielddamage,originator);218 this->damage(damage, originator); 274 219 275 220 if ( this->getController() ) 276 this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? 277 } 278 } 279 221 this->getController()->hit(originator, contactpoint, damage); 222 223 // play hit effect 224 } 225 } 280 226 281 227 void Pawn::kill() -
code/branches/presentation/src/orxonox/worldentities/pawns/Pawn.h
r8578 r8579 72 72 { return this->initialHealth_; } 73 73 74 virtual void setShieldHealth(float shieldHealth);75 74 inline void setShieldHealth(float shieldHealth) 75 { this->shieldHealth_ = shieldHealth; } 76 76 inline float getShieldHealth() 77 77 { return this->shieldHealth_; } 78 79 inline void addShieldHealth(float amount)80 { this->setShieldHealth(this->shieldHealth_ + amount); }81 82 inline bool hasShield()83 { return (this->getShieldHealth() > 0); }84 85 virtual void setMaxShieldHealth(float maxshieldhealth);86 inline float getMaxShieldHealth() const87 { return this->maxShieldHealth_; }88 89 inline void setInitialShieldHealth(float initialshieldhealth)90 { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); }91 inline float getInitialShieldHealth() const92 { return this->initialShieldHealth_; }93 94 inline void restoreInitialShieldHealth()95 { this->setShieldHealth(this->initialShieldHealth_); }96 inline void restoreMaxShieldHealth()97 { this->setShieldHealth(this->maxShieldHealth_); }98 78 99 79 inline void setShieldAbsorption(float shieldAbsorption) … … 102 82 { return this->shieldAbsorption_; } 103 83 104 // TODO: Rename to shieldRechargeRate105 virtual void setReloadRate(float reloadrate);106 inline float getReloadRate() const107 { return this->reloadRate_; }108 109 virtual void setReloadWaitTime(float reloadwaittime);110 inline float getReloadWaitTime() const111 { return this->reloadWaitTime_; }112 113 inline void resetReloadCountdown()114 { this->reloadWaitCountdown_ = 0; }115 116 inline void startReloadCountdown()117 { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc118 119 virtual void decreaseReloadCountdownTime(float dt);120 121 84 inline ControllableEntity* getLastHitOriginator() const 122 85 { return this->lastHitOriginator_; } 123 86 124 //virtual void hit(Pawn* originator, const Vector3& force, float damage); 125 //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 126 virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 127 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 128 87 virtual void hit(Pawn* originator, const Vector3& force, float damage); 88 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 129 89 virtual void kill(); 130 90 … … 182 142 virtual void spawneffect(); 183 143 184 //virtual void damage(float damage, Pawn* originator = 0); 185 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL); 144 virtual void damage(float damage, Pawn* originator = 0); 186 145 187 146 bool bAlive_; … … 195 154 float maxHealth_; 196 155 float initialHealth_; 197 198 156 float shieldHealth_; 199 float maxShieldHealth_;200 float initialShieldHealth_;201 157 float shieldAbsorption_; // Has to be between 0 and 1 202 float reloadRate_;203 float reloadWaitTime_;204 float reloadWaitCountdown_;205 158 206 159 WeakPtr<Pawn> lastHitOriginator_; -
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
r8578 r8579 36 36 #include "core/XMLPort.h" 37 37 #include "items/Engine.h" 38 #include "graphics/Camera.h"39 #include "CameraManager.h"40 #include "util/Math.h"41 38 42 39 namespace orxonox … … 56 53 this->localAngularAcceleration_.setValue(0, 0, 0); 57 54 this->bBoost_ = false; 55 this->bPermanentBoost_ = false; 58 56 this->steering_ = Vector3::ZERO; 59 57 this->engine_ = 0; … … 78 76 this->setConfigValues(); 79 77 this->registerVariables(); 80 81 Camera* camera = CameraManager::getInstance().getActiveCamera();82 this->cameraOriginalPosition_ = camera->getPosition();83 this->cameraOriginalOrientation_ = camera->getOrientation();84 85 this->shakeFrequency_ = 15;86 this->shakeAmplitude_ = 5;87 this->shakeDt_ = 0;88 78 } 89 79 … … 106 96 XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode); 107 97 XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode); 108 XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode);109 XMLPortParamVariable(SpaceShip, "shakeAmplitude", shakeAmplitude_, xmlelement, mode);110 98 } 111 99 … … 115 103 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 116 104 registerVariable(this->rotationThrust_, VariableDirection::ToClient); 117 // TODO: Synchronization of boost needed?118 registerVariable(this->boostPower_, VariableDirection::ToClient);119 registerVariable(this->boostPowerRate_, VariableDirection::ToClient);120 registerVariable(this->boostRate_, VariableDirection::ToClient);121 registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient);122 registerVariable(this->shakeFrequency_, VariableDirection::ToClient);123 registerVariable(this->shakeAmplitude_, VariableDirection::ToClient);124 105 } 125 106 … … 147 128 if (this->hasLocalController()) 148 129 { 149 150 130 /* 151 131 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); … … 170 150 this->boostPower_ += this->boostPowerRate_*dt; 171 151 } 172 173 152 if(this->bBoost_) 174 153 { … … 176 155 if(this->boostPower_ <= 0.0f) 177 156 { 178 this->b oost(false);157 this->bBoost_ = false; 179 158 this->bBoostCooldown_ = true; 180 159 this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this))); 181 182 160 } 183 184 shakeCamera(dt); 185 } 186 } 161 } 162 } 163 } 164 165 void SpaceShip::boostCooledDown(void) 166 { 167 this->bBoostCooldown_ = false; 187 168 } 188 169 … … 226 207 } 227 208 209 // TODO: something seems to call this function every tick, could probably handled a little more efficiently! 210 void SpaceShip::setBoost(bool bBoost) 211 { 212 if(bBoost == this->bBoost_) 213 return; 214 215 if(bBoost) 216 this->boost(); 217 else 218 { 219 this->bBoost_ = false; 220 } 221 } 222 228 223 void SpaceShip::fire() 229 224 { 230 225 } 231 226 232 /** 233 @brief 234 Starts or stops boosting. 235 @param bBoost 236 Whether to start or stop boosting. 237 */ 238 void SpaceShip::boost(bool bBoost) 239 { 240 if(bBoost && !this->bBoostCooldown_) 241 { 242 //COUT(0) << "Boost startet!\n"; 227 void SpaceShip::boost() 228 { 229 if(!this->bBoostCooldown_) 243 230 this->bBoost_ = true; 244 }245 if(!bBoost)246 {247 //COUT(0) << "Boost stoppt\n";248 this->resetCamera();249 this->bBoost_ = false;250 }251 }252 253 void SpaceShip::boostCooledDown(void)254 {255 this->bBoostCooldown_ = false;256 }257 258 void SpaceShip::shakeCamera(float dt)259 {260 //make sure the ship is only shaking if it's moving261 if (this->getVelocity().squaredLength() > 80)262 {263 this->shakeDt_ += dt;264 265 int frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength());266 267 if (this->shakeDt_ >= 1 /(frequency))268 {269 this->shakeDt_ -= 1/(frequency);270 }271 272 Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_);273 274 //COUT(0) << "Angle: " << angle << std::endl;275 Camera* c = this->getCamera();276 277 //Shaking Camera effect278 if (c != 0)279 {280 c->setOrientation(Vector3::UNIT_X, angle);281 }282 }283 }284 285 void SpaceShip::resetCamera()286 {287 288 //COUT(0) << "Resetting camera\n";289 Camera *c = this->getCamera();290 291 if (c == 0)292 {293 COUT(2) << "Failed to reset camera!";294 return;295 }296 297 shakeDt_ = 0;298 //299 c->setPosition(this->cameraOriginalPosition_);300 c->setOrientation(this->cameraOriginalOrientation_);301 231 } 302 232 … … 343 273 return list; 344 274 } 345 346 347 275 } -
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
r8578 r8579 59 59 60 60 virtual void fire(); 61 virtual void boost( bool bBoost); // Starts or stops boosting.61 virtual void boost(); 62 62 63 63 void setEngine(Engine* engine); … … 70 70 { return this->steering_; } 71 71 72 void setBoost(bool bBoost); 72 73 inline bool getBoost() const 73 74 { return this->bBoost_; } … … 78 79 { return this->enginetemplate_; } 79 80 81 inline void setPermanentBoost(bool bPermanent) 82 { this->bPermanentBoost_ = bPermanent; } 83 inline bool getPermanentBoost() const 84 { return this->bPermanentBoost_; } 85 80 86 protected: 81 87 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const; … … 84 90 bool bBoost_; 85 91 bool bBoostCooldown_; 92 bool bPermanentBoost_; 86 93 float boostPower_; 87 94 float initialBoostPower_; … … 96 103 btVector3 localAngularAcceleration_; 97 104 98 float shakeFrequency_;99 float shakeAmplitude_;100 101 105 private: 102 106 void registerVariables(); … … 106 110 107 111 void boostCooledDown(void); 108 109 void resetCamera();110 void shakeCamera(float dt);111 112 112 113 std::string enginetemplate_; 113 114 Engine* engine_; 114 115 Timer timer_; 115 Vector3 cameraOriginalPosition_;116 Quaternion cameraOriginalOrientation_;117 118 float shakeDt_;119 116 }; 120 117 }
Note: See TracChangeset
for help on using the changeset viewer.