diff --git a/VisualStudio/osgPlugins/ive/ive.dsp b/VisualStudio/osgPlugins/ive/ive.dsp index fe42ec2de..f27e9ff52 100755 --- a/VisualStudio/osgPlugins/ive/ive.dsp +++ b/VisualStudio/osgPlugins/ive/ive.dsp @@ -238,6 +238,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\Point.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\LineWidth.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\ReaderWriterIVE.cpp # End Source File # Begin Source File @@ -490,6 +494,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\Point.h # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\LineWidth.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\ShadeModel.h # End Source File # Begin Source File diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index d025f6e3b..4e7dec06f 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -22,6 +22,7 @@ #include "PolygonOffset.h" #include "ShadeModel.h" #include "Point.h" +#include "LineWidth.h" #include "Texture1D.h" #include "Texture2D.h" #include "TextureCubeMap.h" @@ -630,6 +631,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute() attribute = new osg::Point(); ((ive::Point*)(attribute))->read(this); } + else if(attributeID == IVELINEWIDTH){ + attribute = new osg::LineWidth(); + ((ive::LineWidth*)(attribute))->read(this); + } else if(attributeID == IVETEXTURE1D){ attribute = new osg::Texture1D(); ((ive::Texture1D*)(attribute))->read(this); diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 8de644cdf..ef47cdf73 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -24,6 +24,7 @@ #include "PolygonOffset.h" #include "ShadeModel.h" #include "Point.h" +#include "LineWidth.h" #include "Texture1D.h" #include "Texture2D.h" #include "TextureCubeMap.h" @@ -431,6 +432,12 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute) else if(dynamic_cast(attribute)){ ((ive::Point*)(attribute))->write(this); } + else if(dynamic_cast(attribute)){ + ((ive::LineWidth*)(attribute))->write(this); + } + else if(dynamic_cast(attribute)){ + ((ive::LineWidth*)(attribute))->write(this); + } // This is a Texture1D else if(dynamic_cast(attribute)){ ((ive::Texture1D*)(attribute))->write(this); diff --git a/src/osgPlugins/ive/GNUmakefile b/src/osgPlugins/ive/GNUmakefile index b4c8dc1ae..10388b802 100644 --- a/src/osgPlugins/ive/GNUmakefile +++ b/src/osgPlugins/ive/GNUmakefile @@ -33,6 +33,7 @@ CXXFILES =\ MatrixTransform.cpp\ MultiSwitch.cpp\ Node.cpp\ + LineWidth.cpp\ Object.cpp\ OccluderNode.cpp\ PagedLOD.cpp\ diff --git a/src/osgPlugins/ive/LineWidth.cpp b/src/osgPlugins/ive/LineWidth.cpp new file mode 100644 index 000000000..d34c1a107 --- /dev/null +++ b/src/osgPlugins/ive/LineWidth.cpp @@ -0,0 +1,54 @@ +/********************************************************************** + * + * FILE: LineWidth.cpp + * + * DESCRIPTION: Read/Write osg::LineWidth in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 27.3.2003 + * + * Copyright 2003 VR-C + **********************************************************************/ + +#include "Exception.h" +#include "LineWidth.h" +#include "Object.h" + +using namespace ive; + +void LineWidth::write(DataOutputStream* out){ + // Write CullFace's identification. + out->writeInt(IVELINEWIDTH); + // 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){ + ((ive::Object*)(obj))->write(out); + } + else + throw Exception("LineWidth::write(): Could not cast this osg::LineWidth to an osg::Object."); + // Write LineWidth's properties. + out->writeFloat(getWidth()); +} + +void LineWidth::read(DataInputStream* in){ + // Peek on LineWidth's identification. + int id = in->peekInt(); + if(id == IVELINEWIDTH){ + // Read LineWidth'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){ + ((ive::Object*)(obj))->read(in); + } + else + throw Exception("LineWidth::read(): Could not cast this osg::LineWidth to an osg::Object."); + // Read LineWidth's properties + setWidth(in->readFloat()); + } + else{ + throw Exception("LineWidth::read(): Expected LineWidth identification."); + } +} diff --git a/src/osgPlugins/ive/LineWidth.h b/src/osgPlugins/ive/LineWidth.h new file mode 100644 index 000000000..f99c8bae7 --- /dev/null +++ b/src/osgPlugins/ive/LineWidth.h @@ -0,0 +1,15 @@ +#ifndef IVE_LINEWIDTH +#define IVE_LINEWIDTH 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class LineWidth : public osg::LineWidth, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index d3c898a86..fa5dfee51 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -53,6 +53,7 @@ namespace ive { #define IVESHADEMODEL 0x0000012A #define IVEPOINT 0x0000012B #define IVETEXMAT 0x0000012C +#define IVELINEWIDTH 0x0000012D // Drawables #define IVEDRAWABLE 0x00001000