Changeset 7015 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Feb 3, 2006, 2:42:30 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/effects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/effects/lense_flare.cc
r7014 r7015 61 61 PRINTF(0)("light is: %p\n", this->lightSource); 62 62 63 this->isVisible = true; 64 63 65 if (root != NULL) 64 66 { … … 66 68 this->activate(); 67 69 } 70 71 this->setSourceVisibility(false); 72 this->isVisible = true; 73 68 74 } 69 75 … … 165 171 166 172 167 bool LenseFlare::sourceVisible() const 168 { 173 void LenseFlare::setSourceVisibility(bool visibility) 174 { 175 if (this->isVisible == visibility) 176 return; 169 177 170 178 float dist = this->frustumPlane.distancePoint(this->lightSource->getAbsCoor()); 171 if( dist < 0.0f) 172 { 173 std::vector<Billboard*>::const_iterator it = flares.begin(); it++; 174 for(; it != flares.end(); it++) 175 (*it)->setVisibility(true); 176 return true; 177 } 178 179 std::vector<Billboard*>::const_iterator it = flares.begin(); it++; 180 for(; it != flares.end(); it++) 181 (*it)->setVisibility(false); 182 183 return false; 179 PRINTF(0)("dist: %f\n", dist); 180 std::vector<Billboard*>::const_iterator it; 181 for(it = flares.begin(); it != flares.end(); it++) 182 (*it)->setVisibility(visibility); 183 this->isVisible = visibility; 184 184 } 185 185 … … 202 202 203 203 //set the frustum plane 204 Vector psTarget = (State::getCameraTargetNode())->getAbsCoor(); 205 Vector psCamera = (State::getCameraNode())->getAbsCoor(); 206 Vector psCameraDir = psCamera - psTarget; 207 //PRINTF(0)("camera Dir: %f %f %f, camera: %f %f %f\n", psCameraDir.x, psCameraDir.y, psCameraDir.z, psCamera.x, psCamera.y, psCamera.z); 208 this->frustumPlane = Plane(psCameraDir, Vector(-70.0,0.0,0.0)); 204 205 this->frustumPlane = State::getCamera()->getViewFrustum(); 206 207 if (State::getCamera()->distance(lightSource) < 0) 208 this->setSourceVisibility(false); 209 else 210 this->setSourceVisibility(true); 209 211 210 212 211 213 // always update the screen center, it could be, that the window is resized 212 214 this->screenCenter = Vector(State::getResX()/2.0f, State::getResY()/2.0f, 0.0f); 215 213 216 // flare vector is the direction from the center to the light source 214 217 this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter; … … 242 245 if( !this->bActivated) 243 246 return; 244 245 this->sourceVisible(); 246 } 247 } -
trunk/src/lib/graphics/effects/lense_flare.h
r6889 r7015 44 44 private: 45 45 GLint charToFogMode(const char* mode); 46 bool sourceVisible() const;46 void setSourceVisibility(bool visibility) ; 47 47 48 48 49 49 private: 50 float isVisible; //!< Checks visibility 50 51 Light* lightSource; //!< reference to the sun (or primary light source) 51 52 std::vector<Billboard*> flares; //!< the flares array
Note: See TracChangeset
for help on using the changeset viewer.