Changeset 9500 for code/branches/shaders/src/orxonox/graphics/LensFlare.cc
- Timestamp:
- Dec 10, 2012, 3:26:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/shaders/src/orxonox/graphics/LensFlare.cc
r9491 r9500 51 51 RegisterObject(LensFlare); 52 52 53 this->lensConfiguration_=new std::vector<LensFlare::Lens*>(); 54 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/burst"),1.0f,1.0f,1.0f)); //main burst 55 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/bursthalo"),0.7f,0.9f,1.0f)); //halo around main burst 56 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo1"),0.4f,0.2f,0.8f)); //all the different distanced lenses 57 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo2"),0.7f,0.3f,0.7f)); 58 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo3"),0.3f,0.4f,0.6f)); 59 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo3"),0.1f,0.8f,0.4f)); 60 this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo1"),0.15f,0.5f,0.35f)); 61 53 62 this->createBillboards(); 54 63 … … 67 76 XMLPortParam(LensFlare, "fadeResolution", setFadeResolution, getFadeResolution, xmlelement, mode).defaultValues(7); 68 77 XMLPortParam(LensFlare, "fadeExponent", setFadeExponent, getFadeExponent, xmlelement, mode).defaultValues(2.0f); 78 XMLPortParam(LensFlare, "colour", setColour, getColour, xmlelement, mode); 69 79 } 70 80 … … 82 92 void LensFlare::createBillboards() 83 93 { 84 //TODO: add more billboards, possibly do some cleaning up, by using a loop85 94 this->occlusionBillboard_ = new Billboard(this); 86 95 this->occlusionBillboard_->setMaterial("lensflare/hoq"); … … 90 99 this->attach(this->occlusionBillboard_); 91 100 92 Billboard* burst = new Billboard(this); 93 burst->setMaterial("lensflare/burst"); 94 burst->disableFrustumCulling(); 95 burst->setVisible(true); 96 this->attach(burst); 97 98 Billboard* bursthalo = new Billboard(this); 99 bursthalo->setMaterial("lensflare/bursthalo"); 100 bursthalo->disableFrustumCulling(); 101 bursthalo->setVisible(true); 102 this->attach(bursthalo); 103 104 bursthalo = new Billboard(this); 105 bursthalo->setMaterial("lensflare/halo1"); 106 bursthalo->disableFrustumCulling(); 107 bursthalo->setVisible(true); 108 this->attach(bursthalo); 109 110 bursthalo = new Billboard(this); 111 bursthalo->setMaterial("lensflare/halo2"); 112 bursthalo->disableFrustumCulling(); 113 bursthalo->setVisible(true); 114 this->attach(bursthalo); 115 116 bursthalo = new Billboard(this); 117 bursthalo->setMaterial("lensflare/halo3"); 118 bursthalo->disableFrustumCulling(); 119 bursthalo->setVisible(true); 120 this->attach(bursthalo); 101 for(std::vector<LensFlare::Lens*>::iterator it = lensConfiguration_->begin(); it != lensConfiguration_->end(); ++it) { 102 Billboard* lensPart=new Billboard(this); 103 lensPart->setMaterial(*(*it)->material_); 104 lensPart->disableFrustumCulling(); 105 lensPart->setVisible(true); 106 this->attach(lensPart); 107 } 121 108 } 122 109 … … 133 120 void LensFlare::updateBillboardStates(Vector3& viewDirection, float dimension, bool lightIsVisible) 134 121 { 135 //TODO: develop a more sane method for determining positions and scale factors of the flare components136 //A good solution would probably be to introduce a data structure which stores a lens flare configuration137 int i=0;138 float step=0.0f;139 for( std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++) {122 this->occlusionBillboard_->setDefaultDimensions(dimension*0.5f,dimension*0.5f); 123 this->occlusionBillboard_->setVisible(lightIsVisible); 124 std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); 125 it++; 126 for(int i=0; it != this->getAttachedObjects().end(); it++) { 140 127 Billboard* billboard=static_cast<Billboard*>(*it); 141 billboard->setPosition(-viewDirection*step); 128 LensFlare::Lens* lens=lensConfiguration_->at(i); 129 billboard->setPosition(-viewDirection*(1.0f-lens->position_)); 142 130 billboard->setVisible(lightIsVisible); 143 billboard->setDefaultDimensions((i==0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f),(i==0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f)); 144 step=0.25f*(i>2?(i-2):0); 131 billboard->setDefaultDimensions(dimension*lens->scale_,dimension*lens->scale_); 145 132 i++; 146 133 } … … 159 146 it++; 160 147 for(int i=0;it!=this->getAttachedObjects().end(); it++) { 161 if(i==2) 162 { 163 this->colour_->a*=0.33f; 164 } 148 ColourValue* cur=new ColourValue(0,0,0,0); 149 (*cur)+= *(this->colour_); 150 cur->a*=lensConfiguration_->at(i)->alpha_; 165 151 Billboard* billboard=static_cast<Billboard*>(*it); 166 billboard->setColour(* (this->colour_));152 billboard->setColour(*cur); 167 153 i++; 168 154 }
Note: See TracChangeset
for help on using the changeset viewer.