Changeset 150


Ignore:
Timestamp:
Nov 9, 2010, 7:40:51 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/include/distortion/visual_distortion.h

    r148 r150  
    7575        virtual ~visual_distortion(void);
    7676
    77         bool processXMLConfiguration();
    78 
    79         /**
    80          * \brief This function parses the arguments for distortion relevant parameters.
     77        /**
     78         * \brief This function parses the XML config file for distortion relevant parameters.
    8179         *
    8280         * @return : True if parsing was successful.
    8381         */
    84         bool processCommandlineparameters();
     82                bool processXMLConfiguration();
    8583
    8684        /**
  • osgVisual/src/distortion/visual_distortion.cpp

    r149 r150  
    6666                                        std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
    6767                                        if( attr_name == "channelname" )
    68                                                 channelname = attr_value;
     68                                        {
     69                                                std::string  channelname = attr_value;
     70                                                OSG_NOTIFY(osg::ALWAYS) << "channelname:" << channelname << std::endl;
     71
     72                                                std::string pre_cfg("..\\resources\\distortion\\view_");
     73                                                std::string pre_distortion("..\\resources\\distortion\\distort_");
     74                                                std::string pre_blend("..\\resources\\distortion\\blend_");
     75                                                std::string post_cfg(".cfg");
     76                                                std::string post_distortion(".bmp");
     77                                                std::string post_blend(".bmp");
     78
     79                                                // load channel config
     80                                                parser->parseConfigFile((pre_cfg+channelname+post_cfg).data());
     81                                                // load channel blendmap
     82                                                blendMapFileName = (pre_blend+channelname+post_blend).data();
     83                                                // load channel distortionmap
     84                                                distortMapFileName = (pre_distortion+channelname+post_distortion).data();
     85                                                // set channel frustum
     86                                                if( parser->isConfigParsed())
     87                                                        viewer->getCamera()->setProjectionMatrixAsFrustum((parser->getFrustumDataset())[0], (parser->getFrustumDataset())[1], (parser->getFrustumDataset())[2], (parser->getFrustumDataset())[3], (parser->getFrustumDataset())[4], (parser->getFrustumDataset())[5]);
     88                                                else
     89                                                        OSG_NOTIFY(osg::WARN) << "WARNING: Unable to parse Frustum values from '" << pre_cfg<<channelname<<post_cfg << "' -- continue without valid frustum values." << std::endl;
     90                                        }
    6991                                        if( attr_name == "renderimplemmentation" )
    7092                                        {
     
    105127                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "distortionmap")
    106128                        {
    107 
     129                                xmlAttr  *attr = cur_node->properties;
     130                                while ( attr )
     131                                {
     132                                        std::string attr_name=reinterpret_cast<const char*>(attr->name);
     133                                        std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     134                                        if( attr_name == "filename" )
     135                                        {
     136                                                distortMapFileName = attr_value;
     137                                        }
     138
     139                                        attr = attr->next;
     140                                }
    108141                        }
    109142
     
    111144                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "blendmap")
    112145                        {
    113 
     146                                xmlAttr  *attr = cur_node->properties;
     147                                while ( attr )
     148                                {
     149                                        std::string attr_name=reinterpret_cast<const char*>(attr->name);
     150                                        std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     151                                        if( attr_name == "filename" )
     152                                        {
     153                                                blendMapFileName = attr_value;
     154                                        }
     155
     156                                        attr = attr->next;
     157                                }
    114158                        }
    115159                }       // FOR all nodes END
     
    129173        }
    130174
    131         return true;
    132 }
    133 
    134 bool visual_distortion::processCommandlineparameters()
    135 {
    136         // Distortion files.
    137         arguments.getApplicationUsage()->addCommandLineOption("-C <channelname>","Setup the channel name, this is the preset for blendmap, distortionmap and camera configuration file.");
    138 
    139         arguments.getApplicationUsage()->addCommandLineOption("--distortionmap","Set a distortion map file name.");
    140     arguments.getApplicationUsage()->addCommandLineOption("--blendmap","Set a blend map file name.");
    141 
    142         //while (arguments.read("--distortionmap", distortMapFileName)) { }
    143     //while (arguments.read("--blendmap", blendMapFileName)) { }
    144 
    145         std::string pre_cfg("..\\resources\\distortion\\view_");
    146         std::string pre_distortion("..\\resources\\distortion\\distort_");
    147         std::string pre_blend("..\\resources\\distortion\\blend_");
    148         std::string post_cfg(".cfg");
    149         std::string post_distortion(".bmp");
    150         std::string post_blend(".bmp");
    151         std::string channelname;
    152         while (arguments.read("-C",channelname))
    153         {
    154                 OSG_NOTIFY(osg::INFO) << "channelname:" << channelname << std::endl;
    155                 // load channel config
    156                 parser->parseConfigFile((pre_cfg+channelname+post_cfg).data());
    157                 // load channel blendmap
    158                 blendMapFileName = (pre_blend+channelname+post_blend).data();
    159                 // load channel distortionmap
    160                 distortMapFileName = (pre_distortion+channelname+post_distortion).data();
    161                 // set channel frustum
    162                 if( parser->isConfigParsed())
    163                         viewer->getCamera()->setProjectionMatrixAsFrustum((parser->getFrustumDataset())[0], (parser->getFrustumDataset())[1], (parser->getFrustumDataset())[2], (parser->getFrustumDataset())[3], (parser->getFrustumDataset())[4], (parser->getFrustumDataset())[5]);
    164                 else
    165                         OSG_NOTIFY(osg::WARN) << "WARNING: Unable to parse Frustum values from '" << pre_cfg<<channelname<<post_cfg << "' -- continue without valid frustum values." << std::endl;
    166         }
    167 
    168          // report any errors if they have occurred when parsing the program arguments.
    169     if (arguments.errors())
    170     {
    171         arguments.writeErrorMessages(std::cout);
    172                 exit(1);
    173     }
    174175        return true;
    175176}
     
    191192        // Process XML configuration
    192193        processXMLConfiguration();
    193 
    194         // Process Commandline arguments:
    195         processCommandlineparameters();
    196194
    197195        // Add this node to the scenegraph to get updated during update traversal.
Note: See TracChangeset for help on using the changeset viewer.