From 8303f03b24ba7258a1da1ba075bf0325e0bc3db0 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Aug 2008 15:06:41 +0000 Subject: [PATCH] Added .ive support for BlendEquation --- src/osgPlugins/ive/BlendEquation.cpp | 61 +++++++++++++++++++++++++ src/osgPlugins/ive/BlendEquation.h | 15 ++++++ src/osgPlugins/ive/CMakeLists.txt | 1 + src/osgPlugins/ive/DataInputStream.cpp | 5 ++ src/osgPlugins/ive/DataOutputStream.cpp | 4 ++ src/osgPlugins/ive/ReadWrite.h | 1 + 6 files changed, 87 insertions(+) create mode 100644 src/osgPlugins/ive/BlendEquation.cpp create mode 100644 src/osgPlugins/ive/BlendEquation.h diff --git a/src/osgPlugins/ive/BlendEquation.cpp b/src/osgPlugins/ive/BlendEquation.cpp new file mode 100644 index 000000000..394ebb9c7 --- /dev/null +++ b/src/osgPlugins/ive/BlendEquation.cpp @@ -0,0 +1,61 @@ +/********************************************************************** + * + * FILE: BlendEquation.cpp + * + * DESCRIPTION: Read/Write osg::BlendEquation in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerated + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 21.3.2003 + * + * Copyright 2003 VR-C + **********************************************************************/ + +#include "Exception.h" +#include "BlendEquation.h" +#include "Object.h" + +using namespace ive; + +void BlendEquation::write(DataOutputStream* out){ + + // Write BlendEquation's identification. + out->writeInt(IVEBLENDEQUATION); + + // 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("BlendEquation::write(): Could not cast this osg::BlendEquation to an osg::Object."); + // Write BlendEquation's properties. + + // Write source + out->writeInt(getEquation()); +} + +void BlendEquation::read(DataInputStream* in){ + // Peek on BlendEquation's identification. + int id = in->peekInt(); + if(id == IVEBLENDEQUATION){ + // Read BlendEquation'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("BlendEquation::read(): Could not cast this osg::BlendEquation to an osg::Object."); + // Read BlendEquation's properties + + // Read source + setEquation(osg::BlendEquation::Equation(in->readInt())); + + } + else{ + throw Exception("BlendEquation::read(): Expected BlendEquation identification."); + } +} diff --git a/src/osgPlugins/ive/BlendEquation.h b/src/osgPlugins/ive/BlendEquation.h new file mode 100644 index 000000000..d883819d2 --- /dev/null +++ b/src/osgPlugins/ive/BlendEquation.h @@ -0,0 +1,15 @@ +#ifndef IVE_BLENDEQUATION +#define IVE_BLENDEQUATION 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class BlendEquation : public osg::BlendEquation, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/CMakeLists.txt b/src/osgPlugins/ive/CMakeLists.txt index 3735c5bf3..5cda86523 100644 --- a/src/osgPlugins/ive/CMakeLists.txt +++ b/src/osgPlugins/ive/CMakeLists.txt @@ -10,6 +10,7 @@ SET(TARGET_SRC AzimSector.cpp Billboard.cpp BlendColor.cpp + BlendEquation.cpp BlendFunc.cpp BlinkSequence.cpp Camera.cpp diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 7ea90555d..1c65bd560 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -21,6 +21,7 @@ #include "BlendColor.h" #include "Stencil.h" #include "BlendFunc.h" +#include "BlendEquation.h" #include "Depth.h" #include "Material.h" #include "CullFace.h" @@ -1097,6 +1098,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute() attribute = new osg::BlendFunc(); ((ive::BlendFunc*)(attribute))->read(this); } + else if(attributeID == IVEBLENDEQUATION){ + attribute = new osg::BlendEquation(); + ((ive::BlendEquation*)(attribute))->read(this); + } else if(attributeID == IVEDEPTH){ attribute = new osg::Depth(); ((ive::Depth*)(attribute))->read(this); diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 61814c10f..011e3d826 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -22,6 +22,7 @@ #include "BlendColor.h" #include "Stencil.h" #include "BlendFunc.h" +#include "BlendEquation.h" #include "Material.h" #include "CullFace.h" #include "ColorMask.h" @@ -723,6 +724,9 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute) else if(dynamic_cast(attribute)){ ((ive::BlendFunc*)(attribute))->write(this); } + else if(dynamic_cast(attribute)){ + ((ive::BlendEquation*)(attribute))->write(this); + } else if(dynamic_cast(attribute)){ ((ive::Depth*)(attribute))->write(this); } diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index c93db9fbe..b58ace510 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -72,6 +72,7 @@ namespace ive { #define IVESTENCIL 0x00000131 #define IVESTENCILTWOSIDED 0x00000132 #define IVECOLORMASK 0x00000133 +#define IVEBLENDEQUATION 0x00000134 #define IVELIGHTMODEL 0x00001121 #define IVECLIPPLANE 0x00001122 #define IVEFRONTFACE 0x00001123