From 1f219f5a7ed097ce953014cc4b4e46e974aa6baf Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Dec 2003 10:38:59 +0000 Subject: [PATCH] From Johan Nouvel, support for AnimationPathCallback values in .osg file. Includes a small modication to ensure that code works shared animation paths, by RO. --- src/osgPlugins/osg/AnimationPath.cpp | 32 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/osgPlugins/osg/AnimationPath.cpp b/src/osgPlugins/osg/AnimationPath.cpp index de2544e08..10c9837ae 100644 --- a/src/osgPlugins/osg/AnimationPath.cpp +++ b/src/osgPlugins/osg/AnimationPath.cpp @@ -146,8 +146,6 @@ bool AnimationPath_writeLocalData(const osg::Object &obj, osgDB::Output &fw) } - - // forward declare functions to use later. bool AnimationPathCallback_readLocalData(osg::Object &obj, osgDB::Input &fr); bool AnimationPathCallback_writeLocalData(const osg::Object &obj, osgDB::Output &fw); @@ -169,12 +167,28 @@ bool AnimationPathCallback_readLocalData(osg::Object &obj, osgDB::Input &fr) osg::AnimationPathCallback *apc = dynamic_cast(&obj); if (!apc) return false; + bool itrAdvanced = false; + if (fr.matchSequence("timeOffset %f")) + { + fr[1].getFloat(apc->_timeOffset); + fr+=2; + itrAdvanced = true; + } + else if(fr.matchSequence("timeMultiplier %f")) + { + fr[1].getFloat(apc->_timeMultiplier); + fr+=2; + itrAdvanced = true; + } + static osg::ref_ptr s_path = new osg::AnimationPath; ref_ptr object = fr.readObjectOfType(*s_path); - osg::AnimationPath* animpath = dynamic_cast(object.get()); - if (animpath) apc->setAnimationPath(animpath); - - bool itrAdvanced = object.valid(); + if (object.valid()) + { + osg::AnimationPath* animpath = dynamic_cast(object.get()); + if (animpath) apc->setAnimationPath(animpath); + itrAdvanced = true; + } return itrAdvanced; } @@ -182,9 +196,15 @@ bool AnimationPathCallback_readLocalData(osg::Object &obj, osgDB::Input &fr) bool AnimationPathCallback_writeLocalData(const osg::Object &obj, osgDB::Output &fw) { + + const osg::AnimationPathCallback* apc = dynamic_cast(&obj); if (!apc) return false; + + fw.indent() <<"timeOffset " <_timeOffset<_timeMultiplier << std::endl; + if (apc->getAnimationPath()) { fw.writeObject(*(apc->getAnimationPath()));