From f8daf206ab5d932fc61c97a68be381710c7dc80e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 20 May 2004 12:57:06 +0000 Subject: [PATCH] Improved support for new double Vec* classes --- include/osgDB/FieldReaderIterator | 9 +++ src/osgDB/FieldReaderIterator.cpp | 74 +++++++++++++++++++ .../osg/PositionAttitudeTransform.cpp | 6 +- 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/include/osgDB/FieldReaderIterator b/include/osgDB/FieldReaderIterator index 88ffbd6d6..1e3ce597e 100644 --- a/include/osgDB/FieldReaderIterator +++ b/include/osgDB/FieldReaderIterator @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include #include #include @@ -69,6 +72,9 @@ class OSGDB_EXPORT FieldReaderIterator bool readSequence(const char* keyword,osg::Vec2f& value); bool readSequence(const char* keyword,osg::Vec3f& value); bool readSequence(const char* keyword,osg::Vec4f& value); + bool readSequence(const char* keyword,osg::Vec2d& value); + bool readSequence(const char* keyword,osg::Vec3d& value); + bool readSequence(const char* keyword,osg::Vec4d& value); bool readSequence(std::string& value); bool readSequence(unsigned int& value); @@ -77,6 +83,9 @@ class OSGDB_EXPORT FieldReaderIterator bool readSequence(osg::Vec2f& value); bool readSequence(osg::Vec3f& value); bool readSequence(osg::Vec4f& value); + bool readSequence(osg::Vec2d& value); + bool readSequence(osg::Vec3d& value); + bool readSequence(osg::Vec4d& value); private: diff --git a/src/osgDB/FieldReaderIterator.cpp b/src/osgDB/FieldReaderIterator.cpp index 290cbc8da..0d97385e7 100644 --- a/src/osgDB/FieldReaderIterator.cpp +++ b/src/osgDB/FieldReaderIterator.cpp @@ -472,6 +472,45 @@ bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec4f& value) return false; } +bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec2d& value) +{ + if ((*this)[0].matchWord(keyword) && + (*this)[1].getFloat(value[0]) && + (*this)[2].getFloat(value[1])) + { + (*this)+=3; + return true; + } + return false; +} + +bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec3d& value) +{ + if ((*this)[0].matchWord(keyword) && + (*this)[1].getFloat(value[0]) && + (*this)[2].getFloat(value[1]) && + (*this)[3].getFloat(value[2])) + { + (*this)+=4; + return true; + } + return false; +} + +bool FieldReaderIterator::readSequence(const char* keyword,osg::Vec4d& value) +{ + if ((*this)[0].matchWord(keyword) && + (*this)[1].getFloat(value[0]) && + (*this)[2].getFloat(value[1]) && + (*this)[3].getFloat(value[2]) && + (*this)[4].getFloat(value[3])) + { + (*this)+=5; + return true; + } + return false; +} + bool FieldReaderIterator::readSequence(std::string& value) { if ((*this)[0].isString()) @@ -550,3 +589,38 @@ bool FieldReaderIterator::readSequence(osg::Vec4f& value) } +bool FieldReaderIterator::readSequence(osg::Vec2d& value) +{ + if ((*this)[0].getFloat(value[0]) && + (*this)[1].getFloat(value[1])) + { + (*this)+=2; + return true; + } + return false; +} + +bool FieldReaderIterator::readSequence(osg::Vec3d& value) +{ + if ((*this)[0].getFloat(value[0]) && + (*this)[1].getFloat(value[1]) && + (*this)[2].getFloat(value[2])) + { + (*this)+=3; + return true; + } + return false; +} + +bool FieldReaderIterator::readSequence(osg::Vec4d& value) +{ + if ((*this)[0].getFloat(value[0]) && + (*this)[1].getFloat(value[1]) && + (*this)[2].getFloat(value[2]) && + (*this)[3].getFloat(value[3])) + { + (*this)+=4; + return true; + } + return false; +} diff --git a/src/osgPlugins/osg/PositionAttitudeTransform.cpp b/src/osgPlugins/osg/PositionAttitudeTransform.cpp index e151aeac4..38192b383 100644 --- a/src/osgPlugins/osg/PositionAttitudeTransform.cpp +++ b/src/osgPlugins/osg/PositionAttitudeTransform.cpp @@ -30,7 +30,7 @@ bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr) if (fr.matchSequence("position %f %f %f")) { - osg::Vec3 pos; + osg::Vec3d pos; fr[1].getFloat(pos[0]); fr[2].getFloat(pos[1]); fr[3].getFloat(pos[2]); @@ -57,7 +57,7 @@ bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr) if (fr.matchSequence("scale %f %f %f")) { - osg::Vec3 scale; + osg::Vec3d scale; fr[1].getFloat(scale[0]); fr[2].getFloat(scale[1]); fr[3].getFloat(scale[2]); @@ -70,7 +70,7 @@ bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr) if (fr.matchSequence("pivotPoint %f %f %f")) { - osg::Vec3 pivot; + osg::Vec3d pivot; fr[1].getFloat(pivot[0]); fr[2].getFloat(pivot[1]); fr[3].getFloat(pivot[2]);