Changeset 8588
- Timestamp:
- May 26, 2011, 12:04:42 AM (14 years ago)
- Location:
- code/branches/bigships/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/bigships/src/orxonox/gametypes/Dynamicmatch.cc
r8426 r8588 151 151 //Give new pig boost 152 152 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim); 153 153 grantPigBoost(spaceship); 154 154 } 155 155 … … 306 306 } 307 307 308 309 310 308 void Dynamicmatch::grantPigBoost(orxonox::SpaceShip* spaceship) 309 { 310 // Give pig boost 311 311 if (spaceship) 312 312 { … … 317 317 new Timer(10, false, executor, true); 318 318 } 319 319 } 320 320 321 321 void Dynamicmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) //set party + colouring -
code/branches/bigships/src/orxonox/gametypes/Dynamicmatch.h
r8426 r8588 73 73 virtual void furtherInstructions();*/ 74 74 virtual void rewardPig(); 75 75 void grantPigBoost(SpaceShip* spaceship); // Added this, since it's used twice on different occasions. 76 76 void resetSpeedFactor(WeakPtr<SpaceShip>* ptr); 77 77 void tick (float dt);// used to end the game -
code/branches/bigships/src/orxonox/items/Engine.cc
r8426 r8588 47 47 this->ship_ = 0; 48 48 this->shipID_ = OBJECTID_UNKNOWN; 49 49 this->relativePosition_ = Vector3(0,0,0); 50 50 51 51 this->boostFactor_ = 1.5; … … 72 72 Engine::~Engine() 73 73 { 74 if (this->isInitialized() && this->ship_) 75 { 76 //this->ship_->setEngine(0); 77 78 //if (this->boostBlur_) 79 // this->boostBlur_->destroy(); 80 } 74 81 75 } 82 76 … … 98 92 XMLPortParam(Engine, "accelerationupdown", setAccelerationUpDown, setAccelerationUpDown, xmlelement, mode); 99 93 100 101 94 XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode); 95 XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode); 102 96 } 103 97 … … 199 193 } 200 194 201 195 // NOTE: Bullet always uses global coordinates. 202 196 this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_); 203 197 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 } 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(); 204 } 212 205 } 213 206 … … 247 240 } 248 241 249 250 251 252 253 254 255 256 257 258 259 260 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 } 252 } 253 } 261 254 } -
code/branches/bigships/src/orxonox/items/Engine.h
r8426 r8588 55 55 { return this->ship_; } 56 56 57 58 59 60 57 inline void setRelativePosition(const Vector3 &position) 58 { this->relativePosition_ = position; } 59 inline Vector3& getRelativePosition() 60 { return this->relativePosition_; } 61 61 62 62 inline void setBoostFactor(float factor) … … 124 124 { this->speedMultiply_=speedMultiply; } 125 125 126 126 127 127 inline void setEngineTemplate(const std::string& temp) 128 128 { this->engineTemplate_ = temp; this->loadEngineTemplate(); } … … 134 134 { return new std::vector<PickupCarrier*>(); } 135 135 virtual PickupCarrier* getCarrierParent(void) const; 136 136 137 137 void loadEngineTemplate(); 138 138 … … 141 141 void networkcallback_shipID(); 142 142 143 143 std::string engineTemplate_; 144 144 145 145 SpaceShip* ship_; 146 146 unsigned int shipID_; 147 147 Vector3 relativePosition_; 148 148 149 149 float boostFactor_; -
code/branches/bigships/src/orxonox/worldentities/MobileEntity.cc
r8426 r8588 143 143 { 144 144 if (this->isDynamic()) 145 145 { 146 146 this->physicalBody_->applyCentralForce(btVector3(acceleration.x * this->getMass(), acceleration.y * this->getMass(), acceleration.z * this->getMass())); 147 148 149 147 } 148 149 // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement) 150 150 this->linearAcceleration_ = acceleration; 151 151 } 152 152 153 154 155 156 157 158 159 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 } 160 160 161 161 void MobileEntity::setAngularAcceleration(const Vector3& acceleration) -
code/branches/bigships/src/orxonox/worldentities/MobileEntity.h
r8426 r8588 70 70 { return this->linearAcceleration_; } 71 71 72 73 74 75 76 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 77 78 78 void setAngularAcceleration(const Vector3& acceleration); -
code/branches/bigships/src/orxonox/worldentities/pawns/SpaceShip.cc
r8504 r8588 77 77 this->enableCollisionCallback(); 78 78 79 79 this->engineTicksNotDone = 0; 80 80 this->setConfigValues(); 81 81 this->registerVariables(); … … 87 87 { 88 88 this->removeAllEngines(); 89 89 90 90 if (this->boostBlur_) 91 91 this->boostBlur_->destroy(); … … 106 106 XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode); 107 107 108 108 XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); 109 109 } 110 110 … … 123 123 { 124 124 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 125 125 126 126 SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true) 127 127 .description("Enable or disable the motion blur effect when moving very fast") … … 149 149 if (this->hasLocalController()) 150 150 { 151 151 // Handle mouse look 152 152 if (!this->isInMouseLook()) 153 153 { … … 157 157 this->localAngularAcceleration_.setValue(0, 0, 0); 158 158 159 159 // Charge boostPower 160 160 if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_) 161 161 { 162 162 this->boostPower_ += this->boostPowerRate_*dt; 163 163 } 164 164 // Use boostPower 165 165 if(this->bBoost_) 166 166 { … … 174 174 } 175 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 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 } 196 196 } 197 197 } … … 259 259 } 260 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 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 321 322 322 std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) const 323 323 { 324 324 std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>(); 325 326 325 for(unsigned int i=0; i<this->engineList_.size(); i++) 326 list->push_back(this->engineList_[i]); 327 327 return list; 328 328 } 329 330 329 330 void SpaceShip::changedEnableMotionBlur() 331 331 { 332 332 if (!this->bEnableMotionBlur_) -
code/branches/bigships/src/orxonox/worldentities/pawns/SpaceShip.h
r8426 r8588 61 61 virtual void boost(bool bBoost); // Starts or stops boosting. 62 62 63 64 65 66 67 68 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 69 70 71 72 73 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 74 74 75 75 inline void setSteeringDirection(const Vector3& direction) … … 77 77 inline const Vector3& getSteeringDirection() const 78 78 { return this->steering_; } 79 80 81 82 83 84 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); } 85 85 86 86 inline bool getBoost() const … … 109 109 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 110 110 111 112 111 //All things booster 112 void changedEnableMotionBlur(); 113 113 void boostCooledDown(void); 114 114 115 115 Shader* boostBlur_; 116 116 float blurStrength_; 117 117 bool bEnableMotionBlur_; 118 118 119 120 119 std::vector<Engine*> engineList_; 120 int engineTicksNotDone; // Used for knowing when to reset temporary variables. 121 121 Timer timer_; 122 122 };
Note: See TracChangeset
for help on using the changeset viewer.