From 280eaf56fdb1bebe0b6c2f9cb1a0160a115bf998 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 25 Nov 2003 14:38:16 +0000 Subject: [PATCH] Added support for TexMat to .ive plugin --- VisualStudio/osgPlugins/ive/ive.dsp | 8 ++++ src/osgPlugins/ive/DataInputStream.cpp | 5 +++ src/osgPlugins/ive/DataOutputStream.cpp | 5 +++ src/osgPlugins/ive/GNUmakefile | 1 + src/osgPlugins/ive/ReadWrite.h | 13 +++--- src/osgPlugins/ive/TexMat.cpp | 59 +++++++++++++++++++++++++ src/osgPlugins/ive/TexMat.h | 15 +++++++ 7 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 src/osgPlugins/ive/TexMat.cpp create mode 100644 src/osgPlugins/ive/TexMat.h diff --git a/VisualStudio/osgPlugins/ive/ive.dsp b/VisualStudio/osgPlugins/ive/ive.dsp index d3ec1a3dd..09c7eab92 100755 --- a/VisualStudio/osgPlugins/ive/ive.dsp +++ b/VisualStudio/osgPlugins/ive/ive.dsp @@ -270,6 +270,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\TexGen.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\TexMat.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\Texture.cpp # End Source File # Begin Source File @@ -498,6 +502,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\TexGen.h # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\TexMat.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\Texture.h # End Source File # Begin Source File diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 000582418..092d152a0 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -25,6 +25,7 @@ #include "TexEnv.h" #include "TexEnvCombine.h" #include "TexGen.h" +#include "TexMat.h" #include "Group.h" #include "MatrixTransform.h" @@ -570,6 +571,10 @@ osg::StateAttribute* DataInputStream::readStateAttribute() attribute = new osg::TexGen(); ((ive::TexGen*)(attribute))->read(this); } + else if(attributeID == IVETEXMAT){ + attribute = new osg::TexMat(); + ((ive::TexMat*)(attribute))->read(this); + } else{ throw Exception("Unkown StateAttribute in StateSet::read()"); } diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 56ae1c327..d6dec0ed2 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -27,6 +27,7 @@ #include "TexEnv.h" #include "TexEnvCombine.h" #include "TexGen.h" +#include "TexMat.h" #include "Group.h" #include "MatrixTransform.h" @@ -440,6 +441,10 @@ void DataOutputStream::writeStateAttribute(const osg::StateAttribute* attribute) else if(dynamic_cast(attribute)){ ((ive::TexGen*)(attribute))->write(this); } + // This is a TexMat + else if(dynamic_cast(attribute)){ + ((ive::TexMat*)(attribute))->write(this); + } else{ std::string className = attribute->className(); throw Exception(std::string("StateSet::write(): Unknown StateAttribute: ").append(className)); diff --git a/src/osgPlugins/ive/GNUmakefile b/src/osgPlugins/ive/GNUmakefile index d8e9e9509..a2849b746 100644 --- a/src/osgPlugins/ive/GNUmakefile +++ b/src/osgPlugins/ive/GNUmakefile @@ -45,6 +45,7 @@ CXXFILES =\ TexEnv.cpp\ TexEnvCombine.cpp\ TexGen.cpp\ + TexMat.cpp\ Texture.cpp\ Texture2D.cpp\ TextureCubeMap.cpp\ diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index 053321fba..1242465f4 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -39,19 +39,20 @@ namespace ive { #define IVESTATEATTRIBUTE 0x00000100 #define IVEALPHAFUNC 0x00000101 #define IVEBLENDFUNC 0x00000102 -#define IVEMATERIAL 0x00000110 -#define IVETEXTURE 0x00000120 +#define IVEMATERIAL 0x00000110 +#define IVETEXTURE 0x00000120 #define IVETEXTURE1D 0x00000121 #define IVETEXTURE2D 0x00000122 #define IVETEXTURE3D 0x00000123 #define IVETEXTURECUBEMAP 0x00000124 -#define IVETEXENV 0x00000125 +#define IVETEXENV 0x00000125 #define IVETEXENVCOMBINE 0x00000126 -#define IVETEXGEN 0x00000127 -#define IVECULLFACE 0x00000128 +#define IVETEXGEN 0x00000127 +#define IVECULLFACE 0x00000128 #define IVEPOLYGONOFFSET 0x00000129 #define IVESHADEMODEL 0x0000012A -#define IVEPOINT 0x0000012B +#define IVEPOINT 0x0000012B +#define IVETEXMAT 0x0000012C // Drawables #define IVEDRAWABLE 0x00001000 diff --git a/src/osgPlugins/ive/TexMat.cpp b/src/osgPlugins/ive/TexMat.cpp new file mode 100644 index 000000000..63d862218 --- /dev/null +++ b/src/osgPlugins/ive/TexMat.cpp @@ -0,0 +1,59 @@ +/********************************************************************** + * + * FILE: TexMat.cpp + * + * DESCRIPTION: Read/Write osg::TexMat 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 "TexMat.h" +#include "Object.h" + +using namespace ive; + +void TexMat::write(DataOutputStream* out){ + // Write TexMat's identification. + out->writeInt(IVETEXMAT); + // 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("TexMat::write(): Could not cast this osg::TexMat to an osg::Object."); + // Write TexMat's properties. + + // Write mode + out->writeMatrix(getMatrix()); +} + +void TexMat::read(DataInputStream* in){ + // Peek on TexMat's identification. + int id = in->peekInt(); + if(id == IVETEXMAT){ + // Read TexMat'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("TexMat::read(): Could not cast this osg::TexMat to an osg::Object."); + // Read TexMat's properties + + // Read matrix + setMatrix(in->readMatrix()); + + } + else{ + throw Exception("TexMat::read(): Expected TexMat identification."); + } +} diff --git a/src/osgPlugins/ive/TexMat.h b/src/osgPlugins/ive/TexMat.h new file mode 100644 index 000000000..5eaed11b2 --- /dev/null +++ b/src/osgPlugins/ive/TexMat.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXMAT +#define IVE_TEXMAT 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class TexMat : public osg::TexMat, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif