Changeset 8589 for code/branches/presentation
- Timestamp:
- May 26, 2011, 12:58:09 AM (14 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/bigships (added) merged: 8426,8503-8504,8588
- Property svn:mergeinfo changed
-
code/branches/presentation/data/levels/templates/spaceshipAssff.oxt
r8580 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipassffcameras 5 engine = spaceshipassffengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 36 35 angularDamping = 0.9999999 37 36 > 37 <engines> 38 <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine /> 39 <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine /> 40 </engines> 38 41 <attached> 39 42 <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" /> … … 92 95 </EffectContainer> 93 96 <EffectContainer condition="not idle"> 94 <FadingBillboard mainstate=activity active=false scale=0.1 position="0, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 /> 95 <!-- 96 <Light mainstate=visibility position=" 8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point /> 97 <Light mainstate=visibility position="-8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point /> 98 --> 97 <FadingBillboard mainstate=activity active=false scale=0.1 position="7.6, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 /> 98 <FadingBillboard mainstate=activity active=false scale=0.1 position="-7.6, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 /> 99 99 </EffectContainer> 100 100 <EffectContainer condition="normal or brake"> … … 102 102 </EffectContainer> 103 103 <EffectContainer condition="normal or boost"> 104 <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />105 <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />104 <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 0" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" /> 105 <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 0" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" /> 106 106 </EffectContainer> 107 107 <EffectContainer condition="boost"> … … 109 109 <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" /> 110 110 </EffectContainer> 111 <EffectContainer condition="brake">111 <!-- <EffectContainer condition="brake"> 112 112 <FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 /> 113 113 <FadingBillboard mainstate=activity active=false scale=0.3 position="-8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 /> … … 115 115 <FadingBillboard mainstate=activity active=false scale=0.15 position="-8, 0, 6" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 /> 116 116 </EffectContainer> 117 --> 117 118 </MultiStateEngine> 118 119 </Template> -
code/branches/presentation/data/levels/templates/spaceshipGhost.oxt
r7679 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipghostcameras 5 engine = spaceshipghostengine 5 6 6 spawnparticlesource = "Orxonox/fairytwirl" 7 7 spawnparticleduration = 3 … … 21 21 angularDamping = 0.9999999 22 22 > 23 23 <engines> 24 <MultiStateEngine position="0,0,0" template=spaceshipghostengine/> 25 </engines> 24 26 <attached> 25 27 <Model position="0,0,0" scale=2 yaw=90 pitch=-90 roll=0 mesh="ghost.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipH2.oxt
r7679 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipHtwocameras 5 engine = spaceshipHtwoengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 25 24 include("includes/weaponSettingsH2.oxi") 26 25 ?> 26 <engines> 27 <MultiStateEngine position="0,0,0" template=spaceshipHtwoengine /> 27 28 29 </engines> 28 30 <attached> 29 31 <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale3D="3,0.833,0.833" mesh="h2_green.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipHXY.oxt
r7679 r8589 21 21 angularDamping = 0.9999999 22 22 > 23 <engines> 24 <MultiStateEngine position=" 0, 0, 0" template=spaceshipHXYengine /> 25 </engines> 23 26 <attached> 24 27 <Model position="0,0,0" yaw=180 pitch=-90 roll=0 scale=4 mesh="HXY.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipHXYSL.oxt
r8398 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipHXYcameras 5 engine = spaceshipHXYengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 21 20 angularDamping = 0.9999999 22 21 > 22 <engines> 23 <MultiStateEngine position=" 0, 0, 0" template=spaceshipHXYengine /> 24 </engines> 23 25 <attached> 24 26 <Model position="0,0,0" yaw=180 pitch=-90 roll=0 scale=4 mesh="HXY.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipPirate.oxt
r7679 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshippiratecameras 5 engine = spaceshippirateengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 21 20 angularDamping = 0.9999999 22 21 > 22 <engines> 23 <MultiStateEngine position=" 0, 0, 0" template=spaceshippirateengine /> 24 </engines> 23 25 <attached> 24 26 <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="pirate.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipSwallow.oxt
r7679 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipswallowcameras 5 engine = spaceshipswallowengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 21 20 angularDamping = 0.9999999 22 21 > 23 22 <engines> 23 <MultiStateEngine position=" 0, 0, 0" template=spaceshipswallowengine /> 24 </engines> 24 25 <attached> 25 26 <Model position="0,0,0" scale=2 yaw=90 pitch=-90 roll=0 mesh="swallow_mat.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipTransporter.oxt
r7679 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipTransportercameras 5 engine = spaceshipTransporterengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 21 20 angularDamping = 0.9999999 22 21 > 22 <engines> 23 <MultiStateEngine position=" 0, 0, 0" template=spaceshipTransporterengine /> 24 </engines> 23 25 <attached> 24 26 <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=10 mesh="Transporter.mesh" /> -
code/branches/presentation/data/levels/templates/spaceshipTransporterSL.oxt
r7679 r8589 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipTransportercameras 5 engine = spaceshipTransporterengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 21 20 angularDamping = 0.9999999 22 21 > 22 <engines> 23 <MultiStateEngine position=" 0, 0, 0" template=spaceshipTransporterengine /> 24 </engines> 23 25 <attached> 24 26 <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=10 mesh="Transporter.mesh" /> -
code/branches/presentation/src/modules/overlays/hud/HUDSpeedBar.cc
r5781 r8589 54 54 SUPER(HUDSpeedBar, tick, dt); 55 55 56 if (this->owner_ && this->owner_->getEngine())56 if (this->owner_) 57 57 { 58 float value = this->owner_->getVelocity().length() / (this->owner_->get Engine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor());58 float value = this->owner_->getVelocity().length() / (this->owner_->getMaxSpeedFront() * this->owner_->getSpeedFactor() * this->owner_->getBoostFactor()); 59 59 this->setValue(value); 60 60 } -
code/branches/presentation/src/orxonox/controllers/HumanController.cc
r8580 r8589 75 75 this->controlPaused_ = false; 76 76 this->boosting_ = false; 77 this->boosting_ = false; 77 78 78 79 HumanController::localController_s = this; -
code/branches/presentation/src/orxonox/gametypes/Dynamicmatch.cc
r8327 r8589 151 151 //Give new pig boost 152 152 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim); 153 if (spaceship && spaceship->getEngine()) 154 { 155 spaceship->getEngine()->setSpeedFactor(5); 156 WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine()); 157 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 158 executor->setDefaultValue(0, ptr); 159 new Timer(10, false, executor, true); 160 } 153 grantPigBoost(spaceship); 161 154 } 162 155 … … 252 245 //Give new pig boost 253 246 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim); 254 if (spaceship && spaceship->getEngine()) 255 { 256 spaceship->getEngine()->setSpeedFactor(5); 257 WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine()); 258 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 259 executor->setDefaultValue(0, ptr); 260 new Timer(10, false, executor, true); 261 } 262 247 grantPigBoost(spaceship); 263 248 } 264 249 // killer vs piggy … … 321 306 } 322 307 308 void Dynamicmatch::grantPigBoost(orxonox::SpaceShip* spaceship) 309 { 310 // Give pig boost 311 if (spaceship) 312 { 313 spaceship->setSpeedFactor(5); 314 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship); 315 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 316 executor->setDefaultValue(0, ptr); 317 new Timer(10, false, executor, true); 318 } 319 } 320 323 321 void Dynamicmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) //set party + colouring 324 322 { … … 597 595 } 598 596 599 void Dynamicmatch::resetSpeedFactor(WeakPtr< Engine>* ptr)// helper function597 void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function 600 598 { 601 599 if (*ptr) -
code/branches/presentation/src/orxonox/gametypes/Dynamicmatch.h
r7163 r8589 73 73 virtual void furtherInstructions();*/ 74 74 virtual void rewardPig(); 75 void resetSpeedFactor(WeakPtr<Engine>* ptr); 75 void grantPigBoost(SpaceShip* spaceship); // Added this, since it's used twice on different occasions. 76 void resetSpeedFactor(WeakPtr<SpaceShip>* ptr); 76 77 void tick (float dt);// used to end the game 77 78 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; -
code/branches/presentation/src/orxonox/items/Engine.cc
r8580 r8589 35 35 #include "Scene.h" 36 36 #include "worldentities/pawns/SpaceShip.h" 37 #include " tools/Shader.h"37 #include "core/Template.h" 38 38 39 39 namespace orxonox … … 47 47 this->ship_ = 0; 48 48 this->shipID_ = OBJECTID_UNKNOWN; 49 this->relativePosition_ = Vector3(0,0,0); 49 50 50 51 this->boostFactor_ = 1.5; … … 62 63 this->accelerationUpDown_ = 0.0; 63 64 64 this->boostBlur_ = 0;65 66 65 this->speedAdd_ = 0.0; 67 66 this->speedMultiply_ = 1.0; … … 73 72 Engine::~Engine() 74 73 { 75 if (this->isInitialized() && this->ship_) 76 { 77 this->ship_->setEngine(0); 78 79 if (this->boostBlur_) 80 this->boostBlur_->destroy(); 81 } 74 82 75 } 83 76 … … 98 91 XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode); 99 92 XMLPortParam(Engine, "accelerationupdown", setAccelerationUpDown, setAccelerationUpDown, xmlelement, mode); 93 94 XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode); 95 XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode); 100 96 } 101 97 102 98 void Engine::setConfigValues() 103 99 { 104 SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)105 .description("Enable or disable the motion blur effect when moving very fast")106 .callback(this, &Engine::changedEnableMotionBlur);107 SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)108 .description("Defines the strength of the motion blur effect");109 100 } 110 101 … … 202 193 } 203 194 204 this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd()))); 205 206 this->ship_->setSteeringDirection(Vector3::ZERO); 207 208 if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController()) 209 { 210 this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager()); 211 this->boostBlur_->setCompositorName("Radial Blur"); 212 } 213 214 if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1) 215 { 216 float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f); 217 218 this->boostBlur_->setVisible(blur > 0); 219 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur); 195 // NOTE: Bullet always uses global coordinates. 196 this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_); 197 198 // Hack to reset a temporary variable "direction" 199 this->ship_->oneEngineTickDone(); 200 if(!this->ship_->hasEngineTicksRemaining()) 201 { 202 this->ship_->setSteeringDirection(Vector3::ZERO); 203 this->ship_->resetEngineTicks(); 220 204 } 221 205 } … … 224 208 { 225 209 SUPER(Engine, changedActivity); 226 227 if (this->boostBlur_)228 this->boostBlur_->setVisible(this->isVisible());229 210 } 230 211 … … 236 217 { 237 218 this->shipID_ = ship->getObjectID(); 238 if (ship->getEngine() != this) 239 ship->setEngine(this); 240 241 if (this->boostBlur_) 242 { 243 this->boostBlur_->destroy(); 244 this->boostBlur_ = 0; 245 } 219 if (!ship->hasEngine(this)) 220 ship->addEngine(this); 246 221 } 247 222 } … … 265 240 } 266 241 267 void Engine::changedEnableMotionBlur() 268 { 269 if (!this->bEnableMotionBlur_) 270 { 271 this->boostBlur_->destroy(); 272 this->boostBlur_ = 0; 242 void Engine::loadEngineTemplate() 243 { 244 if(!this->engineTemplate_.empty()) 245 { 246 COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n"; 247 Template *temp = Template::getTemplate(this->engineTemplate_); 248 if(temp) 249 { 250 this->addTemplate(temp); 251 } 273 252 } 274 253 } -
code/branches/presentation/src/orxonox/items/Engine.h
r8079 r8589 54 54 inline SpaceShip* getShip() const 55 55 { return this->ship_; } 56 57 inline void setRelativePosition(const Vector3 &position) 58 { this->relativePosition_ = position; } 59 inline Vector3& getRelativePosition() 60 { return this->relativePosition_; } 56 61 57 62 inline void setBoostFactor(float factor) … … 119 124 { this->speedMultiply_=speedMultiply; } 120 125 126 127 inline void setEngineTemplate(const std::string& temp) 128 { this->engineTemplate_ = temp; this->loadEngineTemplate(); } 129 inline const std::string& getEngineTemplate() const 130 { return this->engineTemplate_; } 131 121 132 protected: 122 133 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const 123 134 { return new std::vector<PickupCarrier*>(); } 124 135 virtual PickupCarrier* getCarrierParent(void) const; 136 137 void loadEngineTemplate(); 125 138 126 139 private: 127 140 void registerVariables(); 128 141 void networkcallback_shipID(); 129 void changedEnableMotionBlur(); 142 143 std::string engineTemplate_; 130 144 131 145 SpaceShip* ship_; 132 146 unsigned int shipID_; 147 Vector3 relativePosition_; 133 148 134 149 float boostFactor_; … … 148 163 float accelerationLeftRight_; 149 164 float accelerationUpDown_; 150 151 Shader* boostBlur_;152 float blurStrength_;153 bool bEnableMotionBlur_;154 165 }; 155 166 } -
code/branches/presentation/src/orxonox/worldentities/MobileEntity.cc
r7163 r8589 143 143 { 144 144 if (this->isDynamic()) 145 { 145 146 this->physicalBody_->applyCentralForce(btVector3(acceleration.x * this->getMass(), acceleration.y * this->getMass(), acceleration.z * this->getMass())); 146 147 } 148 149 // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement) 147 150 this->linearAcceleration_ = acceleration; 151 } 152 153 void MobileEntity::addAcceleration(const Vector3 &acceleration, const Vector3 &relativePosition) 154 { 155 if(this->isDynamic()) 156 { 157 this->physicalBody_->applyForce(this->getMass() * btVector3(acceleration.x, acceleration.y, acceleration.z), btVector3(relativePosition.x, relativePosition.y, relativePosition.z)); 158 } 148 159 } 149 160 -
code/branches/presentation/src/orxonox/worldentities/MobileEntity.h
r5781 r8589 70 70 { return this->linearAcceleration_; } 71 71 72 // Added for making N engines work with spaceships 73 void addAcceleration(const Vector3& acceleration, const Vector3 &relativePosition); 74 inline void addAcceleration(float x, float y, float z) 75 { this->addAcceleration(Vector3(x, y, z), Vector3(0,0,0)); } 76 // Getter function above 77 72 78 void setAngularAcceleration(const Vector3& acceleration); 73 79 inline void setAngularAcceleration(float x, float y, float z) -
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
r8587 r8589 35 35 #include "core/Template.h" 36 36 #include "core/XMLPort.h" 37 #include "tools/Shader.h" 38 #include "util/Math.h" 39 40 #include "graphics/Camera.h" 37 41 #include "items/Engine.h" 38 #include "graphics/Camera.h" 42 39 43 #include "CameraManager.h" 40 #include " util/Math.h"44 #include "Scene.h" 41 45 42 46 namespace orxonox … … 45 49 CreateFactory(SpaceShip); 46 50 47 SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator) 51 SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator), boostBlur_(NULL) 48 52 { 49 53 RegisterObject(SpaceShip); … … 57 61 this->bBoost_ = false; 58 62 this->steering_ = Vector3::ZERO; 59 this->engine_ = 0;60 63 61 64 this->boostPower_ = 10.0f; … … 76 79 this->enableCollisionCallback(); 77 80 81 this->engineTicksNotDone = 0; 78 82 this->setConfigValues(); 79 83 this->registerVariables(); … … 89 93 SpaceShip::~SpaceShip() 90 94 { 91 if (this->isInitialized() && this->engine_) 92 this->engine_->destroy(); 95 if (this->isInitialized()) 96 { 97 this->removeAllEngines(); 98 99 if (this->boostBlur_) 100 this->boostBlur_->destroy(); 101 } 93 102 } 94 103 … … 97 106 SUPER(SpaceShip, XMLPort, xmlelement, mode); 98 107 99 XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode);108 //XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode); 100 109 XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode); 101 110 XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); … … 105 114 XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode); 106 115 XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode); 107 116 XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode); 108 117 XMLPortParamVariable(SpaceShip, "shakeAmplitude", shakeAmplitude_, xmlelement, mode); 118 119 XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); 109 120 } 110 121 … … 126 137 { 127 138 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 139 140 SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true) 141 .description("Enable or disable the motion blur effect when moving very fast") 142 .callback(this, &SpaceShip::changedEnableMotionBlur); 143 SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f) 144 .description("Defines the strength of the motion blur effect"); 128 145 } 129 146 … … 146 163 if (this->hasLocalController()) 147 164 { 148 149 /* 150 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 151 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 152 if (this->localLinearAcceleration_.z() > 0) 153 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 154 else 155 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 156 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 157 this->localLinearAcceleration_.setValue(0, 0, 0); 158 */ 165 // Handle mouse look 159 166 if (!this->isInMouseLook()) 160 167 { … … 162 169 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 163 170 } 164 165 171 this->localAngularAcceleration_.setValue(0, 0, 0); 166 172 173 // Charge boostPower 167 174 if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_) 168 175 { 169 176 this->boostPower_ += this->boostPowerRate_*dt; 170 177 } 171 178 // Use boostPower 172 179 if(this->bBoost_) 173 180 { … … 178 185 this->bBoostCooldown_ = true; 179 186 this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this))); 180 181 187 } 182 188 183 189 this->shakeCamera(dt); 190 } 191 192 // Enable Blur depending on settings 193 if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->hasLocalController() && this->hasHumanController()) 194 { 195 this->boostBlur_ = new Shader(this->getScene()->getSceneManager()); 196 this->boostBlur_->setCompositorName("Radial Blur"); 197 } 198 199 if (this->boostBlur_) // && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1) 200 { 201 // TODO: this->maxSpeedFront_ gets fastest engine 202 float blur = this->blurStrength_ * clamp((-this->getLocalVelocity().z - 0.0f /*this->maxSpeedFront_*/) / ((150.0f /*boostFactor_*/ - 1) * 1.5f /*this->maxSpeedFront_*/), 0.0f, 1.0f); 203 204 // Show and hide blur effect depending on state of booster 205 if(this->bBoost_) 206 this->boostBlur_->setVisible(blur > 0); 207 else 208 this->boostBlur_->setVisible(false); 209 210 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur); 184 211 } 185 212 } … … 239 266 if(bBoost && !this->bBoostCooldown_) 240 267 { 241 //COUT(0) << "Boost startet!\n";242 268 this->bBoost_ = true; 243 269 Camera* camera = CameraManager::getInstance().getActiveCamera(); … … 247 273 if(!bBoost) 248 274 { 249 //COUT(0) << "Boost stoppt\n";275 this->bBoost_ = false; 250 276 this->resetCamera(); 251 this->bBoost_ = false; 252 } 253 } 254 277 } 278 } 279 255 280 void SpaceShip::boostCooledDown(void) 256 281 { … … 310 335 } 311 336 312 void SpaceShip::loadEngineTemplate() 313 { 314 if (!this->enginetemplate_.empty()) 315 { 316 Template* temp = Template::getTemplate(this->enginetemplate_); 317 318 if (temp) 319 { 320 Identifier* identifier = temp->getBaseclassIdentifier(); 321 322 if (identifier) 323 { 324 BaseObject* object = identifier->fabricate(this); 325 this->engine_ = orxonox_cast<Engine*>(object); 326 327 if (this->engine_) 328 { 329 this->engine_->addTemplate(temp); 330 this->engine_->addToSpaceShip(this); 331 } 332 else 333 { 334 object->destroy(); 335 } 336 } 337 } 338 } 339 } 340 341 void SpaceShip::setEngine(Engine* engine) 342 { 343 this->engine_ = engine; 344 if (engine && engine->getShip() != this) 345 engine->addToSpaceShip(this); 337 void SpaceShip::addEngine(orxonox::Engine* engine) 338 { 339 //COUT(0)<<"Adding an Engine: " << engine << endl; 340 this->engineList_.push_back(engine); 341 engine->addToSpaceShip(this); 342 this->resetEngineTicks(); 343 } 344 345 bool SpaceShip::hasEngine(Engine* engine) 346 { 347 for(unsigned int i=0; i<this->engineList_.size(); i++) 348 { 349 if(this->engineList_[i]==engine) 350 return true; 351 } 352 return false; 353 } 354 355 Engine* SpaceShip::getEngine(unsigned int i) 356 { 357 if(this->engineList_.size()>=i) 358 return 0; 359 else 360 return this->engineList_[i]; 361 } 362 363 void SpaceShip::removeAllEngines() 364 { 365 for(unsigned int i=0; i<this->engineList_.size(); i++) 366 this->engineList_[i]->~Engine(); 367 } 368 369 void SpaceShip::setSpeedFactor(float factor) 370 { 371 for(unsigned int i=0; i<this->engineList_.size(); i++) 372 this->engineList_[i]->setSpeedFactor(factor); 373 } 374 float SpaceShip::getSpeedFactor() // Calculate mean SpeedFactor. 375 { 376 float ret = 0; unsigned int i = 0; 377 for(; i<this->engineList_.size(); i++) 378 ret += this->engineList_[i]->getSpeedFactor(); 379 ret /= (float)i; 380 return ret; 381 } 382 float SpaceShip::getMaxSpeedFront() 383 { 384 float ret=0; 385 for(unsigned int i=0; i<this->engineList_.size(); i++) 386 { 387 if(this->engineList_[i]->getMaxSpeedFront() > ret) 388 ret = this->engineList_[i]->getMaxSpeedFront(); 389 } 390 return ret; 391 } 392 393 float SpaceShip::getBoostFactor() 394 { 395 float ret = 0; unsigned int i=0; 396 for(; i<this->engineList_.size(); i++) 397 ret += this->engineList_[i]->getBoostFactor(); 398 ret /= (float)i; 399 return ret; 346 400 } 347 401 … … 349 403 { 350 404 std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>(); 351 list->push_back(this->engine_); 405 for(unsigned int i=0; i<this->engineList_.size(); i++) 406 list->push_back(this->engineList_[i]); 352 407 return list; 353 408 } 354 409 410 void SpaceShip::changedEnableMotionBlur() 411 { 412 if (!this->bEnableMotionBlur_) 413 { 414 this->boostBlur_->destroy(); 415 this->boostBlur_ = 0; 416 } 417 } 355 418 356 419 } -
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
r8582 r8589 61 61 virtual void boost(bool bBoost); // Starts or stops boosting. 62 62 63 void setEngine(Engine* engine); 64 inline Engine* getEngine() const 65 { return this->engine_; } 63 void addEngine(Engine* engine); 64 bool hasEngine(Engine* engine); 65 Engine* getEngine(unsigned int i); // This one's for XMLPort 66 inline const std::vector<Engine*>& getEngineList() 67 { return this->engineList_; } 68 void removeAllEngines(); 69 70 void setSpeedFactor(float factor); 71 float getSpeedFactor(); // Gets mean speed factor 72 float getMaxSpeedFront(); // gets largest speed forward 73 float getBoostFactor(); // gets mean boost factor 66 74 67 75 inline void setSteeringDirection(const Vector3& direction) … … 69 77 inline const Vector3& getSteeringDirection() const 70 78 { return this->steering_; } 79 inline void resetEngineTicks() 80 { this->engineTicksNotDone = this->engineList_.size(); } 81 inline void oneEngineTickDone() 82 { this->engineTicksNotDone--; } 83 inline const bool hasEngineTicksRemaining() 84 { return (this->engineTicksNotDone>0); } 71 85 72 86 inline bool getBoost() const 73 87 { return this->bBoost_; } 74 75 inline void setEngineTemplate(const std::string& temp)76 { this->enginetemplate_ = temp; this->loadEngineTemplate(); }77 inline const std::string& getEngineTemplate() const78 { return this->enginetemplate_; }79 88 80 89 protected: … … 102 111 void registerVariables(); 103 112 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 104 105 void loadEngineTemplate();106 113 114 //All things booster 115 void changedEnableMotionBlur(); 107 116 void boostCooledDown(void); 108 117 … … 111 120 void shakeCamera(float dt); 112 121 113 std::string enginetemplate_; 114 Engine* engine_; 122 Shader* boostBlur_; 123 float blurStrength_; 124 bool bEnableMotionBlur_; 125 126 std::vector<Engine*> engineList_; 127 int engineTicksNotDone; // Used for knowing when to reset temporary variables. 115 128 Timer timer_; 116 129 Vector3 cameraOriginalPosition_;
Note: See TracChangeset
for help on using the changeset viewer.