Changeset 6787 in orxonox.OLD for branches/network/src
- Timestamp:
- Jan 27, 2006, 11:11:25 AM (19 years ago)
- Location:
- branches/network/src/lib/graphics/effects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/graphics/effects/lense_flare.cc
r6786 r6787 26 26 27 27 #include "light.h" 28 #include "state.h" 28 29 29 30 #include "render2D/billboard.h" … … 43 44 if (root != NULL) 44 45 this->loadParams(root); 46 47 this->flareMatrix = new float[14]; 48 /* length image scale */ 49 this->flareMatrix[0] = 1.0f; this->flareMatrix[1] = 1.0f; 50 this->flareMatrix[2] = 0.5f; this->flareMatrix[3] = 0.5f; 51 this->flareMatrix[4] = 0.33f; this->flareMatrix[5] = 0.25f; 52 this->flareMatrix[6] = 0.125f; this->flareMatrix[7] = 1.0f; 53 this->flareMatrix[8] = -0.5f; this->flareMatrix[9] = 0.5f; 54 this->flareMatrix[10] = -0.25f; this->flareMatrix[11] = 0.25f; 55 this->flareMatrix[12] = 1.82f; this->flareMatrix[13] = 0.25f; 45 56 } 46 57 … … 116 127 void LenseFlare::addFlare(const char* textureName) 117 128 { 129 if( this->flares.size() < LF_MAX_FLARES) 130 { 131 PRINTF(2)("You tried to add more than %i lense flares, ignoring\n", LF_MAX_FLARES); 132 return; 133 } 134 118 135 Billboard* bb = new Billboard(NULL); 119 136 bb->setTexture(textureName); 120 137 this->flares.push_back(bb); 138 PRINTF(0)("Added a Lenseflare Billboard with texture %s\n", textureName); 121 139 122 140 // the first flare belongs to the light source … … 134 152 void LenseFlare::tick(float dt) 135 153 { 154 if( unlikely(!this->bActivated || this->flares.size() == 0)) 155 return; 156 // always update the screen center, it could be, that the window is resized 157 this->screenCenter = Vector(State::getResX()/2.0f, State::getResY()/2.0f, 0.0f); 158 // flare vector is the direction from the center to the light source 159 this->flareVector = this->flares[0]->getAbsCoor2D(); 160 this->distance = this->flareVector.len(); 161 this->flareVector.normalize(); 136 162 163 // now calculate the new coordinates of the billboards 164 std::vector<Billboard*>::iterator it; 165 int i; 166 for( it = flares.begin(), i = 0; it != flares.end(); it++, i++) 167 { 168 // set the new position 169 (*it)->setAbsCoor2D(this->flareVector * this->flareMatrix[i * 2]); 170 PRINTF(0)("Drawing flare %i @ (%f, %f)\n", i, (this->flareVector * this->flareMatrix[i * 2]).x, (this->flareVector * this->flareMatrix[i * 2]).y); 171 // tick them 172 (*it)->tick(dt); 173 } 137 174 } 138 175 -
branches/network/src/lib/graphics/effects/lense_flare.h
r6786 r6787 12 12 13 13 #include "vector.h" 14 15 16 #define LF_MAX_FLARES 7 17 14 18 15 19 class TiXmlElement; … … 46 50 47 51 Vector flareVector; //!< the axis to draw the flares on 52 float distance; //!< distance from center to source 48 53 Vector screenCenter; //!< the vector marking the center of the screen 54 55 float* flareMatrix; 49 56 }; 50 57
Note: See TracChangeset
for help on using the changeset viewer.