Changeset 13191
- Timestamp:
- 06/19/13 19:28:28 (9 hours ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 12 modified
-
examples/osgimagesequence/osgimagesequence.cpp (modified) (1 diff)
-
include/osg/ImageSequence (modified) (7 diffs)
-
include/osg/NodeVisitor (modified) (1 diff)
-
include/osg/PagedLOD (modified) (1 diff)
-
include/osgDB/ImagePager (modified) (3 diffs)
-
src/osg/ImageSequence.cpp (modified) (18 diffs)
-
src/osgDB/ImagePager.cpp (modified) (7 diffs)
-
src/osgDB/Registry.cpp (modified) (3 diffs)
-
src/osgPlugins/ive/ImageSequence.cpp (modified) (1 diff)
-
src/osgPresentation/SlideShowConstructor.cpp (modified) (2 diffs)
-
src/osgWrappers/deprecated-dotosg/osg/ImageSequence.cpp (modified) (1 diff)
-
src/osgWrappers/serializers/osg/ImageSequence.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgimagesequence/osgimagesequence.cpp
r13158 r13191 131 131 else 132 132 { 133 unsigned int maxNum = osg::maximum(imageSequence->getFileNames().size(), 134 imageSequence->getImages().size()); 135 133 unsigned int maxNum = imageSequence->getNumImageData(); 136 134 imageSequence->setLength(double(maxNum)*(1.0/fps)); 137 135 } -
OpenSceneGraph/trunk/include/osg/ImageSequence
r13041 r13191 49 49 virtual double getTimeMultiplier() const { return _timeMultiplier; } 50 50 51 typedef std::vector< osg::ref_ptr<osg::Image> > Images; 52 typedef std::vector< std::string > FileNames; 51 struct OSG_EXPORT ImageData 52 { 53 ImageData(); 54 ImageData(const ImageData& id); 55 ImageData& operator = (const ImageData& id); 56 57 std::string _filename; 58 osg::ref_ptr<osg::Image> _image; 59 osg::ref_ptr<osg::Referenced> _imageRequest; 60 }; 61 62 typedef std::vector<ImageData> ImageDataList; 53 63 54 64 virtual void seek(double time); … … 79 89 std::string getImageFile(unsigned int pos) const; 80 90 81 unsigned int getNumImageFiles() const { return _fileNames.size(); }82 83 FileNames& getFileNames() { return _fileNames; }84 const FileNames& getFileNames() const { return _fileNames; }85 86 91 void addImage(osg::Image* image); 87 92 … … 97 102 const Image* getImage(unsigned int pos) const; 98 103 99 unsigned int getNumImage s() const { return _images.size(); }104 unsigned int getNumImageData() const { return _imageDataList.size(); } 100 105 101 Image s& getImages() { return _images; }102 const Image s& getImages() const { return _images; }106 ImageDataList& getImageDataList() { return _imageDataList; } 107 const ImageDataList& getImageDataList() const { return _imageDataList; } 103 108 109 104 110 /** ImageSequence requires a call to update(NodeVisitor*) during the update traversal so return true.*/ 105 111 virtual bool requiresUpdateCall() const { return true; } … … 108 114 virtual void update(NodeVisitor* nv); 109 115 110 protected: 116 117 /** Set the optional osgDB::Options object to use when reading images.*/ 118 void setReadOptions(osg::Referenced* options) { _readOptions = options; } 119 120 /** Get the optional osgDB::Options object used when reading images.*/ 121 osg::Referenced* getReadOptions() { return _readOptions.get(); } 122 123 /** Get the optional osgDB::Options object used when reading images.*/ 124 const osg::Referenced* getReadOptions() const { return _readOptions.get(); } 125 126 protected: 111 127 112 128 virtual ~ImageSequence() {} … … 114 130 virtual void applyLoopingMode(); 115 131 116 void setImageToChild( const osg::Image* image);132 void setImageToChild(int pos); 117 133 118 134 void computeTimePerImage(); … … 130 146 131 147 mutable OpenThreads::Mutex _mutex; 132 FileNames _fileNames;133 148 134 Images _images; 135 136 typedef std::set< std::string > FilesRequested; 137 FilesRequested _filesRequested; 149 ImageDataList _imageDataList; 138 150 139 151 int _previousAppliedImageIndex; … … 143 155 double _seekTime; 144 156 145 157 osg::ref_ptr<osg::Referenced> _readOptions; 146 158 147 159 }; -
OpenSceneGraph/trunk/include/osg/NodeVisitor
r13041 r13191 309 309 virtual osg::Image* readImageFile(const std::string& fileName) = 0; 310 310 311 virtual void requestImageFile(const std::string& fileName,osg::Object* attachmentPoint, int attachmentIndex, double timeToMergeBy, const FrameStamp* framestamp ) = 0;311 virtual void requestImageFile(const std::string& fileName,osg::Object* attachmentPoint, int attachmentIndex, double timeToMergeBy, const FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& imageRequest, const osg::Referenced* options=0) = 0; 312 312 313 313 protected: -
OpenSceneGraph/trunk/include/osg/PagedLOD
r13041 r13191 45 45 46 46 47 /** Set the optional database osgDB::Options object to use when loadedchildren.*/47 /** Set the optional database osgDB::Options object to use when reading children.*/ 48 48 void setDatabaseOptions(osg::Referenced* options) { _databaseOptions = options; } 49 49 50 /** Get the optional database osgDB::Options object used when loadedchildren.*/50 /** Get the optional database osgDB::Options object used when reading children.*/ 51 51 osg::Referenced* getDatabaseOptions() { return _databaseOptions.get(); } 52 52 53 /** Get the optional database osgDB::Options object used when loadedchildren.*/53 /** Get the optional database osgDB::Options object used when reading children.*/ 54 54 const osg::Referenced* getDatabaseOptions() const { return _databaseOptions.get(); } 55 55 -
OpenSceneGraph/trunk/include/osgDB/ImagePager
r13144 r13191 61 61 virtual ~ImageThread(); 62 62 63 bool _done;64 Mode _mode;65 ImagePager* _pager;66 std::string _name;63 bool _done; 64 Mode _mode; 65 ImagePager* _pager; 66 std::string _name; 67 67 }; 68 68 … … 80 80 virtual osg::Image* readImageFile(const std::string& fileName); 81 81 82 virtual void requestImageFile(const std::string& fileName,osg::Object* attachmentPoint, int attachmentIndex, double timeToMergeBy, const osg::FrameStamp* framestamp); 83 82 virtual void requestImageFile(const std::string& fileName, osg::Object* attachmentPoint, int attachmentIndex, double timeToMergeBy, const osg::FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& imageRequest, const osg::Referenced* options); 84 83 85 84 /** Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double). */ … … 114 113 osg::ref_ptr<osg::Image> _loadedImage; 115 114 RequestQueue* _requestQueue; 115 osg::ref_ptr<osgDB::Options> _readOptions; 116 116 117 117 }; -
OpenSceneGraph/trunk/src/osg/ImageSequence.cpp
r13186 r13191 23 23 using namespace osg; 24 24 25 ImageSequence::ImageData::ImageData() 26 { 27 } 28 29 ImageSequence::ImageData::ImageData(const ImageData& id): 30 _filename(id._filename), 31 _image(id._image), 32 _imageRequest(id._imageRequest) 33 { 34 } 35 36 ImageSequence::ImageData& ImageSequence::ImageData::operator = (const ImageSequence::ImageData& rhs) 37 { 38 if (&rhs!=this) 39 { 40 _filename = rhs._filename; 41 _image = rhs._image; 42 _imageRequest = rhs._imageRequest; 43 } 44 return *this; 45 } 46 25 47 ImageSequence::ImageSequence() 26 48 { … … 97 119 void ImageSequence::computeTimePerImage() 98 120 { 99 if (!_fileNames.empty()) _timePerImage = _length / double(_fileNames.size()); 100 else if (!_images.empty()) _timePerImage = _length / double(_images.size()); 121 if (!_imageDataList.empty()) _timePerImage = _length / double(_imageDataList.size()); 101 122 else _timePerImage = _length; 102 123 } … … 106 127 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 107 128 108 if (pos>=_ fileNames.size()) _fileNames.resize(pos);109 _ fileNames[pos]= fileName;129 if (pos>=_imageDataList.size()) _imageDataList.resize(pos); 130 _imageDataList[pos]._filename = fileName; 110 131 } 111 132 … … 113 134 { 114 135 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 115 return pos<_ fileNames.size() ? _fileNames[pos]: std::string();136 return pos<_imageDataList.size() ? _imageDataList[pos]._filename : std::string(); 116 137 } 117 138 … … 119 140 { 120 141 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 121 _fileNames.push_back(fileName); 142 _imageDataList.push_back(ImageData()); 143 _imageDataList.back()._filename = fileName; 122 144 computeTimePerImage(); 123 145 } … … 127 149 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 128 150 129 OSG_INFO<<"ImageSequence::setImage("<<pos<<","<<image->getFileName()<<")"<<std::endl; 130 131 if (pos>=_images.size()) _images.resize(pos+1); 132 133 _images[pos] = image; 134 135 // prune from file requested list. 136 FilesRequested::iterator itr = _filesRequested.find(image->getFileName()); 137 if (itr!=_filesRequested.end()) _filesRequested.erase(itr); 151 if (pos>=_imageDataList.size()) _imageDataList.resize(pos+1); 152 153 _imageDataList[pos]._image = image; 154 _imageDataList[pos]._filename = image->getFileName(); 138 155 } 139 156 … … 141 158 { 142 159 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 143 return pos<_image s.size() ? _images[pos].get() : 0;160 return pos<_imageDataList.size() ? _imageDataList[pos]._image.get() : 0; 144 161 } 145 162 … … 147 164 { 148 165 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 149 return pos<_image s.size() ? _images[pos].get() : 0;166 return pos<_imageDataList.size() ? _imageDataList[pos]._image.get() : 0; 150 167 } 151 168 … … 157 174 158 175 // OSG_NOTICE<<"merging image in order expected : "<<image->getFileName()<<std::endl; 159 _images.push_back(image); 176 _imageDataList.push_back(ImageData()); 177 _imageDataList.back()._image = image; 160 178 161 179 computeTimePerImage(); … … 163 181 if (data()==0) 164 182 { 165 setImageToChild(_image s.front().get());166 } 167 } 168 169 void ImageSequence::setImageToChild( const osg::Image* image)170 { 171 // OSG_NOTICE<<"setImageToChild("<<image<<")"<<std::endl;172 183 setImageToChild(_imageDataList.size()-1); 184 } 185 } 186 187 void ImageSequence::setImageToChild(int pos) 188 { 189 190 const osg::Image* image = (pos>=0 && pos<static_cast<int>(_imageDataList.size())) ? _imageDataList[pos]._image.get() : 0; 173 191 if (image==0) return; 174 192 175 193 // check to see if data is changing, if not don't apply 176 if (image->data() == data()) return; 194 if (image->data() == data()) 195 { 196 return; 197 } 198 199 200 if (_mode==PAGE_AND_DISCARD_USED_IMAGES && _previousAppliedImageIndex>=0) 201 { 202 if (_previousAppliedImageIndex<pos) 203 { 204 OSG_INFO<<"Moving forward from "<<_previousAppliedImageIndex<<" to "<<pos<<std::endl; 205 while(_previousAppliedImageIndex<pos) 206 { 207 _imageDataList[_previousAppliedImageIndex]._image = 0; 208 OSG_INFO<<" deleting "<<_previousAppliedImageIndex<<std::endl; 209 ++_previousAppliedImageIndex; 210 } 211 } 212 else if (_previousAppliedImageIndex>pos) 213 { 214 OSG_INFO<<"Moving back from "<<_previousAppliedImageIndex<<" to "<<pos<<std::endl; 215 while(_previousAppliedImageIndex>pos) 216 { 217 _imageDataList[_previousAppliedImageIndex]._image = 0; 218 OSG_INFO<<" deleting "<<_previousAppliedImageIndex<<std::endl; 219 --_previousAppliedImageIndex; 220 } 221 } 222 } 223 224 225 _previousAppliedImageIndex = pos; 177 226 178 227 setImage(image->s(),image->t(),image->r(), … … 198 247 if (time<0.0) return 0; 199 248 int index = int(time/_timePerImage); 200 if (index>=int(_image s.size())) return int(_images.size())-1;249 if (index>=int(_imageDataList.size())) return int(_imageDataList.size())-1; 201 250 return index; 202 251 } … … 223 272 { 224 273 time = _seekTime; 274 useDirectTimeRequest = true; 225 275 _referenceTime = fs->getSimulationTime() - time/_timeMultiplier; 226 276 } … … 248 298 _seekTimeSet = false; 249 299 250 bool pruneOldImages = false; 251 252 switch(_mode) 253 { 254 case(PRE_LOAD_ALL_IMAGES): 255 { 256 if (irh && _fileNames.size()>_images.size()) 257 { 258 FileNames::iterator itr = _fileNames.begin(); 259 for(unsigned int i=0;i<_images.size();++i) ++itr; 260 261 for(; itr!=_fileNames.end(); ++itr) 262 { 263 osg::Image* image = irh->readImageFile(*itr); 264 _images.push_back(image); 265 } 266 } 267 268 irh = 0; 269 break; 270 } 271 case(PAGE_AND_RETAIN_IMAGES): 272 { 273 break; 274 } 275 case(PAGE_AND_DISCARD_USED_IMAGES): 276 { 277 pruneOldImages = true; 278 break; 300 if (irh && _mode==PRE_LOAD_ALL_IMAGES) 301 { 302 for(ImageDataList::iterator itr = _imageDataList.begin(); 303 itr != _imageDataList.end(); 304 ++itr) 305 { 306 if (!(itr->_image) && !(itr->_filename.empty())) 307 { 308 itr->_image = irh->readImageFile(itr->_filename); 309 } 279 310 } 280 311 } … … 283 314 // OSG_NOTICE<<"time= "<<time<<" _timePerImage="<<_timePerImage<<" index="<<index<<" _length="<<_length<<std::endl; 284 315 285 if (index>=int(_images.size())) index = int(_images.size())-1; 286 287 if (index>=0 && index<int(_images.size())) 288 { 289 if (pruneOldImages) 290 { 316 if (index>=int(_imageDataList.size())) index = int(_imageDataList.size())-1; 317 318 if (index>=0 && index<int(_imageDataList.size())) 319 { 320 // need to find the nearest relevant change. 321 if (!_imageDataList[index]._image) 322 { 291 323 if (_previousAppliedImageIndex<index) 292 324 { 293 325 OSG_DEBUG<<"ImageSequence::update(..) Moving forward by "<<index-_previousAppliedImageIndex<<std::endl; 294 while (index>=0 && !_image s[index].valid())326 while (index>=0 && !_imageDataList[index]._image.valid()) 295 327 { 296 328 --index; … … 300 332 { 301 333 OSG_DEBUG<<"ImageSequence::update(..) Moving back by "<<_previousAppliedImageIndex-index<<std::endl; 302 while (index<static_cast<int>(_image s.size()) && !_images[index].valid())334 while (index<static_cast<int>(_imageDataList.size()) && !_imageDataList[index]._image.valid()) 303 335 { 304 336 ++index; 305 337 } 306 338 } 339 } 340 341 if (index>=0 && index!=_previousAppliedImageIndex) 342 { 343 setImageToChild(index); 344 } 345 } 346 347 // OSG_NOTICE<<"time = "<<time<<std::endl; 348 349 if (!irh) return; 350 351 if (useDirectTimeRequest) 352 { 353 int i = int(time/_timePerImage); 354 if ((i>=int(_imageDataList.size()) || !_imageDataList[i]._image)) 355 { 356 i = osg::clampTo<int>(i, 0, _imageDataList.size()-1); 357 358 OSG_INFO<<"Requesting file, entry="<<i<<" : _fileNames[i]="<<_imageDataList[i]._filename<<std::endl; 359 irh->requestImageFile(_imageDataList[i]._filename, this, i, time, fs, _imageDataList[i]._imageRequest, _readOptions.get()); 360 } 361 } 362 else 363 { 364 double preLoadTime = time + osg::minimum(irh->getPreLoadTime()*_timeMultiplier, _length); 365 366 int startLoadIndex = int(time/_timePerImage); 367 if (startLoadIndex>=int(_imageDataList.size())) startLoadIndex = int(_imageDataList.size())-1; 368 if (startLoadIndex<0) startLoadIndex = 0; 369 370 int endLoadIndex = int(preLoadTime/_timePerImage); 371 if (endLoadIndex>=int(_imageDataList.size())) 372 { 373 if (looping) 374 { 375 endLoadIndex -= int(_imageDataList.size()); 376 } 307 377 else 308 378 { 309 // OSG_NOTICE<<"ImageSequence::update(..) Same index."<<std::endl; 310 } 311 } 312 313 if (index>=0) 314 { 315 // OSG_NOTICE<<"at time "<<time<<" setting child = "<<index<<std::endl; 316 317 if (_previousAppliedImageIndex!=index) 318 { 319 if (_previousAppliedImageIndex >= 0 && 320 _previousAppliedImageIndex<int(_images.size()) && 321 pruneOldImages) 379 endLoadIndex = int(_imageDataList.size())-1; 380 } 381 } 382 if (endLoadIndex<0) endLoadIndex = 0; 383 384 double requestTime = time; 385 386 if (endLoadIndex<startLoadIndex) 387 { 388 for(int i=startLoadIndex; i<int(_imageDataList.size()); ++i) 389 { 390 if (!_imageDataList[i]._image) 322 391 { 323 _images[_previousAppliedImageIndex] = 0; 324 } 325 326 setImageToChild(_images[index].get()); 327 328 _previousAppliedImageIndex = index; 329 } 330 } 331 } 332 333 // OSG_NOTICE<<"time = "<<time<<std::endl; 334 335 if (!irh) return; 336 337 if (useDirectTimeRequest) 338 { 339 int i = int(time/_timePerImage); 340 if ((i>=int(_images.size()) || !_images[i])) 341 { 342 i = osg::clampTo<int>(i, 0, _fileNames.size()-1); 343 if (_filesRequested.count(_fileNames[i])==0) 344 { 345 OSG_INFO<<"Requesting file, entry="<<i<<" : _fileNames[i]="<<_fileNames[i]<<std::endl; 346 //_filesRequested.insert(_fileNames[i]); 347 irh->requestImageFile(_fileNames[i], this, i, time, fs); 348 } 349 else 350 { 351 OSG_DEBUG<<"File already requested, entry="<<i<<" : _fileNames[i]="<<_fileNames[i]<<std::endl; 352 } 353 } 354 } 355 else 356 { 357 double preLoadTime = time + osg::minimum(irh->getPreLoadTime()*_timeMultiplier, _length); 358 359 int startLoadIndex = int(time/_timePerImage); 360 if (startLoadIndex>=int(_images.size())) startLoadIndex = int(_images.size())-1; 361 if (startLoadIndex<0) startLoadIndex = 0; 362 363 int endLoadIndex = int(preLoadTime/_timePerImage); 364 if (endLoadIndex>=int(_fileNames.size())) 365 { 366 if (looping) 367 { 368 endLoadIndex -= int(_fileNames.size()); 369 } 370 else 371 { 372 endLoadIndex = int(_fileNames.size())-1; 373 } 374 } 375 if (endLoadIndex<0) endLoadIndex = 0; 376 377 double requestTime = time; 378 379 if (endLoadIndex<startLoadIndex) 380 { 381 for(int i=startLoadIndex; i<int(_fileNames.size()); ++i) 382 { 383 if ((i>=int(_images.size()) || !_images[i]) && _filesRequested.count(_fileNames[i])==0) 384 { 385 //_filesRequested.insert(_fileNames[i]); 386 irh->requestImageFile(_fileNames[i], this, i, requestTime, fs); 392 irh->requestImageFile(_imageDataList[i]._filename, this, i, requestTime, fs, _imageDataList[i]._imageRequest, _readOptions.get()); 387 393 } 388 394 requestTime += _timePerImage; … … 391 397 for(int i=0; i<=endLoadIndex; ++i) 392 398 { 393 if ( (i>=int(_images.size()) || !_images[i]) && _filesRequested.count(_fileNames[i])==0)399 if (!_imageDataList[i]._image) 394 400 { 395 //_filesRequested.insert(_fileNames[i]); 396 irh->requestImageFile(_fileNames[i], this, i, requestTime, fs); 401 irh->requestImageFile(_imageDataList[i]._filename, this, i, requestTime, fs, _imageDataList[i]._imageRequest, _readOptions.get()); 397 402 } 398 403 requestTime += _timePerImage; … … 403 408 for(int i=startLoadIndex; i<=endLoadIndex; ++i) 404 409 { 405 if ( (i>=int(_images.size()) || !_images[i]) && _filesRequested.count(_fileNames[i])==0)410 if (!_imageDataList[i]._image) 406 411 { 407 //_filesRequested.insert(_fileNames[i]); 408 irh->requestImageFile(_fileNames[i], this, i, requestTime, fs); 412 irh->requestImageFile(_imageDataList[i]._filename, this, i, requestTime, fs, _imageDataList[i]._imageRequest, _readOptions.get()); 409 413 } 410 414 requestTime += _timePerImage; … … 412 416 } 413 417 414 415 } 416 417 } 418 } 419 420 } -
OpenSceneGraph/trunk/src/osgDB/ImagePager.cpp
r13159 r13191 84 84 // note this will mean that only one ImageSequence can be properly managed at one time, 85 85 // this hack will be removed once a better system for managing expiry of requests is introduced. 86 clear();86 // clear(); 87 87 88 88 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_requestMutex); … … 91 91 databaseRequest->_requestQueue = this; 92 92 93 OSG_INFO<<"ImagePager::ReadQueue::add( ..), size()="<<_requestList.size()<<std::endl;93 OSG_INFO<<"ImagePager::ReadQueue::add("<<databaseRequest->_fileName<<"), size()="<<_requestList.size()<<std::endl; 94 94 95 95 updateBlock(); … … 207 207 if (imageRequest.valid()) 208 208 { 209 osg::ref_ptr<osg::Image> image = osgDB::readImageFile(imageRequest->_fileName); 209 // OSG_NOTICE<<"doing readImageFile("<<imageRequest->_fileName<<") index to assign = "<<imageRequest->_attachmentIndex<<std::endl; 210 osg::ref_ptr<osg::Image> image = osgDB::readImageFile(imageRequest->_fileName, imageRequest->_readOptions.get()); 210 211 if (image.valid()) 211 212 { 213 // OSG_NOTICE<<" successful readImageFile("<<imageRequest->_fileName<<") index to assign = "<<imageRequest->_attachmentIndex<<std::endl; 214 212 215 osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(imageRequest->_attachmentPoint.get()); 213 216 if (is) … … 267 270 _completedQueue = new RequestQueue; 268 271 _imageThreads.push_back(new ImageThread(this, ImageThread::HANDLE_ALL_REQUESTS, "Image Thread 1")); 272 #if 1 269 273 _imageThreads.push_back(new ImageThread(this, ImageThread::HANDLE_ALL_REQUESTS, "Image Thread 2")); 270 274 _imageThreads.push_back(new ImageThread(this, ImageThread::HANDLE_ALL_REQUESTS, "Image Thread 3")); … … 272 276 _imageThreads.push_back(new ImageThread(this, ImageThread::HANDLE_ALL_REQUESTS, "Image Thread 5")); 273 277 _imageThreads.push_back(new ImageThread(this, ImageThread::HANDLE_ALL_REQUESTS, "Image Thread 6")); 274 278 #endif 275 279 // 1 second 276 280 _preLoadTime = 1.0; … … 315 319 } 316 320 317 void ImagePager::requestImageFile(const std::string& fileName,osg::Object* attachmentPoint, int attachmentIndex, double timeToMergeBy, const osg::FrameStamp*) 318 { 319 OSG_INFO<<"ImagePager::requestNodeFile("<<fileName<<")"<<std::endl; 321 void ImagePager::requestImageFile(const std::string& fileName, osg::Object* attachmentPoint, int attachmentIndex, double timeToMergeBy, const osg::FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& imageRequest, const osg::Referenced* options) 322 { 323 324 osgDB::Options* readOptions = dynamic_cast<osgDB::Options*>(const_cast<osg::Referenced*>(options)); 325 if (!readOptions) 326 { 327 readOptions = Registry::instance()->getOptions(); 328 } 329 330 bool alreadyAssigned = dynamic_cast<ImageRequest*>(imageRequest.get()) && (imageRequest->referenceCount()>1); 331 if (alreadyAssigned) 332 { 333 // OSG_NOTICE<<"ImagePager::requestImageFile("<<fileName<<") alreadyAssigned"<<std::endl; 334 return; 335 } 320 336 321 337 osg::ref_ptr<ImageRequest> request = new ImageRequest; … … 325 341 request->_attachmentIndex = attachmentIndex; 326 342 request->_requestQueue = _readQueue.get(); 343 request->_readOptions = readOptions; 344 345 imageRequest = request; 346 347 // OSG_NOTICE<<"ImagePager::requestImageFile("<<fileName<<") new request."<<std::endl; 327 348 328 349 _readQueue->add(request.get()); -
OpenSceneGraph/trunk/src/osgDB/Registry.cpp
r13156 r13191 1300 1300 useObjectCache=options ? (options->getObjectCacheHint()&cacheHint)!=0: false; 1301 1301 } 1302 1302 1303 if (useObjectCache) 1303 1304 { … … 1308 1309 if (oitr!=_objectCache.end()) 1309 1310 { 1310 OSG_ NOTIFY(INFO)<<"returning cached instanced of "<<file<<std::endl;1311 OSG_INFO<<"returning cached instanced of "<<file<<std::endl; 1311 1312 if (readFunctor.isValid(oitr->second.first.get())) return ReaderWriter::ReadResult(oitr->second.first.get(), ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE); 1312 1313 else return ReaderWriter::ReadResult("Error file does not contain an osg::Object"); … … 1318 1319 { 1319 1320 // update cache with new entry. 1320 OSG_ NOTIFY(INFO)<<"Adding to object cache "<<file<<std::endl;1321 OSG_INFO<<"Adding to object cache "<<file<<std::endl; 1321 1322 addEntryToObjectCache(file,rr.getObject()); 1322 1323 } 1323 1324 else 1324 1325 { 1325 OSG_ NOTIFY(INFO)<<"No valid object found for "<<file<<std::endl;1326 OSG_INFO<<"No valid object found for "<<file<<std::endl; 1326 1327 } 1327 1328 -
OpenSceneGraph/trunk/src/osgPlugins/ive/ImageSequence.cpp
r13041 r13191 38 38 out->writeDouble(getLength()); 39 39 40 out->writeUInt(get FileNames().size());41 for( FileNames::iterator itr = getFileNames().begin();42 itr != get FileNames().end();40 out->writeUInt(getImageDataList().size()); 41 for(ImageDataList::iterator itr = getImageDataList().begin(); 42 itr != getImageDataList().end(); 43 43 ++itr) 44 44 { 45 out->writeString( *itr);45 out->writeString(itr->_filename); 46 46 } 47 47 48 if (get FileNames().empty())48 if (getImageDataList().empty()) 49 49 { 50 out->writeUInt(getImages().size()); 51 for(Images::iterator itr = getImages().begin(); 52 itr != getImages().end(); 53 ++itr) 54 { 55 out->writeImage(itr->get()); 56 } 50 out->writeUInt(0); 57 51 } 58 52 -
OpenSceneGraph/trunk/src/osgPresentation/SlideShowConstructor.cpp
r13179 r13191 1000 1000 } 1001 1001 1002 #if 0 1003 if (imageSequence->getMode()==osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES) 1004 { 1005 1006 if (_options.valid()) 1007 { 1008 OSG_NOTICE<<"Object cache usage _options "<<options->getObjectCacheHint()<<std::endl; 1009 } 1010 else 1011 { 1012 OSG_NOTICE<<"No Object _options assigned"<<std::endl; 1013 } 1014 1015 1016 osg::ref_ptr<osgDB::Options> options = _options.valid() ? _options->cloneOptions() : (new osgDB::Options); 1017 if (!imageData.options.empty()) 1018 { 1019 options->setOptionString(imageData.options); 1020 } 1021 OSG_NOTICE<<"Disabling object cache usage"<<std::endl; 1022 options->setObjectCacheHint(osgDB::Options::CACHE_NONE); 1023 imageSequence->setReadOptions(options); 1024 } 1025 #endif 1002 1026 if (imageData.duration>0.0) 1003 1027 { … … 1006 1030 else 1007 1031 { 1008 unsigned int maxNum = osg::maximum(imageSequence->getFileNames().size(), 1009 imageSequence->getImages().size()); 1010 1032 unsigned int maxNum = imageSequence->getNumImageData(); 1011 1033 imageSequence->setLength(double(maxNum)*(1.0/imageData.fps)); 1012 1034 } -
OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/ImageSequence.cpp
r13041 r13191 108 108 fw.indent()<<"Length "<<is.getLength()<<std::endl; 109 109 110 if ( !is.getFileNames().empty())110 if (is.getNumImageData()>0) 111 111 { 112 112 fw.indent()<<"FileNames {"<<std::endl; 113 113 fw.moveIn(); 114 114 115 const osg::ImageSequence:: FileNames& names = is.getFileNames();116 for(osg::ImageSequence:: FileNames::const_iterator itr = names.begin();117 itr != names.end();115 const osg::ImageSequence::ImageDataList& id = is.getImageDataList(); 116 for(osg::ImageSequence::ImageDataList::const_iterator itr = id.begin(); 117 itr != id.end(); 118 118 ++itr) 119 119 { 120 fw.indent()<<fw.wrapString(*itr)<<std::endl; 121 } 122 123 fw.moveOut(); 124 fw.indent()<<"}"<<std::endl; 125 } 126 else 127 { 128 fw.indent()<<"Images {"<<std::endl; 129 fw.moveIn(); 130 131 const osg::ImageSequence::Images& images = is.getImages(); 132 for(osg::ImageSequence::Images::const_iterator itr = images.begin(); 133 itr != images.end(); 134 ++itr) 135 { 136 if (!(*itr)->getFileName().empty()) fw.indent()<<fw.wrapString((*itr)->getFileName())<<std::endl; 120 fw.indent()<<fw.wrapString(itr->_filename)<<std::endl; 137 121 } 138 122 -
OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/ImageSequence.cpp
r13058 r13191 7 7 static bool checkFileNames( const osg::ImageSequence& image ) 8 8 { 9 return image.getNumImage Files()>0;9 return image.getNumImageData()>0; 10 10 } 11 11 … … 24 24 static bool writeFileNames( osgDB::OutputStream& os, const osg::ImageSequence& image ) 25 25 { 26 const osg::ImageSequence::FileNames& files = image.getFileNames(); 27 os.writeSize(files.size()); os << os.BEGIN_BRACKET << std::endl; 28 for ( osg::ImageSequence::FileNames::const_iterator itr=files.begin(); 29 itr!=files.end(); ++itr ) 26 const osg::ImageSequence::ImageDataList& imageDataList = image.getImageDataList(); 27 os.writeSize(imageDataList.size()); os << os.BEGIN_BRACKET << std::endl; 28 for ( osg::ImageSequence::ImageDataList::const_iterator itr=imageDataList.begin(); 29 itr!=imageDataList.end(); 30 ++itr ) 30 31 { 31 os.writeWrappedString( *itr);32 os.writeWrappedString( itr->_filename ); 32 33 os << std::endl; 33 34 } … … 39 40 static bool checkImages( const osg::ImageSequence& image ) 40 41 { 41 return image.getNumImages()>0;42 return false; 42 43 } 43 44 … … 54 55 } 55 56 56 static bool writeImages( osgDB::OutputStream& os, const osg::ImageSequence& image )57 static bool writeImages( osgDB::OutputStream& os, const osg::ImageSequence& image) 57 58 { 58 const osg::ImageSequence::Images& images = image.getImages(); 59 os.writeSize(images.size()); os << os.BEGIN_BRACKET << std::endl; 60 for ( osg::ImageSequence::Images::const_iterator itr=images.begin(); 61 itr!=images.end(); ++itr ) 59 const osg::ImageSequence::ImageDataList& imageDataList = image.getImageDataList(); 60 os.writeSize(imageDataList.size()); os << os.BEGIN_BRACKET << std::endl; 61 for ( osg::ImageSequence::ImageDataList::const_iterator itr=imageDataList.begin(); 62 itr!=imageDataList.end(); 63 ++itr ) 62 64 { 63 os.writeObject( (*itr). get() );65 os.writeObject( (*itr)._image.get() ); 64 66 } 65 67 os << os.END_BRACKET << std::endl;
