Changeset 13041 for OpenSceneGraph/trunk/src/osg/ImageSequence.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/ImageSequence.cpp (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/ImageSequence.cpp
r12292 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 31 31 _length = 1.0; 32 32 _timePerImage = 1.0; 33 33 34 34 _seekTime = 0.0; 35 35 _seekTimeSet = false; 36 36 37 37 _previousAppliedImageIndex = -1; 38 38 } … … 90 90 return; 91 91 } 92 92 93 93 _length = length; 94 94 computeTimePerImage(); … … 115 115 return pos<_fileNames.size() ? _fileNames[pos] : std::string(); 116 116 } 117 117 118 118 void ImageSequence::addImageFile(const std::string& fileName) 119 119 { … … 130 130 131 131 if (pos>=_images.size()) _images.resize(pos+1); 132 132 133 133 _images[pos] = image; 134 134 … … 160 160 161 161 computeTimePerImage(); 162 162 163 163 if (data()==0) 164 164 { … … 190 190 int ImageSequence::imageIndex(double time) 191 191 { 192 if (getLoopingMode()==LOOPING) 192 if (getLoopingMode()==LOOPING) 193 193 { 194 194 double positionRatio = time/_length; … … 205 205 { 206 206 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); 207 207 208 208 osg::NodeVisitor::ImageRequestHandler* irh = nv->getImageRequestHandler(); 209 209 const osg::FrameStamp* fs = nv->getFrameStamp(); … … 215 215 _referenceTime = fs->getSimulationTime(); 216 216 } 217 217 218 218 bool looping = getLoopingMode()==LOOPING; 219 219 double time = (fs->getSimulationTime() - _referenceTime)*_timeMultiplier; 220 220 221 221 if (_seekTimeSet || _status==PAUSED || _status==INVALID) 222 222 { 223 time = _seekTime; 223 time = _seekTime; 224 224 _referenceTime = fs->getSimulationTime() - time/_timeMultiplier; 225 225 } … … 243 243 } 244 244 } 245 245 246 246 _seekTime = time; 247 247 _seekTimeSet = false; 248 248 249 249 bool pruneOldImages = false; 250 251 250 251 252 252 switch(_mode) 253 253 { … … 265 265 } 266 266 } 267 267 268 268 irh = 0; 269 269 break; … … 295 295 } 296 296 } 297 297 298 298 if (index>=0) 299 299 { … … 302 302 if (_previousAppliedImageIndex!=index) 303 303 { 304 if (_previousAppliedImageIndex >= 0 && 305 _previousAppliedImageIndex<int(_images.size()) && 304 if (_previousAppliedImageIndex >= 0 && 305 _previousAppliedImageIndex<int(_images.size()) && 306 306 pruneOldImages) 307 307 { 308 308 _images[_previousAppliedImageIndex] = 0; 309 309 } 310 310 311 311 setImageToChild(_images[index].get()); 312 312 313 313 _previousAppliedImageIndex = index; 314 314 } … … 321 321 { 322 322 double preLoadTime = time + osg::minimum(irh->getPreLoadTime()*_timeMultiplier, _length); 323 323 324 324 int startLoadIndex = int(time/_timePerImage); 325 325 if (startLoadIndex>=int(_images.size())) startLoadIndex = int(_images.size())-1; … … 327 327 328 328 int endLoadIndex = int(preLoadTime/_timePerImage); 329 if (endLoadIndex>=int(_fileNames.size())) 329 if (endLoadIndex>=int(_fileNames.size())) 330 330 { 331 331 if (looping) … … 339 339 } 340 340 if (endLoadIndex<0) endLoadIndex = 0; 341 341 342 342 double requestTime = time; 343 343 344 344 if (endLoadIndex<startLoadIndex) 345 345 {
