root/OpenSceneGraph/trunk/src/osgPlugins/ive/Sequence.cpp @ 13041

Revision 13041, 3.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            Sequence.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Sequence in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerate
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 24.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "Sequence.h"
17#include "Group.h"
18
19using namespace ive;
20
21void Sequence::write(DataOutputStream* out)
22{
23    // Write Sequence's identification.
24    out->writeInt(IVESEQUENCE);
25    // If the osg class is inherited by any other class we should also write this to file.
26    osg::Group*  group = dynamic_cast<osg::Group*>(this);
27    if(group)
28    {
29        ((ive::Group*)(group))->write(out);
30    }
31    else
32    {
33        out_THROW_EXCEPTION("Sequence::write(): Could not cast this osg::Sequence to an osg::Group.");
34    }
35
36    // Write Sequence's properties.
37
38    if (out->getVersion() >= VERSION_0022)
39    {
40        // Write default frame time
41        out->writeFloat(getDefaultTime()) ;
42    }
43
44    // Write frame times.
45    int size = getNumChildren();
46    out->writeInt(size);
47    for(int i=0;i<size;i++)
48    {
49        out->writeFloat(getTime(i));
50    }
51
52    if (out->getVersion() >= VERSION_0022)
53    {
54        // Write last frame time
55        out->writeFloat(getLastFrameTime()) ;
56    }
57
58    // Write loop mode & interval
59    osg::Sequence::LoopMode mode;
60    int begin, end;
61    getInterval(mode, begin, end);
62    out->writeInt(mode);
63    out->writeInt(begin);
64    out->writeInt(end);
65
66    // Write duration
67    float speed;
68    int nreps;
69    getDuration(speed, nreps);
70    out->writeFloat(speed);
71    out->writeInt(nreps);
72
73    // Write sequence mode
74    out->writeInt(getMode());
75
76    if (out->getVersion() >= VERSION_0022)
77    {
78        // Write sync as an integer
79        out->writeInt((int)getSync()) ;
80
81        // Write clearOnStop as an integer
82        out->writeInt((int)getClearOnStop()) ;
83    }
84
85}
86
87void Sequence::read(DataInputStream* in)
88{
89    // Peek on Sequence's identification.
90    int id = in->peekInt();
91    if(id == IVESEQUENCE)
92    {
93        // Read Sequence's identification.
94        id = in->readInt();
95        // If the osg class is inherited by any other class we should also read this from file.
96        osg::Group*  group = dynamic_cast<osg::Group*>(this);
97        if(group)
98        {
99            ((ive::Group*)(group))->read(in);
100        }
101        else
102        {
103            in_THROW_EXCEPTION("Sequence::read(): Could not cast this osg::Sequence to an osg::Group.");
104        }
105
106        // Read Sequence's properties
107
108        if (in->getVersion() >= VERSION_0022)
109        {
110            // Read default frame time
111            setDefaultTime(in->readFloat());
112        }
113
114        // Read frame times.
115        int size = in->readInt();
116        for(int i=0;i<size;i++)
117        {
118            setTime(i, in->readFloat());
119        }
120
121        if (in->getVersion() >= VERSION_0022)
122        {
123            // Read last frame time
124            setLastFrameTime(in->readFloat());
125        }
126
127        // Read loop mode & interval
128        int mode = in->readInt();
129        int begin = in->readInt();
130        int end = in->readInt();
131        setInterval((osg::Sequence::LoopMode)mode, begin, end);
132
133        // Read duration
134        float speed = in->readFloat();
135        int nreps = in->readInt();
136        setDuration(speed, nreps);
137
138        // Read sequence mode
139        setMode((osg::Sequence::SequenceMode)in->readInt());
140
141        if (in->getVersion() >= VERSION_0022)
142        {
143            // Read sync from an integer
144            setSync((in->readInt())!=0) ;
145
146            // Read clearOnStop from an integer
147            setClearOnStop((in->readInt())!=0) ;
148        }
149    }
150    else
151    {
152        in_THROW_EXCEPTION("Sequence::read(): Expected Sequence identification.");
153    }
154}
Note: See TracBrowser for help on using the browser.