- Timestamp:
- Nov 16, 2008, 7:10:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.cc
r2207 r2212 66 66 67 67 this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName()); 68 this->ribbonTrail_->addNode(this->getNode()); 68 69 69 this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 70 70 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 71 72 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 73 this->ribbonTrail_->setTrailLength(this->length_); 71 74 this->ribbonTrail_->setInitialWidth(0, 0); 72 75 } … … 123 126 { 124 127 if (this->ribbonTrail_ && this->tickcount_ >= 2) 125 this->ribbonTrail_->setInitialWidth(0, this->width_ );128 this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getWorldScale()); 126 129 this->update_lifetime(); 127 130 } … … 131 134 if (this->ribbonTrail_ && this->tickcount_ >= 2) 132 135 { 133 this->ribbonTrail_->setWidthChange(0, this->width_ / this->lifetime_/* * Backlight::timeFactor_s*/);136 this->ribbonTrail_->setWidthChange(0, this->width_ * this->getWorldScale() / this->lifetime_/* * Backlight::timeFactor_s*/); 134 137 this->ribbonTrail_->setColourChange(0, 0, 0, 0, 1.0f / this->lifetime_/* * Backlight::timeFactor_s*/); 135 138 } … … 139 142 { 140 143 if (this->ribbonTrail_ && this->tickcount_ >= 2) 141 this->ribbonTrail_->setTrailLength(this->length_ );144 this->ribbonTrail_->setTrailLength(this->length_ * this->getWorldScale()); 142 145 } 143 146 … … 176 179 } 177 180 } 181 } 182 183 void Backlight::changedScale() 184 { 185 SUPER(Backlight, changedScale); 186 187 this->update_width(); 188 this->update_length(); 178 189 } 179 190 … … 196 207 this->update_maxelements(); 197 208 this->update_trailmaterial(); 209 if (this->ribbonTrail_) 210 this->ribbonTrail_->addNode(this->getNode()); 198 211 } 199 212 } … … 204 217 } 205 218 } 206 207 //------------------------------------------------------------------------------------208 /*209 float Backlight::timeFactor_s = 1.0;210 211 Backlight::Backlight(float maxspeed, float brakingtime, float scale)212 {213 RegisterObject(Backlight);214 215 this->setConfigValues();216 this->traillength_ = 1;217 this->colour_ = ColourValue::White;218 219 this->configure(maxspeed, brakingtime, scale);220 }221 222 bool Backlight::create(){223 if(!WorldEntity::create())224 return false;225 226 this->getNode()->setInheritScale(false);227 228 this->billboard_.setBillboardSet("Flares/backlightflare");229 this->attachObject(this->billboard_.getBillboardSet());230 231 this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");232 this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");233 this->ribbonTrailNode_->attachObject(this->ribbonTrail_);234 this->ribbonTrail_->addNode(this->getNode());235 236 237 this->ribbonTrail_->setTrailLength(this->maxTraillength_);238 this->ribbonTrail_->setMaterialName("Trail/backlighttrail");239 240 //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());241 this->setTimeFactor(1.0f);242 243 this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);244 this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);245 this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());246 this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);247 return true;248 }249 250 Backlight::~Backlight()251 {252 if (this->isInitialized())253 {254 this->detachObject(this->billboard_.getBillboardSet());255 GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");256 GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);257 }258 }259 260 void Backlight::setConfigValues()261 {262 SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");263 SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");264 SetConfigValue(width_, 7.0).description("The width of the trail");265 }266 267 void Backlight::setTimeFactor(float factor)268 {269 Backlight::timeFactor_s = factor;270 float change = Backlight::timeFactor_s / this->maxLifeTime_;271 this->ribbonTrail_->setWidthChange(0, this->width_ * change);272 this->updateColourChange();273 }274 275 void Backlight::updateColourChange()276 {277 this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));278 }279 280 void Backlight::tick(float dt)281 {282 SUPER(Backlight, tick, dt);283 284 if (this->isActive())285 {286 if (this->traillength_ < this->maxTraillength_)287 {288 this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);289 this->updateColourChange();290 }291 }292 else293 {294 if (this->traillength_ > 1)295 {296 this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);297 this->updateColourChange();298 }299 }300 301 this->ribbonTrail_->setTrailLength(this->traillength_);302 }303 304 void Backlight::configure(float maxspeed, float brakingtime, float scale)305 {306 this->maxTraillength_ = this->maxLifeTime_ * maxspeed;307 this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);308 309 this->brakefactor_ = this->maxLifeTime_ / brakingtime;310 311 this->scale(scale);312 }313 314 void Backlight::changedVisibility()315 {316 SUPER(Backlight, changedVisibility);317 318 this->billboard_.setVisible(this->isVisible());319 this->ribbonTrail_->setVisible(this->isVisible());320 }321 */322 219 }
Note: See TracChangeset
for help on using the changeset viewer.