Changeset 182


Ignore:
Timestamp:
Jan 7, 2011, 12:05:14 PM (14 years ago)
Author:
Torben Dannhauer
Message:

Adapted Sky_Silverlining to be aware of the XML configuration. The sky can now be disabled by XML configuration.

All calls to sky must be wrapped with if(sky.valid()) { ...} to ensure that it is only called when available.

Location:
osgVisual/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/include/sky_Silverlining/visual_skySilverLining.h

    r145 r182  
    6565         * @param viewer_ : Pointer to the applications viewer
    6666         * @param configFileName : Filename of the XML configfile to read the configuration from. Currently not used because skySilverlining currently does not need any configuration parameters.
    67          */
    68         visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName);
     67         * @param disabled : Flag to the caller which indicates if the sky was enabled or disabled by the XML configuration file.
     68         */
     69        visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName, bool& disabled);
    6970
    7071        /**
  • osgVisual/trunk/src/core/visual_core.cpp

    r175 r182  
    7777#ifdef USE_SKY_SILVERLINING
    7878        // Initialize sky
    79         sky = new visual_skySilverLining( viewer, configFilename );
    80         sky->init(distortedSceneGraph, rootNode);       // Without distortion: distortedSceneGraph=NULL
     79        bool disabled = false;  // to ask if the skyp is disabled or enabled
     80        sky = new visual_skySilverLining( viewer, configFilename, disabled );
     81        if(disabled)
     82                sky = NULL;
     83        if(sky.valid())
     84                sky->init(distortedSceneGraph, rootNode);       // Without distortion: distortedSceneGraph=NULL
    8185#endif
    8286
     
    404408{
    405409
    406         // Sky settings:       
    407         sky->setTime(15,30,00);
    408         sky->setVisibility(50000);
    409         sky->addWindVolume( 0.0, 15000.0, 25.0, 90.0 );
    410        
    411         //sky->addCloudLayer( 0, 20000, 20000, 600.0, 1000.0, 0.5, CUMULONIMBUS_CAPPILATUS );
    412         //sky->addCloudLayer( 1, 5000000, 5000000, 600.0, 7351.0, 0.2, CIRRUS_FIBRATUS );
    413         //sky->addCloudLayer( 2, 50000, 50000, 600.0, 7351.0, 0.2, CIRROCUMULUS );
    414         ///sky->addCloudLayer( 2, 100000, 100000, 600.0, 2351.0, 0.75, STRATUS );
    415         sky->addCloudLayer( 3, 50000, 50000, 1300.0, 700.0, 0.07, CUMULUS_CONGESTUS );
    416         //sky->addCloudLayer( 1, 100000, 100000, 3500.0, 2000.0, 0.30, STRATOCUMULUS );
    417 
    418         //sky->setSlotPrecipitation( 1, 0.0, 0.0, 0.0, 25.0 );
     410        // Sky settings:
     411        if(sky.valid())
     412        {
     413                sky->setTime(15,30,00);
     414                sky->setVisibility(50000);
     415                sky->addWindVolume( 0.0, 15000.0, 25.0, 90.0 );
     416               
     417                //sky->addCloudLayer( 0, 20000, 20000, 600.0, 1000.0, 0.5, CUMULONIMBUS_CAPPILATUS );
     418                //sky->addCloudLayer( 1, 5000000, 5000000, 600.0, 7351.0, 0.2, CIRRUS_FIBRATUS );
     419                //sky->addCloudLayer( 2, 50000, 50000, 600.0, 7351.0, 0.2, CIRROCUMULUS );
     420                ///sky->addCloudLayer( 2, 100000, 100000, 600.0, 2351.0, 0.75, STRATUS );
     421                sky->addCloudLayer( 3, 50000, 50000, 1300.0, 700.0, 0.07, CUMULUS_CONGESTUS );
     422                //sky->addCloudLayer( 1, 100000, 100000, 3500.0, 2000.0, 0.30, STRATOCUMULUS );
     423
     424                //sky->setSlotPrecipitation( 1, 0.0, 0.0, 0.0, 25.0 );
     425        }
    419426
    420427
  • osgVisual/trunk/src/sky_Silverlining/visual_skySilverLining.cpp

    r144 r182  
    1919using namespace osgVisual;
    2020
    21 visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName)
    22 {
    23         OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining..." << std::endl;
     21visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName, bool& disabled)
     22{
     23        OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining...";
    2424
    2525        atmosphereInitialized = false;
     
    3535                cloudLayerSlots.back().slot_id = i;
    3636        }
     37
     38        // Check if the module is en- or diabled by XML configuration.
     39        xmlDoc* tmpDoc;
     40        xmlNode* config = util::getModuleXMLConfig( configFileName, "sky_silverlining", tmpDoc, disabled );
     41        if( disabled)
     42                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file." << std::endl;
     43        else
     44                OSG_NOTIFY( osg::ALWAYS ) << std::endl;
     45        if(config)
     46                xmlFreeDoc(tmpDoc); xmlCleanupParser();
     47
    3748}
    3849
Note: See TracChangeset for help on using the changeset viewer.