Changeset 151 for osgVisual/src
- Timestamp:
- Nov 9, 2010, 10:37:40 PM (14 years ago)
- Location:
- osgVisual/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/src/core/visual_core.cpp
r148 r151 43 43 } 44 44 45 xmlDoc* tmpDoc;46 util::getModuleXMLConfig( configFilename, "core", tmpDoc );47 if(tmpDoc)48 {49 xmlFreeDoc(tmpDoc); xmlCleanupParser();50 }51 52 53 45 // Configure osg to use KdTrees 54 46 osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES); … … 79 71 #ifdef USE_DISTORTION 80 72 // Initialize distortion 81 OSG_NOTIFY( osg::ALWAYS ) << "Using distortion." << std::endl;82 73 distortion = new visual_distortion( viewer, arguments, configFilename ); 83 distortion->initialize( rootNode, viewer->getCamera()->getClearColor() ); 84 distortedSceneGraph = distortion->getDistortedSceneGraph(); 74 distortedSceneGraph = distortion->initialize( rootNode, viewer->getCamera()->getClearColor() ); 85 75 #endif 86 76 -
osgVisual/src/distortion/visual_distortion.cpp
r150 r151 49 49 if(config) 50 50 { 51 51 OSG_NOTIFY( osg::ALWAYS ) << "Using distortion." << std::endl; 52 52 53 xmlNode* a_node = config->children; 53 54 … … 55 56 { 56 57 std::string node_name=reinterpret_cast<const char*>(cur_node->name); 57 OSG_ALWAYS << "----visual_distortion::processXMLConfiguration() - node type="<< cur_node->type <<", name=" << cur_node->name << std::endl;58 //OSG_ALWAYS << "----visual_distortion::processXMLConfiguration() - node type="<< cur_node->type <<", name=" << cur_node->name << std::endl; 58 59 59 60 // Check for distortion node … … 68 69 { 69 70 std::string channelname = attr_value; 70 OSG_NOTIFY(osg::ALWAYS) << " channelname:" << channelname << std::endl;71 OSG_NOTIFY(osg::ALWAYS) << "visual_distortion: Channelname:" << channelname << std::endl; 71 72 72 73 std::string pre_cfg("..\\resources\\distortion\\view_"); … … 136 137 distortMapFileName = attr_value; 137 138 } 138 139 139 attr = attr->next; 140 140 } … … 153 153 blendMapFileName = attr_value; 154 154 } 155 156 155 attr = attr->next; 157 156 } … … 159 158 } // FOR all nodes END 160 159 161 160 // clean up 161 xmlFreeDoc(tmpDoc); xmlCleanupParser(); 162 return true; 162 163 } // IF Config valid END 163 164 else 164 OSG_WARN << "ERROR: visual_distortion::processXMLConfiguration() - Invalid module configuration!" << std::endl; 165 166 167 168 // clean up 169 if(tmpDoc) 170 { 171 xmlFreeDoc(tmpDoc); xmlCleanupParser(); 172 return true; 165 { 166 OSG_WARN << "WARNING: visual_distortion::processXMLConfiguration() - Module configuration not found or module disabled!" << std::endl; 167 return false; 173 168 } 169 170 174 171 175 172 return true; … … 191 188 192 189 // Process XML configuration 193 processXMLConfiguration(); 190 if(!processXMLConfiguration()) 191 return NULL; // Abort distortion initialization. 194 192 195 193 // Add this node to the scenegraph to get updated during update traversal. -
osgVisual/src/util/visual_util.cpp
r146 r151 146 146 if (cur_node->type == XML_ELEMENT_NODE) 147 147 { 148 std::string node_name=reinterpret_cast<const char*>(cur_node->name); 149 if (node_name == "module") 148 // Extract Node Name and the first attribute: "module name" 149 std::string node_name = reinterpret_cast<const char*>(cur_node->name); 150 std::string modName = ""; 151 xmlAttr *attr = cur_node->properties; 152 while ( attr ) 153 { 154 std::string attr_name=reinterpret_cast<const char*>(attr->name); 155 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 156 if( attr_name == "name" ) 157 modName = attr_value; 158 attr = attr->next; 159 } 160 161 // Check each node for the searched module 162 if (node_name == "module" && modName == moduleName) 150 163 { 151 OSG_DEBUG << "XML node module found" << std::endl; 152 return cur_node; 164 // Check if the module is active 165 xmlAttr *attr = cur_node->properties; 166 while ( attr ) 167 { 168 std::string attr_name=reinterpret_cast<const char*>(attr->name); 169 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 170 if( attr_name == "enabled" && attr_value == "yes" ) 171 { 172 OSG_ALWAYS << "Found XML module configuration for " << moduleName << std::endl; 173 return cur_node; 174 } 175 if( attr_name == "enabled" && attr_value == "no" ) 176 { 177 OSG_ALWAYS << "Found XML module configuration for " << moduleName << ", but it is DISABLED." << std::endl; 178 return NULL; 179 } 180 attr = attr->next; 181 } 153 182 } 154 183 else // Otherwise: check its children..
Note: See TracChangeset
for help on using the changeset viewer.