diff --git a/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp b/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp index 06d3a240d..348d7b83f 100644 --- a/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp +++ b/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp @@ -11,6 +11,8 @@ #include #include +#include + class ReaderWriterTerrain : public osgDB::ReaderWriter { public: @@ -29,6 +31,22 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* opt) const { std::string ext = osgDB::getLowerCaseFileExtension(file); + + if (osgDB::equalCaseInsensitive(ext,"terrain")) + { + KeywordValueMap keywordValueMap; + parseTerrainString(osgDB::getNameLessExtension(file), keywordValueMap); + + for(KeywordValueMap::iterator itr = keywordValueMap.begin(); + itr != keywordValueMap.end(); + ++itr) + { + osg::notify(osg::NOTICE)<<"["<first<<"] = "<<"["<second<<"]"< KeywordValueMap; + bool parseTerrainString(const std::string& str, KeywordValueMap& keywordValueMap) const + { + bool success = false; + + std::string::size_type pos = 0; + while(pos != std::string::npos) + { + pos = str.find_first_not_of(' ',pos); + if (pos == std::string::npos) break; + + std::string::size_type semicolon = str.find_first_of(';', pos); + std::string::size_type startstatement = pos; + std::string::size_type endstatement = std::string::npos; + if (semicolon!=std::string::npos) + { + endstatement = semicolon-1; + pos = semicolon+1; + } + else + { + endstatement = str.length()-1; + pos = std::string::npos; + } + + if (startstatementendstatement) + { + assignment = std::string::npos; + } + + std::string::size_type startvariable = startstatement; + std::string::size_type endvariable = startstatement; + std::string::size_type startvalue = startstatement; + std::string::size_type endvalue = endstatement; + + if (assignment!=std::string::npos) + { + endvariable = assignment-1; + startvalue = assignment+1; + + if (startvariable<=endvariable) + { + endvariable = str.find_last_not_of(' ',endvariable); + } + + if (startvariable<=endvariable) + { + ++endvariable; + } + } + + + if (startvalue<=endvalue) + { + startvalue = str.find_first_not_of(' ',startvalue); + } + + if (startvalue<=endvalue) + { + if (startvariable