- Timestamp:
- May 9, 2011, 2:59:07 PM (14 years ago)
- Location:
- code/branches/bigships
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/bigships/data/levels/templates/spaceshipAssff.oxt
r7845 r8426 3 3 hudtemplate = spaceshiphud 4 4 camerapositiontemplate = spaceshipassffcameras 5 engine = spaceshipassffengine6 5 spawnparticlesource = "Orxonox/fairytwirl" 7 6 spawnparticleduration = 3 … … 21 20 angularDamping = 0.9999999 22 21 > 22 <engines> 23 <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine /> 24 <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine /> 25 </engines> 23 26 <attached> 24 27 <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" /> … … 77 80 </EffectContainer> 78 81 <EffectContainer condition="not idle"> 79 <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 /> 80 <!-- 81 <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 /> 82 <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 /> 83 --> 82 <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 /> 83 <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 /> 84 84 </EffectContainer> 85 85 <EffectContainer condition="normal or brake"> … … 87 87 </EffectContainer> 88 88 <EffectContainer condition="normal or boost"> 89 <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" />90 <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" />89 <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" /> 90 <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" /> 91 91 </EffectContainer> 92 92 <EffectContainer condition="boost"> … … 94 94 <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" /> 95 95 </EffectContainer> 96 <EffectContainer condition="brake">96 <!-- <EffectContainer condition="brake"> 97 97 <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 /> 98 98 <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 /> … … 100 100 <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 /> 101 101 </EffectContainer> 102 --> 102 103 </MultiStateEngine> 103 104 </Template> -
code/branches/bigships/data/levels/templates/spaceshipGhost.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipH2.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipHXY.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipHXYSL.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipPirate.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipSwallow.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipTransporter.oxt
r7679 r8426 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/bigships/data/levels/templates/spaceshipTransporterSL.oxt
r7679 r8426 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/bigships/src/modules/overlays/hud/HUDSpeedBar.cc
r5781 r8426 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/bigships/src/orxonox/controllers/HumanController.cc
r8079 r8426 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"; 44 45 45 46 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); … … 51 52 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 52 53 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 53 SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold);54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress); 54 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 55 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 72 73 73 74 controlPaused_ = false; 75 this->boosting_ = false; 74 76 75 77 HumanController::localController_s = this; … … 163 165 } 164 166 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 167 /** 168 @brief 169 Static method,toggles boosting. 170 */ 171 /*static*/ void HumanController::toggleBoost() 172 { 173 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 174 HumanController::localController_s->toggleBoosting(); 175 } 176 177 /** 178 @brief 179 Toggles the boosting mode. 180 Changes the keybind mode of the boost console command and tells the ControllableEntity to boost (or not boost anymore). 181 */ 182 void HumanController::toggleBoosting(void) 183 { 184 this->boosting_ = !this->boosting_; 185 186 // The keybind mode of the boosting console command is onRelease if in boosting mode and onPress of not in boosting mode. 187 if(this->boosting_) 188 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnRelease); 189 else 190 ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress); 191 192 this->controllableEntity_->boost(this->boosting_); 169 193 } 170 194 -
code/branches/bigships/src/orxonox/controllers/HumanController.h
r8079 r8426 64 64 static void reload(); 65 65 66 static void boost(); 66 static void toggleBoost(); // Static method,toggles boosting. 67 /** 68 @brief Check whether the HumanController is in boosting mode. 69 @return Returns true if it is, false if not. 70 */ 71 inline bool isBoosting(void) 72 { return this->boosting_; } 73 void toggleBoosting(void); // Toggles the boosting mode. 74 67 75 static void greet(); 68 76 static void switchCamera(); … … 92 100 static HumanController* localController_s; 93 101 bool controlPaused_; 102 103 private: 104 bool boosting_; // Whether the HumanController is in boosting mode or not. 105 94 106 }; // tolua_export 95 107 } // tolua_export -
code/branches/bigships/src/orxonox/gametypes/Dynamicmatch.cc
r7284 r8426 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/bigships/src/orxonox/gametypes/Dynamicmatch.h
r7163 r8426 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/bigships/src/orxonox/items/Engine.cc
r8079 r8426 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; … … 75 74 if (this->isInitialized() && this->ship_) 76 75 { 77 this->ship_->setEngine(0);78 79 if (this->boostBlur_)80 this->boostBlur_->destroy();76 //this->ship_->setEngine(0); 77 78 //if (this->boostBlur_) 79 // this->boostBlur_->destroy(); 81 80 } 82 81 } … … 98 97 XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode); 99 98 XMLPortParam(Engine, "accelerationupdown", setAccelerationUpDown, setAccelerationUpDown, xmlelement, mode); 99 100 XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode); 101 XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode); 100 102 } 101 103 102 104 void Engine::setConfigValues() 103 105 { 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 106 } 110 107 … … 202 199 } 203 200 204 this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd()))); 205 206 if (!this->ship_->getPermanentBoost()) 207 this->ship_->setBoost(false); 208 this->ship_->setSteeringDirection(Vector3::ZERO); 209 210 if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController()) 211 { 212 this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager()); 213 this->boostBlur_->setCompositorName("Radial Blur"); 214 } 215 216 if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1) 217 { 218 float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f); 219 220 this->boostBlur_->setVisible(blur > 0); 221 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur); 222 } 201 // NOTE: Bullet always uses global coordinates. 202 this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_); 203 204 205 // Hack to reset a temporary variable "direction" 206 this->ship_->oneEngineTickDone(); 207 if(!this->ship_->hasEngineTicksRemaining()) 208 { 209 this->ship_->setSteeringDirection(Vector3::ZERO); 210 this->ship_->resetEngineTicks(); 211 } 223 212 } 224 213 … … 226 215 { 227 216 SUPER(Engine, changedActivity); 228 229 if (this->boostBlur_)230 this->boostBlur_->setVisible(this->isVisible());231 217 } 232 218 … … 238 224 { 239 225 this->shipID_ = ship->getObjectID(); 240 if (ship->getEngine() != this) 241 ship->setEngine(this); 242 243 if (this->boostBlur_) 244 { 245 this->boostBlur_->destroy(); 246 this->boostBlur_ = 0; 247 } 226 if (!ship->hasEngine(this)) 227 ship->addEngine(this); 248 228 } 249 229 } … … 267 247 } 268 248 269 void Engine::changedEnableMotionBlur() 270 { 271 if (!this->bEnableMotionBlur_) 272 { 273 this->boostBlur_->destroy(); 274 this->boostBlur_ = 0; 275 } 276 } 249 void Engine::loadEngineTemplate() 250 { 251 if(!this->engineTemplate_.empty()) 252 { 253 COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n"; 254 Template *temp = Template::getTemplate(this->engineTemplate_); 255 if(temp) 256 { 257 this->addTemplate(temp); 258 } 259 } 260 } 277 261 } -
code/branches/bigships/src/orxonox/items/Engine.h
r8079 r8426 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/bigships/src/orxonox/worldentities/ControllableEntity.cc
r7892 r8426 84 84 this->client_angular_velocity_ = Vector3::ZERO; 85 85 86 87 86 this->setConfigValues(); 88 87 this->setPriority( Priority::VeryHigh ); -
code/branches/bigships/src/orxonox/worldentities/ControllableEntity.h
r7889 r8426 93 93 virtual void reload() {} 94 94 95 virtual void boost() {} 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 96 102 virtual void greet() {} 97 103 virtual void switchCamera(); -
code/branches/bigships/src/orxonox/worldentities/MobileEntity.cc
r7163 r8426 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; 148 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 } 159 } 149 160 150 161 void MobileEntity::setAngularAcceleration(const Vector3& acceleration) -
code/branches/bigships/src/orxonox/worldentities/MobileEntity.h
r5781 r8426 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/bigships/src/orxonox/worldentities/pawns/SpaceShip.cc
r7860 r8426 37 37 #include "items/Engine.h" 38 38 39 // New as of Booster integration 40 #include "Scene.h" 41 #include "tools/Shader.h" 42 39 43 namespace orxonox 40 44 { … … 53 57 this->localAngularAcceleration_.setValue(0, 0, 0); 54 58 this->bBoost_ = false; 55 this->bPermanentBoost_ = false;56 59 this->steering_ = Vector3::ZERO; 57 this->engine_ = 0; 60 //this->engine_ = 0; 61 62 this->boostBlur_ = 0; 58 63 59 64 this->boostPower_ = 10.0f; … … 74 79 this->enableCollisionCallback(); 75 80 81 this->engineTicksNotDone = 0; 76 82 this->setConfigValues(); 77 83 this->registerVariables(); … … 80 86 SpaceShip::~SpaceShip() 81 87 { 82 if (this->isInitialized() && this->engine_) 83 this->engine_->destroy(); 88 if (this->isInitialized()) 89 this->removeAllEngines(); 90 91 if (this->boostBlur_) 92 this->boostBlur_->destroy(); 84 93 } 85 94 … … 88 97 SUPER(SpaceShip, XMLPort, xmlelement, mode); 89 98 90 XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode);99 //XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode); 91 100 XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode); 92 101 XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); … … 96 105 XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode); 97 106 XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode); 107 108 XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); 98 109 } 99 110 … … 103 114 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 104 115 registerVariable(this->rotationThrust_, VariableDirection::ToClient); 116 registerVariable(this->boostPower_, VariableDirection::ToClient); 117 registerVariable(this->boostPowerRate_, VariableDirection::ToClient); 118 registerVariable(this->boostRate_, VariableDirection::ToClient); 119 registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient); 105 120 } 106 121 … … 108 123 { 109 124 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 125 126 SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true) 127 .description("Enable or disable the motion blur effect when moving very fast") 128 .callback(this, &SpaceShip::changedEnableMotionBlur); 129 SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f) 130 .description("Defines the strength of the motion blur effect"); 110 131 } 111 132 … … 128 149 if (this->hasLocalController()) 129 150 { 130 /* 131 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 132 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 133 if (this->localLinearAcceleration_.z() > 0) 134 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 135 else 136 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 137 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 138 this->localLinearAcceleration_.setValue(0, 0, 0); 139 */ 151 // Handle mouse look 140 152 if (!this->isInMouseLook()) 141 153 { … … 143 155 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 144 156 } 145 146 157 this->localAngularAcceleration_.setValue(0, 0, 0); 147 158 159 // Charge boostPower 148 160 if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_) 149 161 { 150 162 this->boostPower_ += this->boostPowerRate_*dt; 151 163 } 164 // Use boostPower 152 165 if(this->bBoost_) 153 166 { … … 160 173 } 161 174 } 175 176 // Enable Blur depending on settings 177 if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->hasLocalController() && this->hasHumanController()) 178 { 179 this->boostBlur_ = new Shader(this->getScene()->getSceneManager()); 180 this->boostBlur_->setCompositorName("Radial Blur"); 181 } 182 183 if (this->boostBlur_) // && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1) 184 { 185 // TODO: this->maxSpeedFront_ gets fastest engine 186 float blur = this->blurStrength_ * clamp((-this->getLocalVelocity().z - 0.0f /*this->maxSpeedFront_*/) / ((150.0f /*boostFactor_*/ - 1) * 1.5f /*this->maxSpeedFront_*/), 0.0f, 1.0f); 187 188 // Show and hide blur effect depending on state of booster 189 if(this->bBoost_) 190 this->boostBlur_->setVisible(blur > 0); 191 else 192 this->boostBlur_->setVisible(false); 193 194 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur); 195 } 162 196 } 163 197 } … … 207 241 } 208 242 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 243 void SpaceShip::fire() 244 { 245 } 246 247 /** 248 @brief 249 Starts or stops boosting. 250 @param bBoost 251 Whether to start or stop boosting. 252 */ 253 void SpaceShip::boost(bool bBoost) 254 { 255 if(bBoost && !this->bBoostCooldown_) 256 this->bBoost_ = true; 257 if(!bBoost) 258 this->bBoost_ = false; 259 } 260 261 void SpaceShip::addEngine(orxonox::Engine* engine) 262 { 263 //COUT(0)<<"Adding an Engine: " << engine << endl; 264 this->engineList_.push_back(engine); 265 engine->addToSpaceShip(this); 266 this->resetEngineTicks(); 267 } 268 bool SpaceShip::hasEngine(Engine* engine) 269 { 270 for(unsigned int i=0; i<this->engineList_.size(); i++) 271 { 272 if(this->engineList_[i]==engine) 273 return true; 274 } 275 return false; 276 } 277 Engine* SpaceShip::getEngine(unsigned int i) 278 { 279 if(this->engineList_.size()>=i) 280 return 0; 281 else 282 return this->engineList_[i]; 283 } 284 void SpaceShip::removeAllEngines() 285 { 286 for(unsigned int i=0; i<this->engineList_.size(); i++) 287 this->engineList_[i]->~Engine(); 288 } 289 290 void SpaceShip::setSpeedFactor(float factor) 291 { 292 for(unsigned int i=0; i<this->engineList_.size(); i++) 293 this->engineList_[i]->setSpeedFactor(factor); 294 } 295 float SpaceShip::getSpeedFactor() // Calculate mean SpeedFactor. 296 { 297 float ret = 0; unsigned int i = 0; 298 for(; i<this->engineList_.size(); i++) 299 ret += this->engineList_[i]->getSpeedFactor(); 300 ret /= (float)i; 301 return ret; 302 } 303 float SpaceShip::getMaxSpeedFront() 304 { 305 float ret=0; 306 for(unsigned int i=0; i<this->engineList_.size(); i++) 307 { 308 if(this->engineList_[i]->getMaxSpeedFront() > ret) 309 ret = this->engineList_[i]->getMaxSpeedFront(); 310 } 311 return ret; 312 } 313 float SpaceShip::getBoostFactor() 314 { 315 float ret = 0; unsigned int i=0; 316 for(; i<this->engineList_.size(); i++) 317 ret += this->engineList_[i]->getBoostFactor(); 318 ret /= (float)i; 319 return ret; 320 } 321 322 std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) const 323 { 324 std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>(); 325 for(unsigned int i=0; i<this->engineList_.size(); i++) 326 list->push_back(this->engineList_[i]); 327 return list; 328 } 329 330 void SpaceShip::changedEnableMotionBlur() 331 { 332 if (!this->bEnableMotionBlur_) 218 333 { 219 this->bBoost_ = false; 334 this->boostBlur_->destroy(); 335 this->boostBlur_ = 0; 220 336 } 221 337 } 222 338 223 void SpaceShip::fire()224 {225 }226 227 void SpaceShip::boost()228 {229 if(!this->bBoostCooldown_)230 this->bBoost_ = true;231 }232 233 void SpaceShip::loadEngineTemplate()234 {235 if (!this->enginetemplate_.empty())236 {237 Template* temp = Template::getTemplate(this->enginetemplate_);238 239 if (temp)240 {241 Identifier* identifier = temp->getBaseclassIdentifier();242 243 if (identifier)244 {245 BaseObject* object = identifier->fabricate(this);246 this->engine_ = orxonox_cast<Engine*>(object);247 248 if (this->engine_)249 {250 this->engine_->addTemplate(temp);251 this->engine_->addToSpaceShip(this);252 }253 else254 {255 object->destroy();256 }257 }258 }259 }260 }261 262 void SpaceShip::setEngine(Engine* engine)263 {264 this->engine_ = engine;265 if (engine && engine->getShip() != this)266 engine->addToSpaceShip(this);267 }268 269 std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) const270 {271 std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>();272 list->push_back(this->engine_);273 return list;274 }275 339 } -
code/branches/bigships/src/orxonox/worldentities/pawns/SpaceShip.h
r7801 r8426 59 59 60 60 virtual void fire(); 61 virtual void boost( );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 void setBoost(bool bBoost);73 86 inline bool getBoost() const 74 87 { return this->bBoost_; } 75 76 inline void setEngineTemplate(const std::string& temp)77 { this->enginetemplate_ = temp; this->loadEngineTemplate(); }78 inline const std::string& getEngineTemplate() const79 { return this->enginetemplate_; }80 81 inline void setPermanentBoost(bool bPermanent)82 { this->bPermanentBoost_ = bPermanent; }83 inline bool getPermanentBoost() const84 { return this->bPermanentBoost_; }85 88 86 89 protected: … … 90 93 bool bBoost_; 91 94 bool bBoostCooldown_; 92 bool bPermanentBoost_;93 95 float boostPower_; 94 96 float initialBoostPower_; … … 106 108 void registerVariables(); 107 109 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 108 109 void loadEngineTemplate();110 110 111 //All things booster 112 void changedEnableMotionBlur(); 111 113 void boostCooledDown(void); 112 114 113 std::string enginetemplate_; 114 Engine* engine_; 115 Shader* boostBlur_; 116 float blurStrength_; 117 bool bEnableMotionBlur_; 118 119 std::vector<Engine*> engineList_; 120 int engineTicksNotDone; // Used for knowing when to reset temporary variables. 115 121 Timer timer_; 116 122 };
Note: See TracChangeset
for help on using the changeset viewer.