From Johan Nouvel, support for AnimationPathCallback values in .osg file.

Includes a small modication to ensure that code works shared animation paths, by RO.
This commit is contained in:
Robert Osfield
2003-12-09 10:38:59 +00:00
parent e6d3af7a46
commit 1f219f5a7e

View File

@@ -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<osg::AnimationPathCallback*>(&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<osg::AnimationPath> s_path = new osg::AnimationPath;
ref_ptr<osg::Object> object = fr.readObjectOfType(*s_path);
osg::AnimationPath* animpath = dynamic_cast<osg::AnimationPath*>(object.get());
if (animpath) apc->setAnimationPath(animpath);
bool itrAdvanced = object.valid();
if (object.valid())
{
osg::AnimationPath* animpath = dynamic_cast<osg::AnimationPath*>(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<const osg::AnimationPathCallback*>(&obj);
if (!apc) return false;
fw.indent() <<"timeOffset " <<apc->_timeOffset<<std::endl;
fw.indent() <<"timeMultiplier " <<apc->_timeMultiplier << std::endl;
if (apc->getAnimationPath())
{
fw.writeObject(*(apc->getAnimationPath()));