root/OpenSceneGraph/trunk/src/osgPlugins/ive/ImageSequence.cpp @ 13191

Revision 13191, 2.7 kB (checked in by robert, 3 hours ago)

Added shaders to support experimental shader based displacement mapping technique osgTerrain::ShaderTerrain?.

  • Property svn:eol-style set to native
Line 
1/**********************************************************************
2 *
3 *    FILE:            Image.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Image in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerated
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 20.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "ImageSequence.h"
17#include "Object.h"
18
19#include <osg/Notify>
20
21using namespace ive;
22
23void ImageSequence::write(DataOutputStream* out)
24{
25    // Write ImageSequence's identification.
26    out->writeInt(IVEIMAGESEQUENCE);
27    // If the osg class is inherited by any other class we should also write this to file.
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    // Write ImageSequence's properties.
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
55void ImageSequence::read(DataInputStream* in)
56{
57    // Peek ImageSequence's identification.
58    int id = in->peekInt();
59    if(id == IVEIMAGESEQUENCE){
60        // Read ImageSequence's identification.
61        id = in->readInt();
62        // If the osg class is inherited by any other class we should also read this from file.
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        // Read ImageSequence's properties.
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}
Note: See TracBrowser for help on using the browser.