From cc2af85c966060e55b42b4d5bded55a16b190866 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 22 Jul 2008 20:20:16 +0000 Subject: [PATCH] Further work on ImageSequence --- include/osg/ImageSequence | 20 +++++---- src/osg/ImageSequence.cpp | 90 +++++++++++++++++++++++++++++++-------- 2 files changed, 84 insertions(+), 26 deletions(-) diff --git a/include/osg/ImageSequence b/include/osg/ImageSequence index 49a825620..ecdd3339e 100644 --- a/include/osg/ImageSequence +++ b/include/osg/ImageSequence @@ -53,6 +53,9 @@ class OSG_EXPORT ImageSequence : public ImageStream void setDuration(double duration); double getDuration() const { return _duration; } + + void setPreLoadTime(double preLoadTime) { _preLoadTime = preLoadTime; } + double getPreLoadTime() const { return _preLoadTime; } void setPruneOldImages(bool prune) { _pruneOldImages = prune; } bool getPruneOldImages() const { return _pruneOldImages; } @@ -85,22 +88,23 @@ class OSG_EXPORT ImageSequence : public ImageStream double _referenceTime; double _timeMultiplier; - - OpenThreads::Mutex _mutex; - FileNames _fileNames; - + double _duration; + double _preLoadTime; + bool _pruneOldImages; double _timePerImage; - + + OpenThreads::Mutex _mutex; + FileNames _fileNames; + FileNames::iterator _fileNamesIterator; + double _fileNamesIteratorTime; + double _imageHeadTime; Images _images; - Images::iterator _imageIterator; double _imageIteratorTime; - - }; } // namespace diff --git a/src/osg/ImageSequence.cpp b/src/osg/ImageSequence.cpp index beba1ff5a..ee33ecd32 100644 --- a/src/osg/ImageSequence.cpp +++ b/src/osg/ImageSequence.cpp @@ -42,11 +42,15 @@ ImageSequence::ImageSequence() _timeMultiplier = 1.0; _duration = 1.0; + _preLoadTime = 1.0; _timePerImage = 1.0; _pruneOldImages = false; - _imageIteratorTime = DBL_MAX; + _fileNamesIterator = _fileNames.end(); + _fileNamesIteratorTime = DBL_MAX; + _imageIterator = _images.end(); + _imageIteratorTime = DBL_MAX; } ImageSequence::ImageSequence(const ImageSequence& is,const CopyOp& copyop): @@ -54,8 +58,13 @@ ImageSequence::ImageSequence(const ImageSequence& is,const CopyOp& copyop): _referenceTime(is._referenceTime), _timeMultiplier(is._timeMultiplier), _duration(is._duration), + _timePerImage(is._timePerImage), + _preLoadTime(is._preLoadTime), _pruneOldImages(is._pruneOldImages) { + _fileNamesIterator = _fileNames.end(); + _fileNamesIteratorTime = DBL_MAX; + _imageIteratorTime = DBL_MAX; _imageIterator = _images.end(); } @@ -83,6 +92,12 @@ void ImageSequence::addImageFile(const std::string& fileName) OpenThreads::ScopedLock lock(_mutex); _fileNames.push_back(fileName); computeTimePerImage(); + + if (_fileNamesIterator==_fileNames.end()) + { + _fileNamesIterator = _fileNames.begin(); + _fileNamesIteratorTime = _referenceTime; + } } void ImageSequence::addImage(osg::Image* image) @@ -125,45 +140,84 @@ void ImageSequence::update(osg::NodeVisitor* nv) _referenceTime = fs->getSimulationTime(); } + if (_fileNamesIteratorTime == DBL_MAX) + { + _fileNamesIteratorTime = _referenceTime; + } + if (_imageIteratorTime == DBL_MAX) { _imageIteratorTime = _referenceTime; } double time = (fs->getSimulationTime() - _referenceTime)*_timeMultiplier; + double preLoadTime = (time+_preLoadTime)*_timeMultiplier; Images::iterator previous_imageIterator = _imageIterator; // osg::notify(osg::NOTICE)<<"time = "<