Ignore:
Timestamp:
Oct 17, 2010, 8:32:03 PM (14 years ago)
Author:
Torben Dannhauer
Message:

Silverlining integration updated on the road to Silverlining 2.0 compatibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp

    r133 r134  
    3939    setUseVertexBufferObjects(false);
    4040    setUseDisplayList(false);
    41         cloudLayerSlots.clear();
     41        pendingNewCloudLayers.clear();
    4242        newCloudLayersToAdd = false;
    4343}
     
    5151    setUseVertexBufferObjects(false);
    5252    setUseDisplayList(false);
    53         cloudLayerSlots.clear();
     53        pendingNewCloudLayers.clear();
    5454        newCloudLayersToAdd = false;
    5555        sceneRoot = csn_;
     
    223223}
    224224
    225 void skySilverLining_skyDrawable::addCloudLayer(cloudLayerSlot *cloudLayerSlot_)
     225void skySilverLining_skyDrawable::addCloudLayerOrder(cloudlayerOrder newCL)
    226226{
    227227        OpenThreads::ScopedLock<OpenThreads::Mutex> sLock(cloudLayersToAddMutex);
    228         cloudLayerSlots.push_back( cloudLayerSlot_ );
     228        pendingNewCloudLayers.push_back( newCL );
    229229        newCloudLayersToAdd = true;
    230230}
    231 
    232 
    233231
    234232void skySilverLining_skyDrawable::seedAndAddCloudLayers(SilverLining::Atmosphere *atmosphere)
     
    238236        {
    239237                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
    241240                {
    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_ );
    250293                }
     294
     295                //Clear the ToDo List
     296                pendingNewCloudLayers.clear();
    251297
    252298                // Note nothing to do.
Note: See TracChangeset for help on using the changeset viewer.