Added Mode support

This commit is contained in:
Robert Osfield 2008-07-25 16:23:00 +00:00
parent d0890ab250
commit d137394169
2 changed files with 37 additions and 7 deletions

View File

@ -72,6 +72,11 @@ int ImageSequence::compare(const Image& rhs) const
return ImageStream::compare(rhs); return ImageStream::compare(rhs);
} }
void ImageSequence::setMode(Mode mode)
{
_mode = mode;
}
void ImageSequence::setDuration(double duration) void ImageSequence::setDuration(double duration)
{ {
_duration = duration; _duration = duration;

View File

@ -29,6 +29,24 @@ bool ImageSequence_readLocalData(Object& obj, Input& fr)
unsigned int numFilesToPreLoad = 1; 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; double duration;
if (fr.read("Duration", duration)) if (fr.read("Duration", duration))
{ {
@ -45,12 +63,6 @@ bool ImageSequence_readLocalData(Object& obj, Input& fr)
if (fr[0].getStr()) if (fr[0].getStr())
{ {
is.addImageFile(fr[0].getStr()); is.addImageFile(fr[0].getStr());
if (is.getImages().size() < numFilesToPreLoad)
{
osg::ref_ptr<osg::Image> image = fr.readImage(fr[0].getStr());
if (image.valid()) is.addImage(image.get());
}
} }
++fr; ++fr;
} }
@ -83,6 +95,19 @@ bool ImageSequence_writeLocalData(const Object& obj, Output& fw)
// no current image writing code here // no current image writing code here
// as it is all handled by osg::Registry::writeImage() via plugins. // 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"<<std::endl;
break;
case(osg::ImageSequence::PAGE_AND_RETAIN_IMAGES):
fw.indent()<<"Mode PAGE_AND_RETAIN_IMAGES"<<std::endl;
break;
case(osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES):
fw.indent()<<"Mode PAGE_AND_DISCARD_USED_IMAGES"<<std::endl;
break;
}
fw.indent()<<"Duration "<<is.getDuration()<<std::endl; fw.indent()<<"Duration "<<is.getDuration()<<std::endl;
if (!is.getFileNames().empty()) if (!is.getFileNames().empty())