Changeset 134 for osgVisual/src/sky_Silverlining
- Timestamp:
- Oct 17, 2010, 8:32:03 PM (14 years ago)
- Location:
- osgVisual/src/sky_Silverlining
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.