From 9c434274be405d79ed78321f7e6f21da2e40ce43 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 13 Feb 2007 14:42:00 +0000 Subject: [PATCH] Added support for ColorMask to .ive plugin --- VisualStudio/osgPlugins/ive/ive.dsp | 4 ++ src/osgPlugins/ive/ColorMask.cpp | 62 +++++++++++++++++++++++++ src/osgPlugins/ive/ColorMask.h | 15 ++++++ src/osgPlugins/ive/DataInputStream.cpp | 5 ++ src/osgPlugins/ive/DataOutputStream.cpp | 5 ++ src/osgPlugins/ive/GNUmakefile | 1 + src/osgPlugins/ive/ReadWrite.h | 2 + 7 files changed, 94 insertions(+) create mode 100644 src/osgPlugins/ive/ColorMask.cpp create mode 100644 src/osgPlugins/ive/ColorMask.h diff --git a/VisualStudio/osgPlugins/ive/ive.dsp b/VisualStudio/osgPlugins/ive/ive.dsp index 3d0bb3020..a709a678e 100755 --- a/VisualStudio/osgPlugins/ive/ive.dsp +++ b/VisualStudio/osgPlugins/ive/ive.dsp @@ -233,6 +233,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\CoordinateSystemNode.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\ColorMask.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\CullFace.cpp # End Source File # Begin Source File diff --git a/src/osgPlugins/ive/ColorMask.cpp b/src/osgPlugins/ive/ColorMask.cpp new file mode 100644 index 000000000..c844e3516 --- /dev/null +++ b/src/osgPlugins/ive/ColorMask.cpp @@ -0,0 +1,62 @@ +/********************************************************************** + * + * FILE: ColorMask.cpp + * + * DESCRIPTION: Read/Write osg::ColorMask 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 "ColorMask.h" +#include "Object.h" + +using namespace ive; + +void ColorMask::write(DataOutputStream* out){ + // Write ColorMask's identification. + out->writeInt(IVECOLORMASK); + // 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("ColorMask::write(): Could not cast this osg::ColorMask to an osg::Object."); + + // Write ColorMask's properties. + out->writeBool(getRedMask()); + out->writeBool(getGreenMask()); + out->writeBool(getBlueMask()); + out->writeBool(getAlphaMask()); +} + +void ColorMask::read(DataInputStream* in){ + // Peek on ColorMask's identification. + int id = in->peekInt(); + if(id == IVECOLORMASK){ + // Read ColorMask'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("ColorMask::read(): Could not cast this osg::ColorMask to an osg::Object."); + + // Read ColorMask's properties + setRedMask(in->readBool()); + setGreenMask(in->readBool()); + setBlueMask(in->readBool()); + setAlphaMask(in->readBool()); + } + else{ + throw Exception("ColorMask::read(): Expected ColorMask identification."); + } +} diff --git a/src/osgPlugins/ive/ColorMask.h b/src/osgPlugins/ive/ColorMask.h new file mode 100644 index 000000000..c607d5868 --- /dev/null +++ b/src/osgPlugins/ive/ColorMask.h @@ -0,0 +1,15 @@ +#ifndef IVE_COLORMASK +#define IVE_COLORMASK 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class ColorMask : public osg::ColorMask, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 92987c659..e33645ecf 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -24,6 +24,7 @@ #include "Depth.h" #include "Material.h" #include "CullFace.h" +#include "ColorMask.h" #include "ClipPlane.h" #include "PolygonOffset.h" #include "PolygonMode.h" @@ -998,6 +999,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute() attribute = new osg::CullFace(); ((ive::CullFace*)(attribute))->read(this); } + else if(attributeID == IVECOLORMASK){ + attribute = new osg::ColorMask(); + ((ive::ColorMask*)(attribute))->read(this); + } else if(attributeID == IVECLIPPLANE){ attribute = new osg::ClipPlane(); ((ive::ClipPlane*)(attribute))->read(this); diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 4bb4b8830..49b168e13 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -24,6 +24,7 @@ #include "BlendFunc.h" #include "Material.h" #include "CullFace.h" +#include "ColorMask.h" #include "Depth.h" #include "ClipPlane.h" #include "PolygonOffset.h" @@ -682,6 +683,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute) else if(dynamic_cast(attribute)){ ((ive::CullFace*)(attribute))->write(this); } + // This is a ColorMask + else if(dynamic_cast(attribute)){ + ((ive::ColorMask*)(attribute))->write(this); + } // this is a Cliplane else if(dynamic_cast(attribute)){ ((ive::ClipPlane*)(attribute))->write(this); diff --git a/src/osgPlugins/ive/GNUmakefile b/src/osgPlugins/ive/GNUmakefile index 2bcc19a78..e247f6934 100644 --- a/src/osgPlugins/ive/GNUmakefile +++ b/src/osgPlugins/ive/GNUmakefile @@ -21,6 +21,7 @@ CXXFILES =\ ConvexPlanarOccluder.cpp\ ConvexPlanarPolygon.cpp\ CoordinateSystemNode.cpp\ + ColorMask.cpp\ CullFace.cpp\ DataInputStream.cpp\ DataOutputStream.cpp\ diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index 61706dbb6..48fe7cf6f 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -68,6 +68,8 @@ namespace ive { #define IVEVERTEXPROGRAM 0x0000012F #define IVEDEPTH 0x00000130 #define IVESTENCIL 0x00000131 +#define IVESTENCILTWOSIDED 0x00000132 +#define IVECOLORMASK 0x00000133 #define IVELIGHTMODEL 0x00001121 #define IVECLIPPLANE 0x00001122 #define IVEFRONTFACE 0x00001123