- Timestamp:
- Oct 17, 2010, 8:32:03 PM (14 years ago)
- Location:
- osgVisual
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/include/sky_Silverlining/skySilverLining_skyDrawable.h
r88 r134 30 30 31 31 #include <skySilverLining_cloudLayerSlot.h> 32 #include <visual_util.h> 32 33 33 34 #include <SilverLining.h> … … 38 39 39 40 class skySilverLining_atmosphereReference; 41 42 struct cloudlayerOrder 43 { 44 int slot; 45 double lat; 46 double lon; 47 double baseLength; 48 double baseWidth; 49 double thickness; 50 double baseHeight; 51 double density; 52 CloudTypes cloudtype; 53 cloudLayerSlot* assocCloudLayerSlot; // Pointer to the cloudlayerslot managed by visual_skySilverlining. 54 }; 55 40 56 41 57 class skySilverLining_skyDrawable : public osg::Drawable … … 60 76 virtual void drawImplementation(osg::RenderInfo& renderInfo) const; 61 77 62 void addCloudLayer (cloudLayerSlot *cloudLayerSlot_);78 void addCloudLayerOrder(cloudlayerOrder newCL); 63 79 64 80 void shutdown(); … … 75 91 private: 76 92 OpenThreads::Mutex cloudLayersToAddMutex; 77 mutable std::vector<cloudLayerSlot*> cloudLayerSlots;93 std::vector<cloudlayerOrder> pendingNewCloudLayers; 78 94 bool newCloudLayersToAdd; 79 95 osg::ref_ptr<osg::CoordinateSystemNode> sceneRoot; -
osgVisual/src/core/visual_core.cpp
r133 r134 85 85 viewer->realize(); 86 86 87 // setup scenery88 setupScenery();89 90 87 // parse Configuration file 91 88 parseConfigFile(arguments); … … 100 97 void visual_core::mainLoop() 101 98 { 99 int framestoScenerySetup = 5; 102 100 // run main loop 103 101 while( !viewer->done() ) 104 102 { 103 // setup scenery 104 if(framestoScenerySetup-- == 0) 105 setupScenery(); 106 105 107 // next frame please.... 106 108 viewer->advance(); … … 408 410 void visual_core::setupScenery() 409 411 { 410 // iterate manually through one frame to allow some modules like Sky_Silverlining to initialize properly before we configure it according to the scenery data.411 viewer->advance();412 viewer->eventTraversal();413 viewer->updateTraversal();414 viewer->renderingTraversals();415 412 416 413 // Sky settings: … … 423 420 //sky->addCloudLayer( 2, 50000, 50000, 600.0, 7351.0, 0.2, CIRROCUMULUS ); 424 421 //sky->addCloudLayer( 3, 100000, 100000, 1300.0, 100.0, 0.07, CUMULUS_CONGESTUS ); 425 sky->addCloudLayer( 1, 10000, 10000, 600.0, 1000.0, 0.90, STRATOCUMULUS );422 sky->addCloudLayer( 1, 10000, 10000, 600.0, 2000.0, 0.90, STRATOCUMULUS ); 426 423 //cloudLayerSlots[1].cloudLayerPointer->SetPrecipitation(SilverLining::CloudLayer::SLEET, 25.0 ); 427 424 -
osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp
r133 r134 39 39 setUseVertexBufferObjects(false); 40 40 setUseDisplayList(false); 41 cloudLayerSlots.clear();41 pendingNewCloudLayers.clear(); 42 42 newCloudLayersToAdd = false; 43 43 } … … 51 51 setUseVertexBufferObjects(false); 52 52 setUseDisplayList(false); 53 cloudLayerSlots.clear();53 pendingNewCloudLayers.clear(); 54 54 newCloudLayersToAdd = false; 55 55 sceneRoot = csn_; … … 223 223 } 224 224 225 void skySilverLining_skyDrawable::addCloudLayer (cloudLayerSlot *cloudLayerSlot_)225 void skySilverLining_skyDrawable::addCloudLayerOrder(cloudlayerOrder newCL) 226 226 { 227 227 OpenThreads::ScopedLock<OpenThreads::Mutex> sLock(cloudLayersToAddMutex); 228 cloudLayerSlots.push_back( cloudLayerSlot_);228 pendingNewCloudLayers.push_back( newCL ); 229 229 newCloudLayersToAdd = true; 230 230 } 231 232 233 231 234 232 void skySilverLining_skyDrawable::seedAndAddCloudLayers(SilverLining::Atmosphere *atmosphere) … … 238 236 { 239 237 OpenThreads::ScopedLock<OpenThreads::Mutex> sLock(cloudLayersToAddMutex); 240 for ( unsigned int i=0; cloudLayerSlots.size() > 0; i++) 238 239 for ( unsigned int i=0; i<pendingNewCloudLayers.size(); i++) // Configure & Seed cloudLayer 241 240 { 242 // Seed cloudLayer 243 cloudLayerSlots.back()->cloudLayerPointer->SeedClouds(*atmosphere); 244 245 // add cloudLayer to atmosphere 246 cloudLayerSlots.back()->cloudLayerHandle = atmosphere->GetConditions()->AddCloudLayer( cloudLayerSlots.back()->cloudLayerPointer ); 247 248 // Delete this cloudLayer from the ToDo list. 249 cloudLayerSlots.pop_back(); 241 // Calculation earth radius on specified lat lon position 242 double radius; 243 cloudlayerOrder newCL = pendingNewCloudLayers[i]; 244 if ( !util::calculateEarthRadiusAtWGS84Coordinate(newCL.lat, newCL.lon, sceneRoot, radius) ) 245 { 246 OSG_ALWAYS << "ERROR: skySilverLining_skyDrawable::seedAndAddCloudLayers() - Unable to deterine earth radius for lat=" <<newCL.lat<< " lon="<<newCL.lat<<std::endl; 247 return; 248 } 249 OSG_NOTIFY(osg::ALWAYS) << "lat:" << newCL.lat << std::endl; 250 OSG_NOTIFY(osg::ALWAYS) << "lon:" << newCL.lon << std::endl; 251 OSG_NOTIFY(osg::ALWAYS) << "radius:" << radius << std::endl; 252 253 // generate Cloud Layer 254 SilverLining::CloudLayer *cloudLayer_; 255 cloudLayer_ = SilverLining::CloudLayerFactory::Create(newCL.cloudtype); 256 cloudLayer_->SetBaseAltitude( newCL.baseHeight + radius); 257 cloudLayer_->SetThickness(newCL.thickness); 258 cloudLayer_->SetBaseLength(newCL.baseLength); 259 cloudLayer_->SetBaseWidth(newCL.baseWidth); 260 cloudLayer_->SetDensity(newCL.density); 261 cloudLayer_->SetLayerPosition( 0.0, 0.0 ); 262 cloudLayer_->GenerateShadowMaps(false); 263 264 //Save cloudlayer information into SLOT 265 newCL.assocCloudLayerSlot->used = true; 266 newCL.assocCloudLayerSlot->enabled = true; 267 newCL.assocCloudLayerSlot->cloudLayerPointer = cloudLayer_; 268 switch(newCL.cloudtype) 269 { 270 case 0: newCL.assocCloudLayerSlot->typeName = "CIRROCUMULUS"; // High planar cloud puffs 271 break; 272 case 1: newCL.assocCloudLayerSlot->typeName = "CIRRUS_FIBRATUS"; // High, thicker and fibrous clouds that signal changing weather 273 break; 274 case 2: newCL.assocCloudLayerSlot->typeName = "STRATUS"; // Low clouds represented as a slab 275 break; 276 case 3: newCL.assocCloudLayerSlot->typeName = "CUMULUS_MEDIOCRIS"; // Low, puffy clouds on fair days 277 break; 278 case 4: newCL.assocCloudLayerSlot->typeName = "CUMULUS_CONGESTUS"; // Large cumulus clouds that could turn into a thunderhead 279 break; 280 case 5: newCL.assocCloudLayerSlot->typeName = "CUMULONIMBUS_CAPPILATUS"; // Big storm clouds. 281 break; 282 case 6: newCL.assocCloudLayerSlot->typeName = "STRATOCUMULUS"; // Low, dense, puffy clouds with some sun breaks between them. 283 break; 284 default: OSG_NOTIFY( osg::FATAL ) << "skySilverLining_skyDrawable::seedAndAddCloudLayers() - Invalid cloud type." << std::cout; 285 break; 286 }; 287 288 // Seed Cloudlayer 289 cloudLayer_->SeedClouds(*atmosphere); 290 291 // Add cloudLayer to atmosphere 292 newCL.assocCloudLayerSlot->cloudLayerHandle = atmosphere->GetConditions()->AddCloudLayer( cloudLayer_ ); 250 293 } 294 295 //Clear the ToDo List 296 pendingNewCloudLayers.clear(); 251 297 252 298 // Note nothing to do. -
osgVisual/src/sky_Silverlining/visual_skySilverLining.cpp
r133 r134 432 432 if (isInitialized() && slot_ >= 0 && slot_ < MAX_CLOUDLAYER_SLOTS) 433 433 { 434 // Calculation earth radius on current lat lon position 435 double radius; 436 if ( util::calculateEarthRadiusAtWGS84Coordinate(lat, lon, sceneRoot, radius) ) 437 { 438 OSG_NOTIFY(osg::ALWAYS) << "radius:" << radius << std::endl; 439 // generate Cloud Layer 440 SilverLining::CloudLayer *cloudLayer_; 441 cloudLayer_ = SilverLining::CloudLayerFactory::Create(cloudtype_); 442 cloudLayer_->SetBaseAltitude( baseHeight_ + radius); 443 444 cloudLayer_->SetThickness(thickness_); 445 cloudLayer_->SetBaseLength(baseLength_); 446 cloudLayer_->SetBaseWidth(baseWidth_); 447 cloudLayer_->SetDensity(density_); 448 cloudLayer_->SetLayerPosition( 0.0, 0.0 ); 449 cloudLayer_->GenerateShadowMaps(false); 450 451 //Save cloudlayer information into SLOT 452 cloudLayerSlots[slot_].used = true; 453 cloudLayerSlots[slot_].enabled = true; 454 cloudLayerSlots[slot_].cloudLayerPointer = cloudLayer_; 455 switch(cloudtype_) 456 { 457 case 0: cloudLayerSlots[slot_].typeName = "CIRROCUMULUS"; // High planar cloud puffs 458 break; 459 case 1: cloudLayerSlots[slot_].typeName = "CIRRUS_FIBRATUS"; // High, thicker and fibrous clouds that signal changing weather 460 break; 461 case 2: cloudLayerSlots[slot_].typeName = "STRATUS"; // Low clouds represented as a slab 462 break; 463 case 3: cloudLayerSlots[slot_].typeName = "CUMULUS_MEDIOCRIS"; // Low, puffy clouds on fair days 464 break; 465 case 4: cloudLayerSlots[slot_].typeName = "CUMULUS_CONGESTUS"; // Large cumulus clouds that could turn into a thunderhead 466 break; 467 case 5: cloudLayerSlots[slot_].typeName = "CUMULONIMBUS_CAPPILATUS"; // Big storm clouds. 468 break; 469 case 6: cloudLayerSlots[slot_].typeName = "STRATOCUMULUS"; // Low, dense, puffy clouds with some sun breaks between them. 470 break; 471 default: OSG_NOTIFY( osg::FATAL ) << "visual_skySilverlining::addCloudLayer - Invalid cloud type." << std::cout; 472 break; 473 }; 434 // create cloudlayer order and pass to skyDrawable to instantiate. 435 cloudlayerOrder newCL; 436 newCL.slot = slot_; 437 newCL.lat = lat; 438 newCL.lon = lon; 439 newCL.baseLength = baseLength_; 440 newCL.baseWidth = baseWidth_; 441 newCL.thickness = thickness_; 442 newCL.baseHeight = baseHeight_; 443 newCL.density = density_; 444 newCL.cloudtype = cloudtype_; 445 newCL.assocCloudLayerSlot = &cloudLayerSlots[slot_]; 474 446 475 // Pass cloudlayer for seeding and adding to sky framework to the render thread 476 skyDrawable->addCloudLayer( &cloudLayerSlots[slot_] ); 477 } // If valid radius END 447 skyDrawable->addCloudLayerOrder( newCL ); 448 478 449 } // If isInitialized() END 479 450 }
Note: See TracChangeset
for help on using the changeset viewer.