From d1373941692ff4e886b06c5b4a3ae91ea9eac924 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 25 Jul 2008 16:23:00 +0000 Subject: [PATCH] Added Mode support --- src/osg/ImageSequence.cpp | 5 ++++ src/osgPlugins/osg/ImageSequence.cpp | 39 +++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/osg/ImageSequence.cpp b/src/osg/ImageSequence.cpp index 8b10e5968..6e8e6e9f6 100644 --- a/src/osg/ImageSequence.cpp +++ b/src/osg/ImageSequence.cpp @@ -72,6 +72,11 @@ int ImageSequence::compare(const Image& rhs) const return ImageStream::compare(rhs); } +void ImageSequence::setMode(Mode mode) +{ + _mode = mode; +} + void ImageSequence::setDuration(double duration) { _duration = duration; diff --git a/src/osgPlugins/osg/ImageSequence.cpp b/src/osgPlugins/osg/ImageSequence.cpp index fe8e736a1..4265f469a 100644 --- a/src/osgPlugins/osg/ImageSequence.cpp +++ b/src/osgPlugins/osg/ImageSequence.cpp @@ -29,6 +29,24 @@ bool ImageSequence_readLocalData(Object& obj, Input& fr) unsigned int numFilesToPreLoad = 1; + + std::string modeStr; + if (fr.read("Mode",modeStr)) + { + if (modeStr=="PRE_LOAD_ALL_IMAGES") + { + is.setMode(osg::ImageSequence::PRE_LOAD_ALL_IMAGES); + } + else if (modeStr=="PAGE_AND_RETAIN_IMAGES") + { + is.setMode(osg::ImageSequence::PAGE_AND_RETAIN_IMAGES); + } + else if (modeStr=="PAGE_AND_DISCARD_USED_IMAGES") + { + is.setMode(osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES); + } + } + double duration; if (fr.read("Duration", duration)) { @@ -45,12 +63,6 @@ bool ImageSequence_readLocalData(Object& obj, Input& fr) if (fr[0].getStr()) { is.addImageFile(fr[0].getStr()); - - if (is.getImages().size() < numFilesToPreLoad) - { - osg::ref_ptr image = fr.readImage(fr[0].getStr()); - if (image.valid()) is.addImage(image.get()); - } } ++fr; } @@ -82,7 +94,20 @@ bool ImageSequence_writeLocalData(const Object& obj, Output& fw) // no current image writing code here // as it is all handled by osg::Registry::writeImage() via plugins. - + + switch(is.getMode()) + { + case(osg::ImageSequence::PRE_LOAD_ALL_IMAGES): + fw.indent()<<"Mode PRE_LOAD_ALL_IMAGES"<