2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2008-07-21 17:46:53 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2008-07-21 17:46:53 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2008-07-21 17:46:53 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-07-21 17:46:53 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2008-07-21 18:57:06 +08:00
|
|
|
#include <OpenThreads/ScopedLock>
|
2008-07-21 17:46:53 +08:00
|
|
|
#include <osg/ImageSequence>
|
2008-07-22 01:28:22 +08:00
|
|
|
#include <osg/Notify>
|
|
|
|
#include <osg/Camera>
|
2008-07-22 05:00:57 +08:00
|
|
|
#include <osg/NodeVisitor>
|
|
|
|
#include <osg/Texture2D>
|
2008-07-22 01:28:22 +08:00
|
|
|
|
|
|
|
#include <math.h>
|
2008-07-21 17:46:53 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
ImageSequence::ImageSequence()
|
|
|
|
{
|
2008-07-22 01:28:22 +08:00
|
|
|
_referenceTime = DBL_MAX;
|
2008-07-21 17:46:53 +08:00
|
|
|
_timeMultiplier = 1.0;
|
2008-07-22 05:00:57 +08:00
|
|
|
|
2008-07-26 00:11:51 +08:00
|
|
|
_mode = PRE_LOAD_ALL_IMAGES;
|
2008-08-16 00:21:44 +08:00
|
|
|
_length = 1.0;
|
2008-07-23 00:44:49 +08:00
|
|
|
_timePerImage = 1.0;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-08-15 20:45:20 +08:00
|
|
|
_seekTime = 0.0;
|
|
|
|
_seekTimeSet = false;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
_previousAppliedImageIndex = -1;
|
2008-07-21 17:46:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ImageSequence::ImageSequence(const ImageSequence& is,const CopyOp& copyop):
|
|
|
|
osg::ImageStream(is,copyop),
|
|
|
|
_referenceTime(is._referenceTime),
|
2008-07-22 05:00:57 +08:00
|
|
|
_timeMultiplier(is._timeMultiplier),
|
2008-07-26 00:11:51 +08:00
|
|
|
_mode(is._mode),
|
2008-08-16 00:21:44 +08:00
|
|
|
_length(is._length),
|
2008-07-26 00:11:51 +08:00
|
|
|
_timePerImage(is._timePerImage)
|
2008-07-21 17:46:53 +08:00
|
|
|
{
|
2008-08-15 20:45:20 +08:00
|
|
|
_seekTime = is._seekTime;
|
|
|
|
_seekTimeSet = is._seekTimeSet;
|
2008-10-07 01:02:20 +08:00
|
|
|
|
|
|
|
_previousAppliedImageIndex = -1;
|
2008-07-21 17:46:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int ImageSequence::compare(const Image& rhs) const
|
|
|
|
{
|
|
|
|
return ImageStream::compare(rhs);
|
|
|
|
}
|
|
|
|
|
2008-08-15 20:45:20 +08:00
|
|
|
void ImageSequence::seek(double time)
|
|
|
|
{
|
|
|
|
_seekTime = time;
|
|
|
|
_seekTimeSet = true;
|
|
|
|
}
|
|
|
|
|
2008-08-15 00:29:12 +08:00
|
|
|
void ImageSequence::play()
|
|
|
|
{
|
|
|
|
_status=PLAYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageSequence::pause()
|
|
|
|
{
|
|
|
|
_status=PAUSED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageSequence::rewind()
|
|
|
|
{
|
2008-08-15 20:45:20 +08:00
|
|
|
seek(0.0f);
|
2008-08-15 00:29:12 +08:00
|
|
|
}
|
|
|
|
|
2008-07-26 00:23:00 +08:00
|
|
|
void ImageSequence::setMode(Mode mode)
|
|
|
|
{
|
|
|
|
_mode = mode;
|
|
|
|
}
|
|
|
|
|
2008-08-16 00:21:44 +08:00
|
|
|
void ImageSequence::setLength(double length)
|
2008-07-23 00:44:49 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
if (length<=0.0)
|
|
|
|
{
|
2010-05-28 23:47:52 +08:00
|
|
|
OSG_NOTICE<<"ImageSequence::setLength("<<length<<") invalid length value, must be greater than 0."<<std::endl;
|
2008-10-07 01:02:20 +08:00
|
|
|
return;
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-08-16 00:21:44 +08:00
|
|
|
_length = length;
|
2008-07-23 00:44:49 +08:00
|
|
|
computeTimePerImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageSequence::computeTimePerImage()
|
|
|
|
{
|
2008-08-16 00:21:44 +08:00
|
|
|
if (!_fileNames.empty()) _timePerImage = _length / double(_fileNames.size());
|
|
|
|
else if (!_images.empty()) _timePerImage = _length / double(_images.size());
|
|
|
|
else _timePerImage = _length;
|
2008-07-23 00:44:49 +08:00
|
|
|
}
|
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
void ImageSequence::setImageFile(unsigned int pos, const std::string& fileName)
|
|
|
|
{
|
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
|
|
|
|
if (pos>=_fileNames.size()) _fileNames.resize(pos);
|
|
|
|
_fileNames[pos] = fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ImageSequence::getImageFile(unsigned int pos) const
|
|
|
|
{
|
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
return pos<_fileNames.size() ? _fileNames[pos] : std::string();
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-07-22 05:00:57 +08:00
|
|
|
void ImageSequence::addImageFile(const std::string& fileName)
|
2008-07-21 17:46:53 +08:00
|
|
|
{
|
2008-07-21 18:57:06 +08:00
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
2008-07-22 05:00:57 +08:00
|
|
|
_fileNames.push_back(fileName);
|
2008-07-23 00:44:49 +08:00
|
|
|
computeTimePerImage();
|
2008-10-07 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageSequence::setImage(unsigned int pos, osg::Image* image)
|
|
|
|
{
|
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
|
2010-05-28 23:47:52 +08:00
|
|
|
OSG_INFO<<"ImageSequence::setImage("<<pos<<","<<image->getFileName()<<")"<<std::endl;
|
2008-10-07 01:02:20 +08:00
|
|
|
|
|
|
|
if (pos>=_images.size()) _images.resize(pos+1);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
_images[pos] = image;
|
|
|
|
|
|
|
|
// prune from file requested list.
|
|
|
|
FilesRequested::iterator itr = _filesRequested.find(image->getFileName());
|
|
|
|
if (itr!=_filesRequested.end()) _filesRequested.erase(itr);
|
2008-07-21 17:46:53 +08:00
|
|
|
}
|
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
Image* ImageSequence::getImage(unsigned int pos)
|
2008-07-21 17:46:53 +08:00
|
|
|
{
|
2008-07-21 18:57:06 +08:00
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
2008-10-07 01:02:20 +08:00
|
|
|
return pos<_images.size() ? _images[pos].get() : 0;
|
|
|
|
}
|
2008-07-22 01:28:22 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
const Image* ImageSequence::getImage(unsigned int pos) const
|
|
|
|
{
|
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
return pos<_images.size() ? _images[pos].get() : 0;
|
|
|
|
}
|
2008-07-25 21:45:07 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
void ImageSequence::addImage(osg::Image* image)
|
|
|
|
{
|
|
|
|
if (image==0) return;
|
|
|
|
|
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
|
2010-05-28 23:47:52 +08:00
|
|
|
// OSG_NOTICE<<"merging image in order expected : "<<image->getFileName()<<std::endl;
|
2008-10-07 01:02:20 +08:00
|
|
|
_images.push_back(image);
|
2008-07-25 21:45:07 +08:00
|
|
|
|
|
|
|
computeTimePerImage();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-07-25 21:45:07 +08:00
|
|
|
if (data()==0)
|
2008-07-22 01:28:22 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
setImageToChild(_images.front().get());
|
2008-07-22 01:28:22 +08:00
|
|
|
}
|
2008-07-21 17:46:53 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 01:28:22 +08:00
|
|
|
void ImageSequence::setImageToChild(const osg::Image* image)
|
|
|
|
{
|
2010-05-28 23:47:52 +08:00
|
|
|
// OSG_NOTICE<<"setImageToChild("<<image<<")"<<std::endl;
|
2008-07-22 05:00:57 +08:00
|
|
|
|
2008-07-26 00:11:51 +08:00
|
|
|
if (image==0) return;
|
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
// check to see if data is changing, if not don't apply
|
|
|
|
if (image->data() == data()) return;
|
|
|
|
|
2008-07-22 01:28:22 +08:00
|
|
|
setImage(image->s(),image->t(),image->r(),
|
|
|
|
image->getInternalTextureFormat(),
|
|
|
|
image->getPixelFormat(),image->getDataType(),
|
|
|
|
const_cast<unsigned char*>(image->data()),
|
|
|
|
osg::Image::NO_DELETE,
|
|
|
|
image->getPacking());
|
|
|
|
}
|
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
void ImageSequence::applyLoopingMode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int ImageSequence::imageIndex(double time)
|
|
|
|
{
|
2012-03-22 01:36:20 +08:00
|
|
|
if (getLoopingMode()==LOOPING)
|
2008-10-07 01:02:20 +08:00
|
|
|
{
|
|
|
|
double positionRatio = time/_length;
|
|
|
|
time = (positionRatio - floor(positionRatio))*_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time<0.0) return 0;
|
|
|
|
int index = int(time/_timePerImage);
|
2008-10-27 21:09:43 +08:00
|
|
|
if (index>=int(_images.size())) return int(_images.size())-1;
|
2008-10-07 01:02:20 +08:00
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2008-07-22 05:00:57 +08:00
|
|
|
void ImageSequence::update(osg::NodeVisitor* nv)
|
2008-07-21 17:46:53 +08:00
|
|
|
{
|
2008-07-21 18:57:06 +08:00
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-07-22 05:00:57 +08:00
|
|
|
osg::NodeVisitor::ImageRequestHandler* irh = nv->getImageRequestHandler();
|
|
|
|
const osg::FrameStamp* fs = nv->getFrameStamp();
|
|
|
|
|
2010-05-28 23:47:52 +08:00
|
|
|
// OSG_NOTICE<<"ImageSequence::update("<<fs<<", "<<irh<<")"<<std::endl;
|
2008-07-22 01:28:22 +08:00
|
|
|
|
|
|
|
if (_referenceTime == DBL_MAX)
|
|
|
|
{
|
|
|
|
_referenceTime = fs->getSimulationTime();
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-08-15 20:45:20 +08:00
|
|
|
bool looping = getLoopingMode()==LOOPING;
|
|
|
|
double time = (fs->getSimulationTime() - _referenceTime)*_timeMultiplier;
|
2012-10-05 18:37:36 +08:00
|
|
|
bool useDirectTimeRequest = _seekTimeSet;
|
|
|
|
|
2008-08-15 20:45:20 +08:00
|
|
|
if (_seekTimeSet || _status==PAUSED || _status==INVALID)
|
2008-07-22 01:28:22 +08:00
|
|
|
{
|
2012-03-22 01:36:20 +08:00
|
|
|
time = _seekTime;
|
2008-08-15 20:45:20 +08:00
|
|
|
_referenceTime = fs->getSimulationTime() - time/_timeMultiplier;
|
2008-07-22 01:28:22 +08:00
|
|
|
}
|
2008-10-07 01:02:20 +08:00
|
|
|
else
|
2008-08-15 20:45:20 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
if (looping)
|
|
|
|
{
|
|
|
|
while (time>_length)
|
|
|
|
{
|
|
|
|
_referenceTime += _length/_timeMultiplier;
|
|
|
|
time -= _length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (time>_length)
|
|
|
|
{
|
|
|
|
_referenceTime = fs->getSimulationTime() - _length/_timeMultiplier;
|
|
|
|
time = _length;
|
|
|
|
}
|
|
|
|
}
|
2008-08-15 20:45:20 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-08-15 20:45:20 +08:00
|
|
|
_seekTime = time;
|
2008-10-07 01:02:20 +08:00
|
|
|
_seekTimeSet = false;
|
2008-08-15 20:45:20 +08:00
|
|
|
|
2008-07-26 00:11:51 +08:00
|
|
|
bool pruneOldImages = false;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-07-26 00:11:51 +08:00
|
|
|
switch(_mode)
|
|
|
|
{
|
|
|
|
case(PRE_LOAD_ALL_IMAGES):
|
|
|
|
{
|
2012-10-05 18:37:36 +08:00
|
|
|
if (irh && _fileNames.size()>_images.size())
|
2008-07-26 00:11:51 +08:00
|
|
|
{
|
2008-07-26 01:42:37 +08:00
|
|
|
FileNames::iterator itr = _fileNames.begin();
|
|
|
|
for(unsigned int i=0;i<_images.size();++i) ++itr;
|
|
|
|
|
|
|
|
for(; itr!=_fileNames.end(); ++itr)
|
2008-07-26 00:11:51 +08:00
|
|
|
{
|
2008-07-26 01:42:37 +08:00
|
|
|
osg::Image* image = irh->readImageFile(*itr);
|
2008-07-26 00:11:51 +08:00
|
|
|
_images.push_back(image);
|
|
|
|
}
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-07-26 00:11:51 +08:00
|
|
|
irh = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case(PAGE_AND_RETAIN_IMAGES):
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case(PAGE_AND_DISCARD_USED_IMAGES):
|
|
|
|
{
|
|
|
|
pruneOldImages = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
int index = int(time/_timePerImage);
|
2010-05-28 23:47:52 +08:00
|
|
|
// OSG_NOTICE<<"time= "<<time<<" _timePerImage="<<_timePerImage<<" index="<<index<<" _length="<<_length<<std::endl;
|
2008-07-22 01:28:22 +08:00
|
|
|
|
2008-10-27 21:09:43 +08:00
|
|
|
if (index>=int(_images.size())) index = int(_images.size())-1;
|
2008-10-07 01:02:20 +08:00
|
|
|
|
2008-10-27 21:09:43 +08:00
|
|
|
if (index>=0 && index<int(_images.size()))
|
2008-07-22 01:28:22 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
if (pruneOldImages)
|
|
|
|
{
|
2012-10-05 18:37:36 +08:00
|
|
|
if (_previousAppliedImageIndex<index)
|
2008-08-16 00:21:44 +08:00
|
|
|
{
|
2012-11-05 20:21:34 +08:00
|
|
|
OSG_DEBUG<<"ImageSequence::update(..) Moving forward by "<<index-_previousAppliedImageIndex<<std::endl;
|
2012-10-05 18:37:36 +08:00
|
|
|
while (index>=0 && !_images[index].valid())
|
|
|
|
{
|
|
|
|
--index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_previousAppliedImageIndex>index)
|
|
|
|
{
|
2012-11-05 20:21:34 +08:00
|
|
|
OSG_DEBUG<<"ImageSequence::update(..) Moving back by "<<_previousAppliedImageIndex-index<<std::endl;
|
2012-10-05 18:37:36 +08:00
|
|
|
while (index<static_cast<int>(_images.size()) && !_images[index].valid())
|
|
|
|
{
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-29 23:58:02 +08:00
|
|
|
// OSG_NOTICE<<"ImageSequence::update(..) Same index."<<std::endl;
|
2008-08-16 00:21:44 +08:00
|
|
|
}
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
if (index>=0)
|
2008-07-22 01:28:22 +08:00
|
|
|
{
|
2010-05-28 23:47:52 +08:00
|
|
|
// OSG_NOTICE<<"at time "<<time<<" setting child = "<<index<<std::endl;
|
2008-08-16 00:21:44 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
if (_previousAppliedImageIndex!=index)
|
2008-07-22 01:28:22 +08:00
|
|
|
{
|
2012-03-22 01:36:20 +08:00
|
|
|
if (_previousAppliedImageIndex >= 0 &&
|
|
|
|
_previousAppliedImageIndex<int(_images.size()) &&
|
2008-10-07 01:02:20 +08:00
|
|
|
pruneOldImages)
|
2008-07-23 00:44:49 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
_images[_previousAppliedImageIndex] = 0;
|
2008-07-23 00:44:49 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
setImageToChild(_images[index].get());
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
_previousAppliedImageIndex = index;
|
2008-07-22 01:28:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-15 20:45:20 +08:00
|
|
|
|
2010-05-28 23:47:52 +08:00
|
|
|
// OSG_NOTICE<<"time = "<<time<<std::endl;
|
2008-08-15 20:45:20 +08:00
|
|
|
|
2012-10-05 18:37:36 +08:00
|
|
|
if (!irh) return;
|
|
|
|
|
|
|
|
if (useDirectTimeRequest)
|
|
|
|
{
|
|
|
|
int i = int(time/_timePerImage);
|
|
|
|
if ((i>=int(_images.size()) || !_images[i]))
|
|
|
|
{
|
2012-11-01 22:29:26 +08:00
|
|
|
i = osg::clampTo<int>(i, 0, _fileNames.size()-1);
|
2012-10-05 18:37:36 +08:00
|
|
|
if (_filesRequested.count(_fileNames[i])==0)
|
|
|
|
{
|
2012-11-05 20:21:34 +08:00
|
|
|
OSG_INFO<<"Requesting file, entry="<<i<<" : _fileNames[i]="<<_fileNames[i]<<std::endl;
|
2012-10-05 18:37:36 +08:00
|
|
|
//_filesRequested.insert(_fileNames[i]);
|
|
|
|
irh->requestImageFile(_fileNames[i], this, i, time, fs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-05 20:21:34 +08:00
|
|
|
OSG_DEBUG<<"File already requested, entry="<<i<<" : _fileNames[i]="<<_fileNames[i]<<std::endl;
|
2012-10-05 18:37:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-07-22 01:28:22 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
double preLoadTime = time + osg::minimum(irh->getPreLoadTime()*_timeMultiplier, _length);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
int startLoadIndex = int(time/_timePerImage);
|
2008-10-27 21:09:43 +08:00
|
|
|
if (startLoadIndex>=int(_images.size())) startLoadIndex = int(_images.size())-1;
|
2008-10-07 01:02:20 +08:00
|
|
|
if (startLoadIndex<0) startLoadIndex = 0;
|
2008-08-15 20:45:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
int endLoadIndex = int(preLoadTime/_timePerImage);
|
2012-03-22 01:36:20 +08:00
|
|
|
if (endLoadIndex>=int(_fileNames.size()))
|
2008-08-15 20:45:20 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
if (looping)
|
|
|
|
{
|
2008-10-27 21:09:43 +08:00
|
|
|
endLoadIndex -= int(_fileNames.size());
|
2008-10-07 01:02:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-27 21:09:43 +08:00
|
|
|
endLoadIndex = int(_fileNames.size())-1;
|
2008-10-07 01:02:20 +08:00
|
|
|
}
|
2008-08-15 20:45:20 +08:00
|
|
|
}
|
2008-10-07 01:02:20 +08:00
|
|
|
if (endLoadIndex<0) endLoadIndex = 0;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
double requestTime = time;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
if (endLoadIndex<startLoadIndex)
|
2008-07-23 04:20:16 +08:00
|
|
|
{
|
2008-10-27 21:09:43 +08:00
|
|
|
for(int i=startLoadIndex; i<int(_fileNames.size()); ++i)
|
2008-07-23 04:20:16 +08:00
|
|
|
{
|
2008-10-27 21:09:43 +08:00
|
|
|
if ((i>=int(_images.size()) || !_images[i]) && _filesRequested.count(_fileNames[i])==0)
|
2008-07-23 04:20:16 +08:00
|
|
|
{
|
2012-10-10 00:14:21 +08:00
|
|
|
//_filesRequested.insert(_fileNames[i]);
|
2008-10-07 01:02:20 +08:00
|
|
|
irh->requestImageFile(_fileNames[i], this, i, requestTime, fs);
|
2008-07-23 04:20:16 +08:00
|
|
|
}
|
2008-10-07 01:02:20 +08:00
|
|
|
requestTime += _timePerImage;
|
2008-07-23 04:20:16 +08:00
|
|
|
}
|
|
|
|
|
2008-10-07 01:02:20 +08:00
|
|
|
for(int i=0; i<=endLoadIndex; ++i)
|
|
|
|
{
|
2008-10-27 21:09:43 +08:00
|
|
|
if ((i>=int(_images.size()) || !_images[i]) && _filesRequested.count(_fileNames[i])==0)
|
2008-10-07 01:02:20 +08:00
|
|
|
{
|
2012-10-10 00:14:21 +08:00
|
|
|
//_filesRequested.insert(_fileNames[i]);
|
2008-10-07 01:02:20 +08:00
|
|
|
irh->requestImageFile(_fileNames[i], this, i, requestTime, fs);
|
|
|
|
}
|
|
|
|
requestTime += _timePerImage;
|
|
|
|
}
|
2008-07-23 04:20:16 +08:00
|
|
|
}
|
2008-10-07 01:02:20 +08:00
|
|
|
else
|
2008-07-23 00:44:49 +08:00
|
|
|
{
|
2008-10-07 01:02:20 +08:00
|
|
|
for(int i=startLoadIndex; i<=endLoadIndex; ++i)
|
|
|
|
{
|
2008-10-27 21:09:43 +08:00
|
|
|
if ((i>=int(_images.size()) || !_images[i]) && _filesRequested.count(_fileNames[i])==0)
|
2008-10-07 01:02:20 +08:00
|
|
|
{
|
2012-10-10 00:14:21 +08:00
|
|
|
//_filesRequested.insert(_fileNames[i]);
|
2008-10-07 01:02:20 +08:00
|
|
|
irh->requestImageFile(_fileNames[i], this, i, requestTime, fs);
|
|
|
|
}
|
|
|
|
requestTime += _timePerImage;
|
|
|
|
}
|
2008-07-23 00:44:49 +08:00
|
|
|
}
|
2008-10-07 01:02:20 +08:00
|
|
|
|
|
|
|
|
2008-07-22 01:28:22 +08:00
|
|
|
}
|
2008-10-07 01:02:20 +08:00
|
|
|
|
2008-07-21 17:46:53 +08:00
|
|
|
}
|