diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 7a81ad193..70fc376b9 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -74,7 +74,7 @@ DataOutputStream::DataOutputStream(std::ostream * ostream) if(!_ostream) throw Exception("DataOutputStream::DataOutputStream(): null pointer exception in argument."); writeUInt(ENDIAN_TYPE) ; - writeUInt(VERSION); + writeUInt(getVersion()); } DataOutputStream::~DataOutputStream(){} diff --git a/src/osgPlugins/ive/DataOutputStream.h b/src/osgPlugins/ive/DataOutputStream.h index 6585993d0..54b364360 100644 --- a/src/osgPlugins/ive/DataOutputStream.h +++ b/src/osgPlugins/ive/DataOutputStream.h @@ -28,6 +28,9 @@ class DataOutputStream{ public: DataOutputStream(std::ostream* ostream); ~DataOutputStream(); + + unsigned int getVersion() { return VERSION; } + void writeBool(bool b); void writeChar(char c); void writeUChar(unsigned char c); diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index c98d9f76a..ca3d3f648 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -9,7 +9,9 @@ stored in the 2nd 4 bytes of the file */ #define VERSION_0002 0x00000002 -#define VERSION 0x00000003 +#define VERSION_0003 0x00000003 +#define VERSION_0004 0x00000004 +#define VERSION VERSION_0004 /* The BYTE_SEX tag is used to check the endian diff --git a/src/osgPlugins/ive/LightModel.h b/src/osgPlugins/ive/LightModel.h index 9e1f3d5b7..6e92a09de 100644 --- a/src/osgPlugins/ive/LightModel.h +++ b/src/osgPlugins/ive/LightModel.h @@ -12,4 +12,4 @@ namespace ive{ }; } -#endif \ No newline at end of file +#endif diff --git a/src/osgPlugins/ive/ShapeDrawable.cpp b/src/osgPlugins/ive/ShapeDrawable.cpp index 6f11fcb86..0b113a7b2 100644 --- a/src/osgPlugins/ive/ShapeDrawable.cpp +++ b/src/osgPlugins/ive/ShapeDrawable.cpp @@ -12,6 +12,7 @@ * Copyright 2003 VR-C **********************************************************************/ +#include "Drawable.h" #include "Exception.h" #include "ShapeDrawable.h" #include "Object.h" @@ -22,14 +23,27 @@ void ShapeDrawable::write(DataOutputStream* out) { // Write CullFace's identification. out->writeInt(IVESHAPEDRAWABLE); - // If the osg class is inherited by any other class we should also write this to file. - osg::Object* obj = dynamic_cast(this); - if(obj) + + if ( out->getVersion() >= VERSION_0004 ) { - ((ive::Object*)(obj))->write(out); + // If the osg class is inherited by any other class we should also write this to file. + osg::Drawable* drawable = dynamic_cast(this); + if(drawable){ + ((ive::Drawable*)(drawable))->write(out); + } + else + throw Exception("ShapeDrawable::write(): Could not cast this osg::ShapeDrawable to an osg::Object."); + } else - throw Exception("ShapeDrawable::write(): Could not cast this osg::ShapeDrawable to an osg::Object."); + { + osg::Object* obj = dynamic_cast(this); + if(obj){ + ((ive::Object*)(obj))->write(out); + } + else + throw Exception("ShapeDrawable::write(): Could not cast this osg::ShapeDrawable to an osg::Object."); + } // Write ShapeDrawable's properties. out->writeVec4(getColor()); @@ -53,15 +67,28 @@ void ShapeDrawable::read(DataInputStream* in) { // Read ShapeDrawable's identification. id = in->readInt(); - // If the osg class is inherited by any other class we should also read this from file. - osg::Object* obj = dynamic_cast(this); - if(obj) + + if ( in->getVersion() >= VERSION_0004 ) { - ((ive::Object*)(obj))->read(in); + // If the osg class is inherited by any other class we should also read this from file. + osg::Drawable* drawable = dynamic_cast(this); + if(drawable){ + ((ive::Drawable*)(drawable))->read(in); + } + else + throw Exception("ShapeDrawable::read(): Could not cast this osg::ShapeDrawable to an osg::Object."); } else - throw Exception("ShapeDrawable::read(): Could not cast this osg::ShapeDrawable to an osg::Object."); - + { + // If the osg class is inherited by any other class we should also read this from file. + osg::Object* obj = dynamic_cast(this); + if(obj){ + ((ive::Object*)(obj))->read(in); + } + else + throw Exception("ShapeDrawable::read(): Could not cast this osg::ShapeDrawable to an osg::Object."); + } + // Read ShapeDrawable's properties setColor(in->readVec4());