ImageSequence
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* 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
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_IMAGESEQUENCE
#define OSG_IMAGESEQUENCE 1
#include <OpenThreads/Mutex>
#include <osg/ImageStream>
#include <list>
#include <set>
namespace osg {
class OSG_EXPORT ImageSequence : public ImageStream
{
public:
ImageSequence();
ImageSequence(const ImageSequence& ImageSequence, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual Object* cloneType() const { return new ImageSequence(); }
virtual Object* clone(const CopyOp& copyop) const { return new ImageSequence(*this,copyop); }
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImageSequence*>(obj)!=0; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "ImageSequence"; }
virtual int compare(const Image& rhs) const;
virtual void setReferenceTime(double t) { _referenceTime = t; }
virtual double getReferenceTime() const { return _referenceTime; }
virtual void setTimeMultiplier(double tm) { _timeMultiplier = tm; }
virtual double getTimeMultiplier() const { return _timeMultiplier; }
struct OSG_EXPORT ImageData
{
ImageData();
ImageData(const ImageData& id);
ImageData& operator = (const ImageData& id);
std::string _filename;
osg::ref_ptr<osg::Image> _image;
osg::ref_ptr<osg::Referenced> _imageRequest;
};
typedef std::vector<ImageData> ImageDataList;
virtual void seek(double time);
virtual void play();
virtual void pause();
virtual void rewind();
enum Mode
{
PRE_LOAD_ALL_IMAGES,
PAGE_AND_RETAIN_IMAGES,
PAGE_AND_DISCARD_USED_IMAGES,
LOAD_AND_RETAIN_IN_UPDATE_TRAVERSAL,
LOAD_AND_DISCARD_IN_UPDATE_TRAVERSAL
};
void setMode(Mode mode);
Mode getMode() const { return _mode; }
void setLength(double length);
virtual double getLength() const { return _length; }
void addImageFile(const std::string& fileName);
void setImageFile(unsigned int pos, const std::string& fileName);
std::string getImageFile(unsigned int pos) const;
void addImage(osg::Image* image);
template<class T> void addImage(const osg::ref_ptr<T>& image) { addImage(image.get()); }
void setImage(int s,int t,int r,
GLint internalTextureformat,
GLenum pixelFormat,GLenum type,
unsigned char* data,
AllocationMode mode,
int packing=1) { Image::setImage(s,t,r,internalTextureformat, pixelFormat, type, data, mode, packing); }
void setImage(unsigned int pos, osg::Image* image);
template<class T> void setImage(unsigned int pos, const osg::ref_ptr<T>& image) { setImage(pos, image.get()); }
Image* getImage(unsigned int pos);
const Image* getImage(unsigned int pos) const;
unsigned int getNumImageData() const { return _imageDataList.size(); }
ImageDataList& getImageDataList() { return _imageDataList; }
const ImageDataList& getImageDataList() const { return _imageDataList; }
virtual bool requiresUpdateCall() const { return true; }
virtual void update(NodeVisitor* nv);
void setReadOptions(osg::Referenced* options) { _readOptions = options; }
osg::Referenced* getReadOptions() { return _readOptions.get(); }
const osg::Referenced* getReadOptions() const { return _readOptions.get(); }
protected:
virtual ~ImageSequence() {}
virtual void applyLoopingMode();
void setImageToChild(int pos);
void computeTimePerImage();
int imageIndex(double time);
// setImage without acquiring mutex.
void _setImage(unsigned int pos, osg::Image* image);
double _referenceTime;
double _timeMultiplier;
Mode _mode;
double _length;
double _timePerImage;
mutable OpenThreads::Mutex _mutex;
ImageDataList _imageDataList;
int _previousAppliedImageIndex;
bool _seekTimeSet;
double _seekTime;
osg::ref_ptr<osg::Referenced> _readOptions;
};
} // namespace
#endif
ImageStream
Mutex
OpenThreads::Mutex
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::ImageSequence::_seekTimeSet
bool _seekTimeSet
Definition ImageSequence:163
osg::ImageSequence::setMode
void setMode(Mode mode)
osg::ImageSequence::update
virtual void update(NodeVisitor *nv)
osg::ImageSequence::addImage
void addImage(const osg::ref_ptr< T > &image)
Definition ImageSequence:95
osg::ImageSequence::getImage
Image * getImage(unsigned int pos)
osg::ImageSequence::setReadOptions
void setReadOptions(osg::Referenced *options)
Definition ImageSequence:125
osg::ImageSequence::setImage
void setImage(unsigned int pos, const osg::ref_ptr< T > &image)
Definition ImageSequence:106
osg::ImageSequence::setImage
void setImage(int s, int t, int r, GLint internalTextureformat, GLenum pixelFormat, GLenum type, unsigned char *data, AllocationMode mode, int packing=1)
Definition ImageSequence:97
osg::ImageSequence::_readOptions
osg::ref_ptr< osg::Referenced > _readOptions
Definition ImageSequence:166
osg::ImageSequence::Mode
Mode
Definition ImageSequence:73
osg::ImageSequence::LOAD_AND_DISCARD_IN_UPDATE_TRAVERSAL
@ LOAD_AND_DISCARD_IN_UPDATE_TRAVERSAL
Definition ImageSequence:78
osg::ImageSequence::PAGE_AND_RETAIN_IMAGES
@ PAGE_AND_RETAIN_IMAGES
Definition ImageSequence:75
osg::ImageSequence::LOAD_AND_RETAIN_IN_UPDATE_TRAVERSAL
@ LOAD_AND_RETAIN_IN_UPDATE_TRAVERSAL
Definition ImageSequence:77
osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES
@ PAGE_AND_DISCARD_USED_IMAGES
Definition ImageSequence:76
osg::ImageSequence::PRE_LOAD_ALL_IMAGES
@ PRE_LOAD_ALL_IMAGES
Definition ImageSequence:74
osg::ImageSequence::~ImageSequence
virtual ~ImageSequence()
Definition ImageSequence:135
osg::ImageSequence::getLength
virtual double getLength() const
Definition ImageSequence:85
osg::ImageSequence::getNumImageData
unsigned int getNumImageData() const
Definition ImageSequence:111
osg::ImageSequence::addImage
void addImage(osg::Image *image)
osg::ImageSequence::getImageDataList
const ImageDataList & getImageDataList() const
Definition ImageSequence:114
osg::ImageSequence::_mode
Mode _mode
Definition ImageSequence:151
osg::ImageSequence::getMode
Mode getMode() const
Definition ImageSequence:82
osg::ImageSequence::clone
virtual Object * clone(const CopyOp &copyop) const
Definition ImageSequence:37
osg::ImageSequence::setImageToChild
void setImageToChild(int pos)
osg::ImageSequence::setImageFile
void setImageFile(unsigned int pos, const std::string &fileName)
osg::ImageSequence::cloneType
virtual Object * cloneType() const
Definition ImageSequence:36
osg::ImageSequence::_length
double _length
Definition ImageSequence:152
osg::ImageSequence::ImageSequence
ImageSequence()
osg::ImageSequence::compare
virtual int compare(const Image &rhs) const
osg::ImageSequence::_previousAppliedImageIndex
int _previousAppliedImageIndex
Definition ImageSequence:160
osg::ImageSequence::rewind
virtual void rewind()
osg::ImageSequence::_seekTime
double _seekTime
Definition ImageSequence:164
osg::ImageSequence::computeTimePerImage
void computeTimePerImage()
osg::ImageSequence::setImage
void setImage(unsigned int pos, osg::Image *image)
osg::ImageSequence::ImageDataList
std::vector< ImageData > ImageDataList
Definition ImageSequence:62
osg::ImageSequence::getReferenceTime
virtual double getReferenceTime() const
Definition ImageSequence:46
osg::ImageSequence::className
virtual const char * className() const
Definition ImageSequence:40
osg::ImageSequence::getTimeMultiplier
virtual double getTimeMultiplier() const
Definition ImageSequence:49
osg::ImageSequence::_timeMultiplier
double _timeMultiplier
Definition ImageSequence:149
osg::ImageSequence::getImage
const Image * getImage(unsigned int pos) const
osg::ImageSequence::_referenceTime
double _referenceTime
Definition ImageSequence:148
osg::ImageSequence::getReadOptions
const osg::Referenced * getReadOptions() const
Definition ImageSequence:131
osg::ImageSequence::setReferenceTime
virtual void setReferenceTime(double t)
Definition ImageSequence:45
osg::ImageSequence::getImageDataList
ImageDataList & getImageDataList()
Definition ImageSequence:113
osg::ImageSequence::libraryName
virtual const char * libraryName() const
Definition ImageSequence:39
osg::ImageSequence::getImageFile
std::string getImageFile(unsigned int pos) const
osg::ImageSequence::setTimeMultiplier
virtual void setTimeMultiplier(double tm)
Definition ImageSequence:48
osg::ImageSequence::pause
virtual void pause()
osg::ImageSequence::addImageFile
void addImageFile(const std::string &fileName)
osg::ImageSequence::setLength
void setLength(double length)
osg::ImageSequence::seek
virtual void seek(double time)
osg::ImageSequence::getReadOptions
osg::Referenced * getReadOptions()
Definition ImageSequence:128
osg::ImageSequence::ImageSequence
ImageSequence(const ImageSequence &ImageSequence, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::ImageSequence::_timePerImage
double _timePerImage
Definition ImageSequence:154
osg::ImageSequence::requiresUpdateCall
virtual bool requiresUpdateCall() const
Definition ImageSequence:118
osg::ImageSequence::play
virtual void play()
osg::ImageSequence::isSameKindAs
virtual bool isSameKindAs(const Object *obj) const
Definition ImageSequence:38
osg::ImageSequence::applyLoopingMode
virtual void applyLoopingMode()
osg::ImageSequence::_setImage
void _setImage(unsigned int pos, osg::Image *image)
osg::ImageSequence::_imageDataList
ImageDataList _imageDataList
Definition ImageSequence:158
osg::ImageSequence::_mutex
OpenThreads::Mutex _mutex
Definition ImageSequence:156
osg::ImageSequence::imageIndex
int imageIndex(double time)
osg::ImageStream::ImageStream
ImageStream()
osg::Image
Definition Image:179
osg::Image::s
int s() const
Definition Image:291
osg::Image::t
int t() const
Definition Image:294
osg::Image::AllocationMode
AllocationMode
Definition Image:215
osg::Image::setImage
virtual void setImage(int s, int t, int r, GLint internalTextureformat, GLenum pixelFormat, GLenum type, unsigned char *data, AllocationMode mode, int packing=1, int rowLength=0)
osg::Image::r
int r() const
Definition Image:297
osg::Image::data
unsigned char * data()
Definition Image:352
osg::NodeVisitor
Definition NodeVisitor:82
osg::Object
Definition Object:61
osg::Referenced
Definition Referenced:44
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39
osg::ImageSequence::ImageData::_filename
std::string _filename
Definition ImageSequence:57
osg::ImageSequence::ImageData::_imageRequest
osg::ref_ptr< osg::Referenced > _imageRequest
Definition ImageSequence:59
osg::ImageSequence::ImageData::ImageData
ImageData()
osg::ImageSequence::ImageData::_image
osg::ref_ptr< osg::Image > _image
Definition ImageSequence:58
osg::ImageSequence::ImageData::ImageData
ImageData(const ImageData &id)