Changeset 2207
- Timestamp:
- Nov 14, 2008, 1:47:33 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects/worldentities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.cc
r2182 r2207 35 35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 #include "core/Executor.h" 37 38 #include "core/XMLPort.h" 38 39 #include "objects/Scene.h" … … 51 52 this->width_ = 0; 52 53 this->length_ = 1.0f; 53 this->lifetime_ = 1.0f; 54 this->lifetime_ = 0.001f; 55 this->turnofftime_ = 0.5f; 56 this->bTurningOff_ = false; 54 57 this->maxelements_ = 1; 58 59 this->tickcount_ = 0; 55 60 56 61 if (Core::showsGraphics()) … … 61 66 62 67 this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName()); 68 this->ribbonTrail_->addNode(this->getNode()); 63 69 this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 64 70 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 65 this->ribbonTrail_->addNode(this->getNode()); 66 67 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 68 this->ribbonTrail_->setTrailLength(this->length_); 69 this->ribbonTrail_->setInitialWidth(0, this->width_); 71 this->ribbonTrail_->setInitialWidth(0, 0); 70 72 } 71 73 … … 97 99 XMLPortParam(Backlight, "elements", setMaxElements, getMaxElements, xmlelement, mode).defaultValues(10); 98 100 XMLPortParam(Backlight, "lifetime", setLifetime, getLifetime, xmlelement, mode).defaultValues(1.0f); 101 XMLPortParam(Backlight, "turnofftime", setTurnOffTime, getTurnOffTime, xmlelement, mode).defaultValues(0.5f); 99 102 XMLPortParam(Backlight, "trailmaterial", setTrailMaterial, getTrailMaterial, xmlelement, mode); 100 103 } … … 113 116 Billboard::changedColour(); 114 117 115 if (this->ribbonTrail_ && this->isActive() )118 if (this->ribbonTrail_ && this->isActive() && this->tickcount_ >= 2) 116 119 this->ribbonTrail_->setInitialColour(0, this->getColour()); 117 120 } … … 119 122 void Backlight::update_width() 120 123 { 121 if (this->ribbonTrail_ )124 if (this->ribbonTrail_ && this->tickcount_ >= 2) 122 125 this->ribbonTrail_->setInitialWidth(0, this->width_); 123 126 this->update_lifetime(); … … 126 129 void Backlight::update_lifetime() 127 130 { 128 if (this->ribbonTrail_ )131 if (this->ribbonTrail_ && this->tickcount_ >= 2) 129 132 { 130 133 this->ribbonTrail_->setWidthChange(0, this->width_ / this->lifetime_/* * Backlight::timeFactor_s*/); … … 135 138 void Backlight::update_length() 136 139 { 137 // if (this->ribbonTrail_)138 //this->ribbonTrail_->setTrailLength(this->length_);140 if (this->ribbonTrail_ && this->tickcount_ >= 2) 141 this->ribbonTrail_->setTrailLength(this->length_); 139 142 } 140 143 141 144 void Backlight::update_maxelements() 142 145 { 143 if (this->ribbonTrail_ )146 if (this->ribbonTrail_ && this->tickcount_ >= 2) 144 147 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 145 148 } … … 147 150 void Backlight::update_trailmaterial() 148 151 { 149 if (this->ribbonTrail_ )152 if (this->ribbonTrail_ && this->tickcount_ >= 2) 150 153 this->ribbonTrail_->setMaterialName(this->trailmaterial_); 151 154 } … … 168 171 this->ribbonTrail_->setInitialColour(0, this->getColour()); 169 172 else 170 this->ribbonTrail_->setInitialColour(0, 0, 0, 0, 0); 171 } 172 } 173 174 void Backlight::notifyAttached() 175 { 176 Billboard::notifyAttached(); 177 178 // if (this->ribbonTrail_) 179 // this->ribbonTrail_->clearChain(0); 180 181 // if (this->ribbonTrail_) 182 // this->ribbonTrail_->setTrailLength(this->length_); 173 { 174 this->bTurningOff_ = true; 175 this->turnofftimer_.setTimer(this->turnofftime_, false, this, createExecutor(createFunctor(&Backlight::stopturnoff))); 176 } 177 } 178 } 179 180 void Backlight::stopturnoff() 181 { 182 this->bTurningOff_ = false; 183 183 } 184 184 185 185 void Backlight::tick(float dt) 186 186 { 187 if (this->ribbonTrail_) 188 this->ribbonTrail_->setTrailLength(this->length_); 187 if (this->tickcount_ < 2) 188 { 189 ++this->tickcount_; 190 if (this->tickcount_ == 2) 191 { 192 this->changedColour(); 193 this->update_width(); 194 this->update_lifetime(); 195 this->update_length(); 196 this->update_maxelements(); 197 this->update_trailmaterial(); 198 } 199 } 200 201 if (this->bTurningOff_ && this->ribbonTrail_) 202 { 203 this->ribbonTrail_->setInitialColour(0, this->ribbonTrail_->getInitialColour(0) - this->getColour() / this->turnofftime_ * dt); 204 } 189 205 } 190 206 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.h
r2182 r2207 33 33 #include "Billboard.h" 34 34 #include "objects/Tickable.h" 35 #include "tools/Timer.h" 35 36 36 37 namespace orxonox … … 59 60 { return this->lifetime_; } 60 61 62 inline void setTurnOffTime(float turnofftime) 63 { this->turnofftime_ = turnofftime; } 64 inline float getTurnOffTime() const 65 { return this->turnofftime_; } 66 61 67 inline void setLength(float length) 62 68 { this->length_ = length; this->update_length(); } … … 74 80 { return this->trailmaterial_; } 75 81 76 protected:77 virtual void notifyAttached();78 79 82 private: 83 void stopturnoff(); 80 84 virtual void changedColour(); 81 85 void update_width(); … … 90 94 float length_; 91 95 float lifetime_; 96 float turnofftime_; 97 bool bTurningOff_; 92 98 size_t maxelements_; 93 99 std::string trailmaterial_; 100 char tickcount_; 101 Timer<Backlight> turnofftimer_; 94 102 }; 95 103 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Billboard.cc
r2182 r2207 73 73 void Billboard::changedMaterial() 74 74 { 75 if (this->material_ == "") 76 return; 77 75 78 if (!this->billboard_.getBillboardSet()) 76 79 { -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.cc
r2182 r2207 131 131 object->parent_ = this; 132 132 object->parentID_ = this->getObjectID(); 133 134 object->notifyAttached();135 133 } 136 134 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.h
r2182 r2207 139 139 140 140 protected: 141 virtual void notifyAttached() {}142 143 141 Ogre::SceneNode* node_; 144 142
Note: See TracChangeset
for help on using the changeset viewer.