- Timestamp:
- Nov 1, 2010, 6:24:56 PM (14 years ago)
- Location:
- osgVisual
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/include/core/visual_core.h
r129 r144 139 139 140 140 /** 141 * XML File valid?141 * XML configuration filename. 142 142 */ 143 bool configFileValid; 143 std::string configFilename; 144 144 145 145 146 #ifdef USE_SPACENAVIGATOR -
osgVisual/include/dataIO/visual_dataIO.h
r118 r144 145 145 static visual_dataIO* getInstance(); 146 146 147 void init(osgViewer::Viewer* viewer_,osg::ArgumentParser& arguments_ );147 void init(osgViewer::Viewer* viewer_,osg::ArgumentParser& arguments_, std::string configFileName); 148 148 void shutdown(); 149 149 bool isMaster(){if (clusterMode==osgVisual::dataIO_cluster::MASTER) return true; else return false;}; -
osgVisual/include/sky_Silverlining/visual_skySilverLining.h
r139 r144 65 65 * @param viewer_ : Pointer to the applications viewer 66 66 */ 67 visual_skySilverLining(osgViewer::Viewer* viewer_ );67 visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName); 68 68 69 69 /** -
osgVisual/include/util/visual_util.h
r88 r144 18 18 #include <string.h> 19 19 #include <iostream> 20 20 #include <libxml/parser.h> 21 #include <libxml/tree.h> 21 22 22 23 #include <osg/Node> … … 27 28 28 29 #include <osgViewer/Viewer> 30 31 #include <OpenThreads/ReentrantMutex> 32 33 #include <osgUtil/LineSegmentIntersector> 29 34 30 35 #ifdef FUNFUNCTIONS_ENABLED … … 36 41 #endif 37 42 38 #include <OpenThreads/ReentrantMutex> 39 40 #include <osgUtil/LineSegmentIntersector> 43 41 44 42 45 namespace osgVisual … … 216 219 */ 217 220 static bool setTransparentWindowBackground(osgViewer::Viewer* viewer_); 221 222 // Parses for the XML node of the specified module. The caller has to clean up if ret_value!=NULL, otherwise this function cleans up. 223 // nötige cleanup-Schritte: xmlFreeDoc(doc); xmlCleanupParser(); 224 static xmlNode* getModuleXMLConfig(std::string configFilename, std::string moduleName, xmlDoc*& doc); 225 226 private: 227 static xmlNode* checkXMLNodeChildrenForModule(xmlNode* node, std::string moduleName); 218 228 }; 219 229 -
osgVisual/src/core/visual_core.cpp
r143 r144 34 34 OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_core..." << std::endl; 35 35 36 // Check for config file to provide it to all modules during initialization. 37 if( arguments.read("-c", configFilename) || arguments.read("--config", configFilename) ) 38 { 39 if( !osgDB::fileExists(configFilename) ) 40 configFilename = ""; 41 else 42 OSG_ALWAYS << "Using configuration file: " << configFilename << std::endl; 43 } 44 45 xmlDoc* tmpDoc; 46 util::getModuleXMLConfig( configFilename, "core", tmpDoc ); 47 if(tmpDoc) 48 { 49 xmlFreeDoc(tmpDoc); xmlCleanupParser(); 50 } 51 52 36 53 // Configure osg to use KdTrees 37 54 osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES); … … 63 80 // Initialize distortion 64 81 OSG_NOTIFY( osg::ALWAYS ) << "Using distortion." << std::endl; 65 distortion = new visual_distortion( viewer, arguments );82 distortion = new visual_distortion( viewer, arguments, configFilename ); 66 83 distortion->initialize( rootNode, viewer->getCamera()->getClearColor() ); 67 84 distortedSceneGraph = distortion->getDistortedSceneGraph(); … … 70 87 #ifdef USE_SKY_SILVERLINING 71 88 // Initialize sky 72 sky = new visual_skySilverLining( viewer );73 sky->init(distortedSceneGraph, rootNode); // Without distort edSceneGraph=NULL89 sky = new visual_skySilverLining( viewer, configFilename ); 90 sky->init(distortedSceneGraph, rootNode); // Without distortion: distortedSceneGraph=NULL 74 91 #endif 75 92 76 93 // Initialize DataIO interface 77 visual_dataIO::getInstance()->init(viewer, arguments );78 79 // Add manipulators for user interaction - after dataIO to be able to skip it in slaves .94 visual_dataIO::getInstance()->init(viewer, arguments, configFilename); 95 96 // Add manipulators for user interaction - after dataIO to be able to skip it in slaves rendering machines. 80 97 addManipulators(); 81 98 … … 258 275 void visual_core::parseConfigFile(osg::ArgumentParser& arguments_) 259 276 { 260 configFileValid = false;261 262 std::string filename;263 if( arguments.read("-c", filename) || arguments.read("--config", filename) )264 {265 OSG_ALWAYS << "Using configuration file.." << std::endl;266 if ( osgDB::fileExists(filename))277 if( configFilename != "" ) 278 { 279 xmlDoc *doc = NULL; 280 xmlNode *root_element = NULL; 281 282 doc = xmlReadFile(configFilename.c_str(), NULL, 0); 283 if (doc == NULL) 267 284 { 268 configFileValid = false; 269 xmlDoc *doc = NULL; 270 xmlNode *root_element = NULL; 271 272 doc = xmlReadFile(filename.c_str(), NULL, 0); 273 if (doc == NULL) 274 { 275 configFileValid = false; 276 OSG_ALWAYS << "visual_core::parseConfigFile() - ERROR: could not parse osgVisual config file" << filename << std::endl; 277 } 278 else 279 { 280 // Get the root element node 281 root_element = xmlDocGetRootElement(doc); 282 283 // Parse the XML document. 284 checkXMLNode(root_element); 285 286 // free the document 287 xmlFreeDoc(doc);; 288 } 289 // Free the global variables that may have been allocated by the parser. 290 xmlCleanupParser(); 291 292 if(!configFileValid) 293 OSG_ALWAYS << "visual_core::parseConfigFile() - ERROR: XML file seems not to be a valid osgVisual configuration file!" << std::endl; 294 295 } // IF configfile exists 296 } // IF -c END 285 OSG_ALWAYS << "visual_core::parseConfigFile() - ERROR: could not parse osgVisual config file" << configFilename << std::endl; 286 } 287 else 288 { 289 // Get the root element node 290 root_element = xmlDocGetRootElement(doc); 291 292 // Parse the XML document. 293 checkXMLNode(root_element); 294 295 // free the document 296 xmlFreeDoc(doc);; 297 } 298 // Free the global variables that may have been allocated by the parser. 299 xmlCleanupParser(); 300 301 } // IF configfile exists 297 302 } 298 303 … … 305 310 { 306 311 OSG_DEBUG << "XML node osgvisualconfiguration found" << std::endl; 307 configFileValid = true; 312 308 313 // Iterate to the next nodes to configure modules and scenery. 309 314 checkXMLNode(cur_node->children); … … 352 357 enabled = false; 353 358 354 OSG_ALWAYS << "Module '" << name << "' found. Enabled = " << enabled << std::endl;355 356 359 attr = attr->next; 357 360 } 361 OSG_ALWAYS << "Module '" << name << "' found. Enabled = " << enabled << std::endl; 358 362 359 363 // Pass the nodes to the corresponding modules... … … 412 416 413 417 // Sky settings: 414 sky->setTime(1 2,00,23);418 sky->setTime(15,30,00); 415 419 sky->setVisibility(50000); 416 sky->addWindVolume( 0.0, 15000.0, 50.0, 90.0 );420 sky->addWindVolume( 0.0, 15000.0, 25.0, 90.0 ); 417 421 418 422 //sky->addCloudLayer( 0, 20000, 20000, 600.0, 1000.0, 0.5, CUMULONIMBUS_CAPPILATUS ); 419 423 //sky->addCloudLayer( 1, 5000000, 5000000, 600.0, 7351.0, 0.2, CIRRUS_FIBRATUS ); 420 424 //sky->addCloudLayer( 2, 50000, 50000, 600.0, 7351.0, 0.2, CIRROCUMULUS ); 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.60, STRATOCUMULUS ); 425 ///sky->addCloudLayer( 2, 100000, 100000, 600.0, 2351.0, 0.75, STRATUS ); 426 sky->addCloudLayer( 3, 50000, 50000, 1300.0, 700.0, 0.07, CUMULUS_CONGESTUS ); 427 //sky->addCloudLayer( 1, 100000, 100000, 3500.0, 2000.0, 0.50, STRATOCUMULUS ); 423 428 424 429 //sky->setSlotPrecipitation( 1, 0.0, 0.0, 0.0, 25.0 ); -
osgVisual/src/dataIO/visual_dataIO.cpp
r121 r144 44 44 }; 45 45 46 void visual_dataIO::init(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_ )46 void visual_dataIO::init(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_, std::string configFileName) 47 47 { 48 48 OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO init()" << std::endl; -
osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp
r143 r144 164 164 atmosphere->SetRightVector(-0.201185, 0.979553, 0.0); 165 165 166 /** \todo :not working!! what is wrong? */167 // override the some options of the configuration file with the required settings to make silverlining upgrades easier168 OSG_ALWAYS << "atmosphere from space before : " << atmosphere->GetConfigOptionBoolean("enable-atmosphere-from-space") << std::endl;169 atmosphere->SetConfigOption("enable-atmosphere-from-space", "yes");170 atmosphere->SetConfigOption("draw-sun-below-horizon", "yes");171 OSG_ALWAYS << "atmosphere from space after: " << atmosphere->GetConfigOptionBoolean("enable-atmosphere-from-space") << std::endl;172 173 166 // Set our location (change this to your own latitude and longitude) 174 167 SilverLining::Location loc; … … 256 249 cloudLayer_->SetLayerPosition( 0.0, 0.0 ); 257 250 cloudLayer_->GenerateShadowMaps(false); 258 cloudLayer_->SetIsInfinite( true );251 //cloudLayer_->SetIsInfinite( true ); 259 252 260 253 -
osgVisual/src/sky_Silverlining/visual_skySilverLining.cpp
r143 r144 19 19 using namespace osgVisual; 20 20 21 visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_ )21 visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName) 22 22 { 23 23 OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining..." << std::endl; -
osgVisual/src/util/visual_util.cpp
r130 r144 25 25 util::~util(void) 26 26 { 27 } 28 29 xmlNode* util::getModuleXMLConfig(std::string configFilename, std::string moduleName, xmlDoc*& doc) 30 { 31 doc = NULL; 32 xmlNode *root_element = NULL; 33 34 // Check for valid parameters 35 if(configFilename == "") 36 { 37 OSG_ALWAYS << "ERROR - util::getModuleXMLConfig() : Invalid Configuration Filename!" << std::endl; 38 return NULL; 39 } 40 if(moduleName == "") 41 { 42 OSG_ALWAYS << "ERROR - util::getModuleXMLConfig() : Invalid Module Filename!" << std::endl; 43 return NULL; 44 } 45 46 // It is a valid XML document? 47 doc = xmlReadFile(configFilename.c_str(), NULL, 0); 48 if (doc == NULL) 49 { 50 OSG_ALWAYS << "ERROR - util::getModuleXMLConfig() : " << configFilename << " is not a valid XML file!" << std::endl; 51 return NULL; 52 } 53 54 // Get the root element node 55 root_element = xmlDocGetRootElement(doc); 56 57 // Check if it is an osgVisual configuration file 58 std::string node_name=reinterpret_cast<const char*>(root_element->name); 59 if(!(root_element->type == XML_ELEMENT_NODE && node_name == "osgvisualconfiguration")) 60 { 61 OSG_ALWAYS << "ERROR - util::getModuleXMLConfig() : " << configFilename << " is not an osgVisual configuration file!" << std::endl; 62 return NULL; 63 } 64 65 // If file is a valid osgVisual config file, check all the root xml node and all of it's children of osgvisualconfiguration for the specified module 66 xmlNode* tmpNode = checkXMLNodeChildrenForModule(root_element, moduleName); 67 68 if( !tmpNode ) // if no valid node was found: clena up. Otherwise: the caller has to clean up. 69 { 70 xmlFreeDoc(doc); // free the document 71 xmlCleanupParser(); // Free the global variables that may have been allocated by the parser. 72 return NULL; 73 } 74 else 75 return tmpNode; 76 77 } 78 79 xmlNode* util::checkXMLNodeChildrenForModule(xmlNode* node, std::string moduleName) 80 { 81 for (xmlNode *cur_node = node; cur_node; cur_node = cur_node->next) // iterate through all elements 82 { 83 // Is the node the one we are searching for? 84 if (cur_node->type == XML_ELEMENT_NODE) 85 { 86 std::string node_name=reinterpret_cast<const char*>(cur_node->name); 87 if (node_name == "module") 88 { 89 OSG_DEBUG << "XML node module found" << std::endl; 90 return cur_node; 91 } 92 else // Otherwise: check its children.. 93 { 94 xmlNode* tmp_XmlNode = checkXMLNodeChildrenForModule(cur_node->children, moduleName); 95 if(tmp_XmlNode) 96 return tmp_XmlNode; 97 } 98 } // IF NODE TYPE = ELEMENT END 99 100 // Proceed with next node in this loop. 101 } 27 102 } 28 103
Note: See TracChangeset
for help on using the changeset viewer.