From 9a411784393d4b762c92a1f123772f711b0ef929 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 21 Dec 2007 14:13:40 +0000 Subject: [PATCH] From John Kelso,"Attached is the ive reader/writer for the 2.x version of the osg::Sequence node. " --- src/osgPlugins/ive/IveVersion.h | 3 +- src/osgPlugins/ive/Sequence.cpp | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index 621ad7bfa..bb407bd85 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -30,8 +30,9 @@ #define VERSION_0019 19 #define VERSION_0020 20 #define VERSION_0021 21 +#define VERSION_0022 22 -#define VERSION VERSION_0021 +#define VERSION VERSION_0022 /* The BYTE_SEX tag is used to check the endian of the IVE file being read in. The IVE format diff --git a/src/osgPlugins/ive/Sequence.cpp b/src/osgPlugins/ive/Sequence.cpp index c11cd7779..fc019671b 100644 --- a/src/osgPlugins/ive/Sequence.cpp +++ b/src/osgPlugins/ive/Sequence.cpp @@ -35,6 +35,12 @@ void Sequence::write(DataOutputStream* out) // Write Sequence's properties. + if (out->getVersion() >= VERSION_0022) + { + // Write default frame time + out->writeFloat(getDefaultTime()) ; + } + // Write frame times. int size = getNumChildren(); out->writeInt(size); @@ -42,6 +48,13 @@ void Sequence::write(DataOutputStream* out) { out->writeFloat(getTime(i)); } + + if (out->getVersion() >= VERSION_0022) + { + // Write last frame time + out->writeFloat(getLastFrameTime()) ; + } + // Write loop mode & interval osg::Sequence::LoopMode mode; int begin, end; @@ -60,6 +73,19 @@ void Sequence::write(DataOutputStream* out) // Write sequence mode out->writeInt(getMode()); + if (out->getVersion() >= VERSION_0022) + { + // Write sync as an integer + bool sync ; + getSync(sync) ; + out->writeInt((int)sync) ; + + // Write clearOnStop as an integer + bool clearOnStop ; + getClearOnStop(clearOnStop) ; + out->writeInt((int)clearOnStop) ; + } + } void Sequence::read(DataInputStream* in) @@ -82,12 +108,26 @@ void Sequence::read(DataInputStream* in) } // Read Sequence's properties + + if (in->getVersion() >= VERSION_0022) + { + // Read default frame time + setDefaultTime(in->readFloat()); + } + // Read frame times. int size = in->readInt(); for(int i=0;ireadFloat()); } + + if (in->getVersion() >= VERSION_0022) + { + // Read last frame time + setLastFrameTime(in->readFloat()); + } + // Read loop mode & interval int mode = in->readInt(); int begin = in->readInt(); @@ -101,6 +141,15 @@ void Sequence::read(DataInputStream* in) // Read sequence mode setMode((osg::Sequence::SequenceMode)in->readInt()); + + if (in->getVersion() >= VERSION_0022) + { + // Read sync from an integer + setSync((in->readInt())!=0) ; + + // Read clearOnStop from an integer + setClearOnStop((in->readInt())!=0) ; + } } else {