| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "Exception.h" |
|---|
| 16 | #include "ImageSequence.h" |
|---|
| 17 | #include "Object.h" |
|---|
| 18 | |
|---|
| 19 | #include <osg/Notify> |
|---|
| 20 | |
|---|
| 21 | using namespace ive; |
|---|
| 22 | |
|---|
| 23 | void ImageSequence::write(DataOutputStream* out) |
|---|
| 24 | { |
|---|
| 25 | |
|---|
| 26 | out->writeInt(IVEIMAGESEQUENCE); |
|---|
| 27 | |
|---|
| 28 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 29 | if(obj){ |
|---|
| 30 | ((ive::Object*)(obj))->write(out); |
|---|
| 31 | } |
|---|
| 32 | else |
|---|
| 33 | out_THROW_EXCEPTION("ImageSequence::write(): Could not cast this osg::ImageSequence to an osg::Object."); |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | out->writeInt(getMode()); |
|---|
| 38 | out->writeDouble(getLength()); |
|---|
| 39 | |
|---|
| 40 | out->writeUInt(getImageDataList().size()); |
|---|
| 41 | for(ImageDataList::iterator itr = getImageDataList().begin(); |
|---|
| 42 | itr != getImageDataList().end(); |
|---|
| 43 | ++itr) |
|---|
| 44 | { |
|---|
| 45 | out->writeString(itr->_filename); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | if (getImageDataList().empty()) |
|---|
| 49 | { |
|---|
| 50 | out->writeUInt(0); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | void ImageSequence::read(DataInputStream* in) |
|---|
| 56 | { |
|---|
| 57 | |
|---|
| 58 | int id = in->peekInt(); |
|---|
| 59 | if(id == IVEIMAGESEQUENCE){ |
|---|
| 60 | |
|---|
| 61 | id = in->readInt(); |
|---|
| 62 | |
|---|
| 63 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 64 | if(obj){ |
|---|
| 65 | ((ive::Object*)(obj))->read(in); |
|---|
| 66 | } |
|---|
| 67 | else |
|---|
| 68 | in_THROW_EXCEPTION("ImageSequence::read(): Could not cast this osg::ImageSequence to an osg::Object."); |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | setMode((osg::ImageSequence::Mode)(in->readInt())); |
|---|
| 73 | setLength(in->readDouble()); |
|---|
| 74 | |
|---|
| 75 | unsigned int numFileNames = in->readUInt(); |
|---|
| 76 | if (numFileNames>0) |
|---|
| 77 | { |
|---|
| 78 | for(unsigned int i=0; i<numFileNames; ++i) |
|---|
| 79 | { |
|---|
| 80 | addImageFile(in->readString()); |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | else |
|---|
| 84 | { |
|---|
| 85 | unsigned int numImages = in->readUInt(); |
|---|
| 86 | for(unsigned int i=0; i<numImages; ++i) |
|---|
| 87 | { |
|---|
| 88 | addImage(in->readImage()); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | } |
|---|
| 93 | else{ |
|---|
| 94 | in_THROW_EXCEPTION("ImageSequence::read(): Expected ImageSequence identification."); |
|---|
| 95 | } |
|---|
| 96 | } |
|---|