Changeset 9500 for code/branches/shaders/src
- Timestamp:
- Dec 10, 2012, 3:26:49 PM (12 years ago)
- Location:
- code/branches/shaders/src/orxonox/graphics
- Files:
-
- 2 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 } -
code/branches/shaders/src/orxonox/graphics/LensFlare.h
r9466 r9500 46 46 47 47 namespace orxonox 48 { 48 { 49 49 /** 50 50 @brief … … 61 61 class _OrxonoxExport LensFlare : public StaticEntity, public Tickable 62 62 { 63 /** 64 @brief 65 This is a nested Class used to easily set properties of the different sublenses of a LensFlare effect 66 */ 67 class Lens 68 { 69 public: 70 std::string* material_;//!< Which material should the Lens use, current choices include burst, bursthalo, halo1, halo2, halo3 71 float alpha_;//!< Which base alpha value should the Lens use 72 float scale_;//!< Which base scale should the Lens Flare have 73 float position_;//!< This defines how far along the view direction the flare should be positioned, e.g. 0.5 would position the flare halfway between the viewer and the base burst, 0 at the camera, 1 at the burst 74 Lens(std::string* material, float alpha, float scale, float position) 75 { 76 this->material_=material; 77 this->alpha_=alpha; 78 this->scale_=scale; 79 this->position_=position; 80 } 81 }; 82 63 83 public: 64 84 LensFlare(BaseObject* creator); … … 69 89 inline float getScale() const 70 90 { return this->scale_; } 91 92 /** 93 @brief 94 This sets the base colour of the billboards 95 @param colour 96 Vector3 containing r,g,b values 97 */ 98 inline void setColour(const ColourValue& colour) 99 { 100 this->colour_->r=colour.r; 101 this->colour_->g=colour.g; 102 this->colour_->b=colour.b; 103 } 104 /** 105 @brief 106 This returns the current base colour of the billboards 107 @return a Vector3 containing r,g,b values 108 */ 109 inline const ColourValue& getColour() const 110 { return *(new ColourValue(this->colour_->r,this->colour_->g,this->colour_->b)); } 71 111 72 112 /** … … 141 181 unsigned int getPointCount(float dimension) const; 142 182 183 std::vector<Lens*>* lensConfiguration_;//!< this stores the lensConfiguration 143 184 Billboard* occlusionBillboard_;//!< this is a transparent billboard used solely for the Hardware Occlusion Query 144 185 float cameraDistance_;//!< current distance of the lensflare center from the camera … … 147 188 unsigned int fadeResolution_;//!< how many points should be sampled per axis for the screen border fade. High number => smooth fade, but uses more processing power 148 189 float fadeExponent_;//!< this determines how fast the flare fades away as it gets obstructed 149 //TODO: add XML port for colour manipulation150 190 ColourValue* colour_;//!< this stores the base colour of the light 151 191 };
Note: See TracChangeset
for help on using the changeset viewer.