Changeset 53 for osgVisual/src
- Timestamp:
- May 28, 2010, 10:18:54 AM (14 years ago)
- Location:
- osgVisual/src/sky_Silverlining
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp
r31 r53 43 43 } 44 44 45 skySilverLining_skyDrawable::skySilverLining_skyDrawable(osgViewer::Viewer* view )45 skySilverLining_skyDrawable::skySilverLining_skyDrawable(osgViewer::Viewer* view, osg::CoordinateSystemNode* csn_) 46 46 : osg::Drawable() 47 47 , _view(view) … … 53 53 cloudLayerSlots.clear(); 54 54 newCloudLayersToAdd = false; 55 sceneRoot = csn_; 55 56 } 56 57 … … 86 87 void skySilverLining_skyDrawable::setSceneFog(SilverLining::Atmosphere *atmosphere) const 87 88 { 88 glEnable(GL_FOG); 89 glFogi(GL_FOG_MODE, GL_EXP); 89 //glEnable(GL_FOG); 90 // glFogi(GL_FOG_MODE, GL_EXP); 91 92 ////float hazeR, hazeG, hazeB; 93 ////double hazeDepth, hazeDensity; 94 ////atmosphere->GetHaze(hazeR, hazeG, hazeB, hazeDepth, hazeDensity); 95 96 // //hazeDensity = 1.0 / 40000; 97 ////hazeDensity = 0; 98 //float hazeDensity = 1.0 / atmosphere->GetConditions()->GetVisibility(); 99 100 // // Decrease fog density with altitude, to avoid fog effects through the vacuum of space. 101 // static const double H = 8435.0; // Pressure scale height of Earth's atmosphere 102 // double isothermalEffect = exp(-(atmosphere->GetConditions()->GetLocation().GetAltitude() / H)); 103 // if (isothermalEffect <= 0) isothermalEffect = 1E-9; 104 // if (isothermalEffect > 1.0) isothermalEffect = 1.0; 105 // hazeDensity *= isothermalEffect; 106 107 // bool silverLiningHandledTheFog = false; 108 109 // if (atmosphere->GetFogEnabled()) 110 // { 111 // float density, r, g, b; 112 // // Note, the fog color returned is already lit 113 // atmosphere->GetFogSettings(&density, &r, &g, &b); 114 115 // if (density > hazeDensity) 116 // { 117 // glFogf(GL_FOG_DENSITY, density); 118 119 // GLfloat fogColor[4] = {r, g, b, 1.0}; 120 // glFogfv(GL_FOG_COLOR, fogColor); 121 122 // silverLiningHandledTheFog = true; 123 // } 124 // } 125 // 126 // if (!silverLiningHandledTheFog) 127 // { 128 // GLfloat fogColor[4]; 129 // //atmosphere->GetHorizonColor(yaw, &fogColor[0], &fogColor[1], &fogColor[2]); // New version of this call: SL_1.94 /** \todo transmit the yaw value of the center channel to all slaves for consistent fog color. */ 130 // atmosphere->GetHorizonColor( 0, &fogColor[0], &fogColor[1], &fogColor[2]); 131 // glFogfv(GL_FOG_COLOR, fogColor); 132 133 // glFogf(GL_FOG_DENSITY, hazeDensity); 134 // } 135 136 137 138 139 140 141 osg::ref_ptr<osg::Fog> fog = new osg::Fog; 142 fog->setMode(osg::Fog::EXP); 143 //fog->setUseRadialFog( true ); 144 145 //_objectsNode = erde oder object, das mit nebel bedacht werden soll 146 sceneRoot->getOrCreateStateSet()->setAttributeAndModes(fog.get()); 90 147 91 148 //float hazeR, hazeG, hazeB; … … 114 171 if (density > hazeDensity) 115 172 { 116 glFogf(GL_FOG_DENSITY, density); 117 118 GLfloat fogColor[4] = {r, g, b, 1.0}; 119 glFogfv(GL_FOG_COLOR, fogColor); 120 121 silverLiningHandledTheFog = true; 173 fog->setDensity(density); 174 fog->setColor(osg::Vec4(r, g, b, 1.0)); 175 176 silverLiningHandledTheFog = true; 122 177 } 123 178 } … … 125 180 if (!silverLiningHandledTheFog) 126 181 { 127 GLfloat fogColor[4]; 128 //atmosphere->GetHorizonColor(yaw, &fogColor[0], &fogColor[1], &fogColor[2]); // New version of this call: SL_1.94 /** \todo transmit the yaw value of the center channel to all slaves for consistent fog color. */ 129 atmosphere->GetHorizonColor( 0, &fogColor[0], &fogColor[1], &fogColor[2]); 130 glFogfv(GL_FOG_COLOR, fogColor); 131 132 glFogf(GL_FOG_DENSITY, hazeDensity); 182 float r, g, b; 183 atmosphere->GetHorizonColor(0, &r, &g, &b);// New version of this call: since SL_1.94 /** \todo transmit the yaw value of the center channel to all slaves for consistent fog color. */ 184 185 fog->setDensity(hazeDensity); 186 fog->setColor(osg::Vec4(r, g, b, 1.0)); 133 187 } 134 188 135 136 // _fog = new osg::Fog;137 //_objectsNode = erde oder object, das mit nebel bedacht werden soll138 //_objectsNode->getOrCreateStateSet()->setAttributeAndModes(_fog.get());139 140 //fog->setMode(osg::Fog::EXP);141 142 // float hazeDensity = 0;//1.0 / 10000.0; //0.000075f143 // bool silverLiningHandledTheFog = false;144 145 // if (atmosphere->GetFogEnabled())146 // {147 // float density, r, g, b;148 // atmosphere->GetFogSettings(&density, &r, &g, &b);149 150 // if (density > hazeDensity)151 // {152 // fog->setDensity(density);153 // fog->setColor(osg::Vec4(r, g, b, 1.0));154 155 // silverLiningHandledTheFog = true;156 // }157 // }158 159 // if (!silverLiningHandledTheFog)160 // {161 // float r, g, b;162 // atmosphere->GetHorizonColor(0, &r, &g, &b);163 164 // fog->setDensity(hazeDensity);165 // fog->setColor(osg::Vec4(r, g, b, 1.0));166 // }167 189 } 168 190 … … 278 300 } 279 301 } 302 303 void skySilverLining_skyDrawable::shutdown() 304 { 305 sceneRoot = NULL; 306 } -
osgVisual/src/sky_Silverlining/visual_skySilverLining.cpp
r31 r53 164 164 // Add the sky (calls Atmosphere::BeginFrame and handles initialization once you're in 165 165 // the rendering thread) 166 skyDrawable = new skySilverLining_skyDrawable(viewer );166 skyDrawable = new skySilverLining_skyDrawable(viewer, sceneRoot); 167 167 168 168 osg::Camera *mainCamera = viewer->getCamera(); … … 244 244 // Add the sky (calls Atmosphere::BeginFrame and handles initialization once you're in 245 245 // the rendering thread) 246 skyDrawable = new skySilverLining_skyDrawable(viewer );246 skyDrawable = new skySilverLining_skyDrawable(viewer, sceneRoot); 247 247 248 248 if (!useProjMatrixCallback) … … 301 301 302 302 setTime(16,00,23); 303 setVisibility(50000); 303 setVisibility(5000); 304 //AtmosphericConditions::SetFog()// use this for simulation real fog. 305 306 304 307 305 308 //Todo: secure memory-manager of timer*. oder remove paragraph … … 371 374 372 375 // delete drawables 376 skyDrawable->shutdown(); 373 377 this->removeDrawable(skyDrawable); 374 378 this->removeDrawable(cloudsDrawable); … … 382 386 atmosphere->GetConditions()->SetVisibility( visibility_ ); 383 387 } 388 384 389 } 385 390
Note: See TracChangeset
for help on using the changeset viewer.