diff --git a/VisualStudio/osgPlugins/ive/ive.dsp b/VisualStudio/osgPlugins/ive/ive.dsp index 21b5ea6a0..e9a0e6659 100755 --- a/VisualStudio/osgPlugins/ive/ive.dsp +++ b/VisualStudio/osgPlugins/ive/ive.dsp @@ -128,6 +128,14 @@ SOURCE=..\..\..\src\osgPlugins\ive\BlinkSequence.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\ClipPlane.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\ClipNode.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\ClusterCullingCallback.cpp # End Source File # Begin Source File @@ -340,6 +348,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\TexGen.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\TexGenNode.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\TexMat.cpp # End Source File # Begin Source File @@ -412,6 +424,14 @@ SOURCE=..\..\..\src\osgPlugins\ive\BlinkSequence.h # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\ClipPlane.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\ClipNode.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\ClusterCullingCallback.h # End Source File # Begin Source File @@ -628,6 +648,10 @@ SOURCE=..\..\..\src\osgPlugins\ive\TexGen.h # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\ive\TexGenNode.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\ive\TexMat.h # End Source File # Begin Source File diff --git a/include/osg/ClipNode b/include/osg/ClipNode index e16110267..6de0156c7 100644 --- a/include/osg/ClipNode +++ b/include/osg/ClipNode @@ -51,7 +51,7 @@ class SG_EXPORT ClipNode : public Group bool removeClipPlane(unsigned int pos); /** Returns the number of ClipPlanes. */ - inline unsigned int getNumClipPlanes() const { return _planes.size(); } + inline unsigned int getNumClipPlanes() const { return _planes.size(); } /** Get ClipPlane at the given index position. */ diff --git a/src/osgPlugins/ive/ClipNode.cpp b/src/osgPlugins/ive/ClipNode.cpp new file mode 100644 index 000000000..eb99dd215 --- /dev/null +++ b/src/osgPlugins/ive/ClipNode.cpp @@ -0,0 +1,72 @@ +/********************************************************************** + * + * FILE: ClipNode.cpp + * + * DESCRIPTION: Read/Write osg::ClipNode 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 "ClipNode.h" +#include "ClipPlane.h" +#include "Group.h" +#include "Light.h" + +using namespace ive; + +void ClipNode::write(DataOutputStream* out){ + // Write ClipNode's identification. + out->writeInt(IVECLIPNODE); + // If the osg class is inherited by any other class we should also write this to file. + osg::Group* group = dynamic_cast(this); + if(group){ + ((ive::Group*)(group))->write(out); + } + else + throw Exception("ClipNode::write(): Could not cast this osg::ClipNode to an osg::Group."); + // Write ClipNode's properties. + + out->writeUInt(getNumClipPlanes()); + + for (unsigned int i=0;iwrite(out); + } + +} + +void ClipNode::read(DataInputStream* in){ + // Peek on ClipNode's identification. + int id = in->peekInt(); + if(id == IVECLIPNODE){ + // Read ClipNode's identification. + id = in->readInt(); + // If the osg class is inherited by any other class we should also read this from file. + osg::Group* group = dynamic_cast(this); + if(group){ + ((ive::Group*)(group))->read(in); + } + else + throw Exception("ClipNode::read(): Could not cast this osg::ClipNode to an osg::Object."); + // Read ClipNode's properties + + unsigned int numClipPlanes = in->readUInt(); + + for (unsigned int i=0;iread(in); + addClipPlane(clipPlane); + } + + } + else{ + throw Exception("ClipNode::read(): Expected ClipNode identification."); + } +} diff --git a/src/osgPlugins/ive/ClipNode.h b/src/osgPlugins/ive/ClipNode.h new file mode 100644 index 000000000..9b53e006f --- /dev/null +++ b/src/osgPlugins/ive/ClipNode.h @@ -0,0 +1,15 @@ +#ifndef IVE_ClipNode +#define IVE_ClipNode 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class ClipNode : public osg::ClipNode, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/ClipPlane.cpp b/src/osgPlugins/ive/ClipPlane.cpp new file mode 100644 index 000000000..45ab63e53 --- /dev/null +++ b/src/osgPlugins/ive/ClipPlane.cpp @@ -0,0 +1,80 @@ +/********************************************************************** + * + * FILE: ClipPlane.cpp + * + * DESCRIPTION: Read/Write osg::ClipPlane (partially) in binary format to disk. + * + * CREATED BY: Stanislav Blinov + * + * HISTORY: Created 7.09.2004 + * + * Copyright 2004 OtherSide + **********************************************************************/ + +#include "Exception.h" +#include "ClipPlane.h" +#include "Object.h" + +using namespace ive; + +void ClipPlane::write(DataOutputStream* out){ + + // write ClipPlane's identification + out->writeInt(IVECLIPPLANE); + + // 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("ClipPlane::write(): Could not cast this osg::ClipPlane to an osg::Object."); + + // write ClipPlane's properties + + + + + double plane[4]; + getClipPlane(plane); + + out->writeDouble(plane[0]); + out->writeDouble(plane[1]); + out->writeDouble(plane[2]); + out->writeDouble(plane[3]); + + out->writeUInt(getClipPlaneNum()); + +} + +void ClipPlane::read(DataInputStream* in){ + + // peek on ClipPlane's identification + int id = in->peekInt(); + if(id == IVECLIPPLANE) + { + // read ClipPlane'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("ClipPlane::read(): Could not cast this osg::ClipPlane to an osg::Object."); + + // Read ClipPlane's properties + double plane[4]; + + plane[0] = in->readDouble(); + plane[1] = in->readDouble(); + plane[2] = in->readDouble(); + plane[3] = in->readDouble(); + + setClipPlane(plane); + + setClipPlaneNum(in->readUInt()); + } + else{ + throw Exception("ClipPlane::read(): Expected ClipPlane identification."); + } +} diff --git a/src/osgPlugins/ive/ClipPlane.h b/src/osgPlugins/ive/ClipPlane.h new file mode 100644 index 000000000..0c234638a --- /dev/null +++ b/src/osgPlugins/ive/ClipPlane.h @@ -0,0 +1,15 @@ +#ifndef IVE_ClipPlane +#define IVE_ClipPlane 1 + +#include +#include "ReadWrite.h" + +namespace ive{ + class ClipPlane : public osg::ClipPlane, 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 55ff55897..ce7d987f9 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -21,6 +21,7 @@ #include "BlendFunc.h" #include "Material.h" #include "CullFace.h" +#include "ClipPlane.h" #include "PolygonOffset.h" #include "ShadeModel.h" #include "Point.h" @@ -41,6 +42,8 @@ #include "MatrixTransform.h" #include "Geode.h" #include "LightSource.h" +#include "TexGenNode.h" +#include "ClipNode.h" #include "Billboard.h" #include "Sequence.h" #include "LOD.h" @@ -311,6 +314,18 @@ osg::Vec4 DataInputStream::readVec4(){ return v; } +osg::Plane DataInputStream::readPlane(){ + osg::Plane v; + v[0]=readFloat(); + v[1]=readFloat(); + v[2]=readFloat(); + v[3]=readFloat(); + + if (_verboseOutput) std::cout<<"read/writePlane() ["<read(this); } + else if(attributeID == IVECLIPPLANE){ + attribute = new osg::ClipPlane(); + ((ive::ClipPlane*)(attribute))->read(this); + } else if(attributeID == IVEPOLYGONOFFSET){ attribute = new osg::PolygonOffset(); ((ive::PolygonOffset*)(attribute))->read(this); @@ -835,6 +854,14 @@ osg::Node* DataInputStream::readNode() node = new osg::LightSource(); ((ive::LightSource*)(node))->read(this); } + else if(nodeTypeID== IVETEXGENNODE){ + node = new osg::TexGenNode(); + ((ive::TexGenNode*)(node))->read(this); + } + else if(nodeTypeID== IVECLIPNODE){ + node = new osg::ClipNode(); + ((ive::ClipNode*)(node))->read(this); + } else if(nodeTypeID== IVESEQUENCE){ node = new osg::Sequence(); ((ive::Sequence*)(node))->read(this); diff --git a/src/osgPlugins/ive/DataInputStream.h b/src/osgPlugins/ive/DataInputStream.h index 2cd8af75d..7b72d892c 100644 --- a/src/osgPlugins/ive/DataInputStream.h +++ b/src/osgPlugins/ive/DataInputStream.h @@ -48,6 +48,7 @@ public: osg::Vec2 readVec2(); osg::Vec3 readVec3(); osg::Vec4 readVec4(); + osg::Plane readPlane(); osg::UByte4 readUByte4(); osg::Quat readQuat(); osg::Matrix readMatrix(); diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index babd49693..ecbdbe0eb 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -22,6 +22,7 @@ #include "BlendFunc.h" #include "Material.h" #include "CullFace.h" +#include "ClipPlane.h" #include "PolygonOffset.h" #include "ShadeModel.h" #include "Point.h" @@ -43,6 +44,8 @@ #include "MatrixTransform.h" #include "Geode.h" #include "LightSource.h" +#include "TexGenNode.h" +#include "ClipNode.h" #include "Billboard.h" #include "Sequence.h" #include "LOD.h" @@ -179,6 +182,16 @@ void DataOutputStream::writeVec4(const osg::Vec4& v){ if (_verboseOutput) std::cout<<"read/writeVec4() ["<(attribute)){ ((ive::CullFace*)(attribute))->write(this); } + // this is a Cliplane + else if(dynamic_cast(attribute)){ + ((ive::ClipPlane*)(attribute))->write(this); + } // This is a PolygonOffset else if(dynamic_cast(attribute)){ ((ive::PolygonOffset*)(attribute))->write(this); @@ -611,6 +628,12 @@ void DataOutputStream::writeNode(const osg::Node* node) else if(dynamic_cast(node)){ ((ive::LightSource*)(node))->write(this); } + else if(dynamic_cast(node)){ + ((ive::TexGenNode*)(node))->write(this); + } + else if(dynamic_cast(node)){ + ((ive::ClipNode*)(node))->write(this); + } else if(dynamic_cast(node)){ ((ive::Sequence*)(node))->write(this); } diff --git a/src/osgPlugins/ive/DataOutputStream.h b/src/osgPlugins/ive/DataOutputStream.h index 54b364360..f010763cb 100644 --- a/src/osgPlugins/ive/DataOutputStream.h +++ b/src/osgPlugins/ive/DataOutputStream.h @@ -46,6 +46,7 @@ public: void writeVec2(const osg::Vec2& v); void writeVec3(const osg::Vec3& v); void writeVec4(const osg::Vec4& v); + void writePlane(const osg::Plane& v); void writeUByte4(const osg::UByte4& v); void writeQuat(const osg::Quat& q); void writeBinding(osg::Geometry::AttributeBinding b); diff --git a/src/osgPlugins/ive/GNUmakefile b/src/osgPlugins/ive/GNUmakefile index e35853f96..5fcb65af2 100644 --- a/src/osgPlugins/ive/GNUmakefile +++ b/src/osgPlugins/ive/GNUmakefile @@ -3,74 +3,77 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ AlphaFunc.cpp\ - AnimationPath.cpp\ AnimationPathCallback.cpp\ + AnimationPath.cpp\ + AzimElevationSector.cpp\ + AzimSector.cpp\ Billboard.cpp\ BlendFunc.cpp\ + BlinkSequence.cpp\ + ClipNode.cpp\ + ClipPlane.cpp\ + ClusterCullingCallback.cpp\ + ConeSector.cpp\ ConvexPlanarOccluder.cpp\ ConvexPlanarPolygon.cpp\ CoordinateSystemNode.cpp\ - ClusterCullingCallback.cpp\ CullFace.cpp\ DataInputStream.cpp\ DataOutputStream.cpp\ + DirectionalSector.cpp\ DOFTransform.cpp\ + Drawable.cpp\ DrawArrayLengths.cpp\ DrawArrays.cpp\ DrawElementsUByte.cpp\ - DrawElementsUShort.cpp\ DrawElementsUInt.cpp\ - Drawable.cpp\ + DrawElementsUShort.cpp\ + ElevationSector.cpp\ EllipsoidModel.cpp\ Exception.cpp\ + FragmentProgram.cpp\ Geode.cpp\ Geometry.cpp\ Group.cpp\ Image.cpp\ Impostor.cpp\ - LOD.cpp\ Light.cpp\ - LightSource.cpp\ LightModel.cpp\ + LightPoint.cpp\ + LightPointNode.cpp\ + LightSource.cpp\ + LineWidth.cpp\ + LOD.cpp\ Material.cpp\ MatrixTransform.cpp\ MultiSwitch.cpp\ Node.cpp\ - LineWidth.cpp\ Object.cpp\ OccluderNode.cpp\ PagedLOD.cpp\ - PositionAttitudeTransform.cpp\ - PolygonOffset.cpp\ Point.cpp\ + PolygonOffset.cpp\ + PositionAttitudeTransform.cpp\ PrimitiveSet.cpp\ + ReaderWriterIVE.cpp\ Sequence.cpp\ ShadeModel.cpp\ Shape.cpp\ ShapeDrawable.cpp\ - Switch.cpp\ StateSet.cpp\ - TexEnv.cpp\ + Switch.cpp\ TexEnvCombine.cpp\ + TexEnv.cpp\ TexGen.cpp\ + TexGenNode.cpp\ TexMat.cpp\ - Texture.cpp\ Texture1D.cpp\ Texture2D.cpp\ Texture3D.cpp\ + Texture.cpp\ TextureCubeMap.cpp\ - FragmentProgram.cpp\ - VertexProgram.cpp\ Transform.cpp\ - ReaderWriterIVE.cpp\ - AzimElevationSector.cpp\ - AzimSector.cpp\ - BlinkSequence.cpp\ - ConeSector.cpp\ - DirectionalSector.cpp\ - ElevationSector.cpp\ - LightPoint.cpp\ - LightPointNode.cpp\ + VertexProgram.cpp\ VisibilityGroup.cpp\ LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS) diff --git a/src/osgPlugins/ive/IveVersion.h b/src/osgPlugins/ive/IveVersion.h index ca3d3f648..46f72191d 100644 --- a/src/osgPlugins/ive/IveVersion.h +++ b/src/osgPlugins/ive/IveVersion.h @@ -11,7 +11,8 @@ #define VERSION_0002 0x00000002 #define VERSION_0003 0x00000003 #define VERSION_0004 0x00000004 -#define VERSION VERSION_0004 +#define VERSION_0005 0x00000005 +#define VERSION VERSION_0005 /* The BYTE_SEX tag is used to check the endian diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index a71a87ab5..553311f75 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -31,6 +31,8 @@ namespace ive { #define IVEDOFTRANSFORM 0x00000022 #define IVECOORDINATESYSTEMNODE 0x00000023 #define IVEELLIPSOIDMODEL 0x00000024 +#define IVETEXGENNODE 0x00000025 +#define IVECLIPNODE 0x00000026 // Node callbacks #define IVENODECALLBACK 0x00000050 @@ -58,7 +60,8 @@ namespace ive { #define IVELINEWIDTH 0x0000012D #define IVEFRAGMENTPROGRAM 0x0000012E #define IVEVERTEXPROGRAM 0x0000012F -#define IVELIGHTMODEL 0x00001121 +#define IVELIGHTMODEL 0x00001121 +#define IVECLIPPLANE 0x00001122 // Drawables #define IVEDRAWABLE 0x00001000 diff --git a/src/osgPlugins/ive/StateSet.cpp b/src/osgPlugins/ive/StateSet.cpp index 672f8144a..483bb5334 100644 --- a/src/osgPlugins/ive/StateSet.cpp +++ b/src/osgPlugins/ive/StateSet.cpp @@ -15,18 +15,6 @@ #include "Exception.h" #include "StateSet.h" #include "Object.h" -#include "BlendFunc.h" -#include "Material.h" -#include "Material.h" -#include "CullFace.h" -#include "PolygonOffset.h" -#include "ShadeModel.h" -#include "Texture1D.h" -#include "Texture2D.h" -#include "TextureCubeMap.h" -#include "TexEnv.h" -#include "TexEnvCombine.h" -#include "TexGen.h" #include diff --git a/src/osgPlugins/ive/TexGen.cpp b/src/osgPlugins/ive/TexGen.cpp index e00f7cb3f..18eb84dea 100644 --- a/src/osgPlugins/ive/TexGen.cpp +++ b/src/osgPlugins/ive/TexGen.cpp @@ -33,7 +33,13 @@ void TexGen::write(DataOutputStream* out){ // Write mode out->writeInt(getMode()); - // Notice no support for planes yet + if ( out->getVersion() >= VERSION_0005 ) + { + out->writePlane(getPlane(osg::TexGen::S)); + out->writePlane(getPlane(osg::TexGen::T)); + out->writePlane(getPlane(osg::TexGen::R)); + out->writePlane(getPlane(osg::TexGen::Q)); + } } void TexGen::read(DataInputStream* in){ @@ -51,6 +57,14 @@ void TexGen::read(DataInputStream* in){ throw Exception("TexGen::read(): Could not cast this osg::TexGen to an osg::Object."); // Read TexGen's properties setMode((osg::TexGen::Mode)in->readInt()); + + if ( in->getVersion() >= VERSION_0005 ) + { + setPlane(osg::TexGen::S, in->readPlane()); + setPlane(osg::TexGen::T, in->readPlane()); + setPlane(osg::TexGen::R, in->readPlane()); + setPlane(osg::TexGen::Q, in->readPlane()); + } } else{ diff --git a/src/osgPlugins/ive/TexGenNode.cpp b/src/osgPlugins/ive/TexGenNode.cpp new file mode 100644 index 000000000..9a62626a1 --- /dev/null +++ b/src/osgPlugins/ive/TexGenNode.cpp @@ -0,0 +1,73 @@ +/********************************************************************** + * + * FILE: TexGenNode.cpp + * + * DESCRIPTION: Read/Write osg::TexGenNode 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 "TexGenNode.h" +#include "Group.h" +#include "TexGen.h" + +using namespace ive; + +void TexGenNode::write(DataOutputStream* out){ + // Write TexGenNode's identification. + out->writeInt(IVETEXGENNODE); + // If the osg class is inherited by any other class we should also write this to file. + osg::Group* group = dynamic_cast(this); + if(group){ + ((ive::Group*)(group))->write(out); + } + else + throw Exception("TexGenNode::write(): Could not cast this osg::TexGenNode to an osg::Group."); + // Write TexGenNode's properties. + + + out->writeUInt(getTextureUnit()); + + // Write out light + out->writeBool(getTexGen()!=0); + if(getTexGen()) + { + ((ive::TexGen*)(getTexGen()))->write(out); + } +} + +void TexGenNode::read(DataInputStream* in){ + // Peek on TexGenNode's identification. + int id = in->peekInt(); + if(id == IVETEXGENNODE){ + // Read TexGenNode's identification. + id = in->readInt(); + // If the osg class is inherited by any other class we should also read this from file. + osg::Group* group = dynamic_cast(this); + if(group){ + ((ive::Group*)(group))->read(in); + } + else + throw Exception("TexGenNode::read(): Could not cast this osg::TexGenNode to an osg::Object."); + // Read TexGenNode's properties + + + setTextureUnit(in->readUInt()); + + // Read texgen + if(in->readBool()){ + osg::TexGen* texgen = new osg::TexGen(); + ((ive::TexGen*)(texgen))->read(in); + setTexGen(texgen); + } + } + else{ + throw Exception("TexGenNode::read(): Expected TexGenNode identification."); + } +} diff --git a/src/osgPlugins/ive/TexGenNode.h b/src/osgPlugins/ive/TexGenNode.h new file mode 100644 index 000000000..47ee0e010 --- /dev/null +++ b/src/osgPlugins/ive/TexGenNode.h @@ -0,0 +1,15 @@ +#ifndef IVE_TEXGENNODE +#define IVE_TEXGENNODE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class TexGenNode : public osg::TexGenNode, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif