- Timestamp:
- Nov 24, 2008, 1:50:47 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.cc
r2212 r2254 43 43 CreateFactory(Backlight); 44 44 45 Backlight::Backlight(BaseObject* creator) : Billboard(creator)45 Backlight::Backlight(BaseObject* creator) : FadingBillboard(creator) 46 46 { 47 47 RegisterObject(Backlight); … … 53 53 this->length_ = 1.0f; 54 54 this->lifetime_ = 0.001f; 55 this->turnofftime_ = 0.5f;56 this->bTurningOff_ = false;57 55 this->maxelements_ = 1; 58 56 … … 102 100 XMLPortParam(Backlight, "elements", setMaxElements, getMaxElements, xmlelement, mode).defaultValues(10); 103 101 XMLPortParam(Backlight, "lifetime", setLifetime, getLifetime, xmlelement, mode).defaultValues(1.0f); 104 XMLPortParam(Backlight, "turnofftime", setTurnOffTime, getTurnOffTime, xmlelement, mode).defaultValues(0.5f);105 102 XMLPortParam(Backlight, "trailmaterial", setTrailMaterial, getTrailMaterial, xmlelement, mode); 106 103 } … … 117 114 void Backlight::changedColour() 118 115 { 119 Billboard::changedColour();120 121 if (this->ribbonTrail_ && this-> isActive() && this->tickcount_ >= 2)122 this->ribbonTrail_->setInitialColour(0, this->get Colour());116 FadingBillboard::changedColour(); 117 118 if (this->ribbonTrail_ && this->tickcount_ >= 2) 119 this->ribbonTrail_->setInitialColour(0, this->getFadedColour()); 123 120 } 124 121 … … 165 162 } 166 163 167 void Backlight::changedActivity() 168 { 169 SUPER(Backlight, changedActivity); 164 void Backlight::startturnonoff() 165 { 166 FadingBillboard::startturnonoff(); 167 168 if (this->ribbonTrail_ && this->isActive() && this->isVisible()) 169 this->ribbonTrail_->setVisible(true); 170 } 171 172 void Backlight::stopturnonoff() 173 { 174 this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_); 175 176 FadingBillboard::stopturnonoff(); 170 177 171 178 if (this->ribbonTrail_) 172 {173 if (this->isActive())174 this->ribbonTrail_->setInitialColour(0, this->getColour()); 175 else176 177 this->bTurningOff_ = true;178 this->turnofftimer_.setTimer(this->turnofftime_, false, this, createExecutor(createFunctor(&Backlight::stopturnoff))); 179 }180 }179 this->ribbonTrail_->setInitialColour(0, this->getFadedColour()); 180 } 181 182 void Backlight::poststopturnonoff() 183 { 184 FadingBillboard::poststopturnonoff(); 185 186 if (this->ribbonTrail_) 187 this->ribbonTrail_->setVisible(false); 181 188 } 182 189 … … 187 194 this->update_width(); 188 195 this->update_length(); 189 }190 191 void Backlight::stopturnoff()192 {193 this->bTurningOff_ = false;194 196 } 195 197 … … 212 214 } 213 215 214 if (this->bTurningOff_ && this->ribbonTrail_) 215 { 216 this->ribbonTrail_->setInitialColour(0, this->ribbonTrail_->getInitialColour(0) - this->getColour() / this->turnofftime_ * dt); 216 SUPER(Backlight, tick, dt); 217 218 if (this->ribbonTrail_ && this->changedirection_ != 0) 219 { 220 // we use alpha_blend, only adjust alpha 221 const ColourValue& colour = this->getColour(); 222 this->ribbonTrail_->setInitialColour(0, colour.r, colour.g, colour.b, this->getFadedColour().a); 217 223 } 218 224 }
Note: See TracChangeset
for help on using the changeset viewer.