root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/ImageSequence.cpp @ 13191

Revision 13191, 2.8 kB (checked in by robert, 83 minutes ago)

Standardized on defined(ANDROID)

  • Property svn:eol-style set to native
Line 
1#include <osg/ImageSequence>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6// _fileNames
7static bool checkFileNames( const osg::ImageSequence& image )
8{
9    return image.getNumImageData()>0;
10}
11
12static bool readFileNames( osgDB::InputStream& is, osg::ImageSequence& image )
13{
14    unsigned int files = 0; is >> files >> is.BEGIN_BRACKET;
15    for ( unsigned int i=0; i<files; ++i )
16    {
17        std::string filename; is.readWrappedString( filename );
18        image.addImageFile( filename );
19    }
20    is >> is.END_BRACKET;
21    return true;
22}
23
24static bool writeFileNames( osgDB::OutputStream& os, const osg::ImageSequence& image )
25{
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 )
31    {
32        os.writeWrappedString( itr->_filename );
33        os << std::endl;
34    }
35    os << os.END_BRACKET << std::endl;
36    return true;
37}
38
39// _images
40static bool checkImages( const osg::ImageSequence& image )
41{
42    return false;
43}
44
45static bool readImages( osgDB::InputStream& is, osg::ImageSequence& image )
46{
47    unsigned int images = is.readSize(); is >> is.BEGIN_BRACKET;
48    for ( unsigned int i=0; i<images; ++i )
49    {
50        osg::Image* img = dynamic_cast<osg::Image*>( is.readObject() );
51        if ( img ) image.addImage( img );
52    }
53    is >> is.END_BRACKET;
54    return true;
55}
56
57static bool writeImages( osgDB::OutputStream& os, const osg::ImageSequence& image)
58{
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 )
64    {
65        os.writeObject( (*itr)._image.get() );
66    }
67    os << os.END_BRACKET << std::endl;
68    return true;
69}
70
71REGISTER_OBJECT_WRAPPER( ImageSequence,
72                         new osg::ImageSequence,
73                         osg::ImageSequence,
74                         "osg::Object osg::Image osg::ImageStream osg::ImageSequence" )
75{
76    ADD_DOUBLE_SERIALIZER( ReferenceTime, DBL_MAX );  // _referenceTime
77    ADD_DOUBLE_SERIALIZER( TimeMultiplier, 1.0 );  // _timeMultiplier
78
79    BEGIN_ENUM_SERIALIZER( Mode, PRE_LOAD_ALL_IMAGES );
80        ADD_ENUM_VALUE( PRE_LOAD_ALL_IMAGES );
81        ADD_ENUM_VALUE( PAGE_AND_RETAIN_IMAGES );
82        ADD_ENUM_VALUE( PAGE_AND_DISCARD_USED_IMAGES );
83    END_ENUM_SERIALIZER();  // _mode
84
85    ADD_DOUBLE_SERIALIZER( Length, 1.0 );  // _length
86    ADD_USER_SERIALIZER( FileNames );  // _fileNames
87    ADD_USER_SERIALIZER( Images );  // _images
88}
Note: See TracBrowser for help on using the browser.