Changeset 8588 for code/branches/bigships/src/orxonox/worldentities
- Timestamp:
- May 26, 2011, 12:04:42 AM (14 years ago)
- Location:
- code/branches/bigships/src/orxonox/worldentities
- Files:
-
- 4 edited
-
MobileEntity.cc (modified) (1 diff)
-
MobileEntity.h (modified) (1 diff)
-
pawns/SpaceShip.cc (modified) (8 diffs)
-
pawns/SpaceShip.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement)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 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 }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 // Added for making N engines work with spaceships73 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 above72 // 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 this->engineTicksNotDone = 0;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 XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode);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 // Handle mouse look151 // Handle mouse look 152 152 if (!this->isInMouseLook()) 153 153 { … … 157 157 this->localAngularAcceleration_.setValue(0, 0, 0); 158 158 159 // Charge boostPower159 // Charge boostPower 160 160 if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_) 161 161 { 162 162 this->boostPower_ += this->boostPowerRate_*dt; 163 163 } 164 // Use boostPower164 // Use boostPower 165 165 if(this->bBoost_) 166 166 { … … 174 174 } 175 175 176 // Enable Blur depending on settings177 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 engine186 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 booster189 if(this->bBoost_)190 this->boostBlur_->setVisible(blur > 0);191 else192 this->boostBlur_->setVisible(false);193 194 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);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 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 else282 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 }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 for(unsigned int i=0; i<this->engineList_.size(); i++)326 list->push_back(this->engineList_[i]);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 void SpaceShip::changedEnableMotionBlur()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 void addEngine(Engine* engine);64 bool hasEngine(Engine* engine);65 Engine* getEngine(unsigned int i); // This one's for XMLPort66 inline const std::vector<Engine*>& getEngineList()67 { return this->engineList_; }68 void removeAllEngines();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 void setSpeedFactor(float factor);71 float getSpeedFactor(); // Gets mean speed factor72 float getMaxSpeedFront(); // gets largest speed forward73 float getBoostFactor(); // gets mean boost factor70 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 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); }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 //All things booster112 void changedEnableMotionBlur();111 //All things booster 112 void changedEnableMotionBlur(); 113 113 void boostCooledDown(void); 114 114 115 Shader* boostBlur_;115 Shader* boostBlur_; 116 116 float blurStrength_; 117 117 bool bEnableMotionBlur_; 118 118 119 std::vector<Engine*> engineList_;120 int engineTicksNotDone; // Used for knowing when to reset temporary variables.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.










