diff --git a/src/osgDB/Field.cpp b/src/osgDB/Field.cpp index ae340de0f..5103b00e4 100644 --- a/src/osgDB/Field.cpp +++ b/src/osgDB/Field.cpp @@ -11,11 +11,111 @@ * OpenSceneGraph Public License for more details. */ #include +#include +#include #include using namespace osgDB; using namespace std; + +double osg_atof(const char* str) +{ + const char* ptr = str; + + // check if could be a hex number. + if (strncmp(ptr,"0x",2)==0) + { + + double value = 0.0; + + // skip over leading 0x, and then go through rest of string + // checking to make sure all values are 0...9 or a..f. + ptr+=2; + while ( + *ptr!=0 && + ((*ptr>='0' && *ptr<='9') || + (*ptr>='a' && *ptr<='f') || + (*ptr>='A' && *ptr<='F')) + ) + { + if (*ptr>='0' && *ptr<='9') value = value*16.0 + double(*ptr-'0'); + else if (*ptr>='a' && *ptr<='f') value = value*16.0 + double(*ptr-'a'+10); + else if (*ptr>='A' && *ptr<='F') value = value*16.0 + double(*ptr-'A'+10); + ++ptr; + } + + // osg::notify(osg::NOTICE)<<"Read "<