From 81fbb26d6237ee80e8881b034ac4f6106be16c61 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 14 Sep 2003 22:48:35 +0000 Subject: [PATCH] Forom yne Schmidt Jansen, added support for osgSim into ive plugin. --- VisualStudio/osgPlugins/ive/ive.dsp | 56 ++++++++++ src/osgPlugins/ive/AzimElevationSector.cpp | 54 ++++++++++ src/osgPlugins/ive/AzimElevationSector.h | 15 +++ src/osgPlugins/ive/AzimSector.cpp | 45 ++++++++ src/osgPlugins/ive/AzimSector.h | 15 +++ src/osgPlugins/ive/BlinkSequence.cpp | 81 ++++++++++++++ src/osgPlugins/ive/BlinkSequence.h | 15 +++ src/osgPlugins/ive/ConeSector.cpp | 43 ++++++++ src/osgPlugins/ive/ConeSector.h | 15 +++ src/osgPlugins/ive/DataInputStream.cpp | 12 +-- src/osgPlugins/ive/DataOutputStream.cpp | 12 +-- src/osgPlugins/ive/ElevationSector.cpp | 43 ++++++++ src/osgPlugins/ive/ElevationSector.h | 15 +++ src/osgPlugins/ive/GNUmakefile | 9 +- src/osgPlugins/ive/LightPoint.cpp | 119 +++++++++++++++++++++ src/osgPlugins/ive/LightPoint.h | 15 +++ src/osgPlugins/ive/LightPointNode.cpp | 74 +++++++++++++ src/osgPlugins/ive/LightPointNode.h | 15 +++ src/osgPlugins/ive/PagedLOD.cpp | 4 +- src/osgPlugins/ive/ReadWrite.h | 57 +++++----- 20 files changed, 674 insertions(+), 40 deletions(-) create mode 100644 src/osgPlugins/ive/AzimElevationSector.cpp create mode 100644 src/osgPlugins/ive/AzimElevationSector.h create mode 100644 src/osgPlugins/ive/AzimSector.cpp create mode 100644 src/osgPlugins/ive/AzimSector.h create mode 100644 src/osgPlugins/ive/BlinkSequence.cpp create mode 100644 src/osgPlugins/ive/BlinkSequence.h create mode 100644 src/osgPlugins/ive/ConeSector.cpp create mode 100644 src/osgPlugins/ive/ConeSector.h create mode 100644 src/osgPlugins/ive/ElevationSector.cpp create mode 100644 src/osgPlugins/ive/ElevationSector.h create mode 100644 src/osgPlugins/ive/LightPoint.cpp create mode 100644 src/osgPlugins/ive/LightPoint.h create mode 100644 src/osgPlugins/ive/LightPointNode.cpp create mode 100644 src/osgPlugins/ive/LightPointNode.h diff --git a/VisualStudio/osgPlugins/ive/ive.dsp b/VisualStudio/osgPlugins/ive/ive.dsp index d82bfd128..f9e93836b 100755 --- a/VisualStudio/osgPlugins/ive/ive.dsp +++ b/VisualStudio/osgPlugins/ive/ive.dsp @@ -272,6 +272,34 @@ SOURCE=..\..\..\src\osgPlugins\ive\TextureCubeMap.cpp SOURCE=..\..\..\src\osgPlugins\ive\Transform.cpp # End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\AzimElevationSector.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\AzimSector.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\BlinkSequence.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\ConeSector.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\ElevationSector.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\LightPoint.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\LightPointNode.cpp +# End Source File # End Group # Begin Group "Header Files" @@ -460,6 +488,34 @@ SOURCE=..\..\..\src\osgPlugins\ive\TextureCubeMap.h SOURCE=..\..\..\src\osgPlugins\ive\Transform.h # End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\AzimElevationSector.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\AzimSector.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\BlinkSequence.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\ConeSector.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\ElevationSector.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\LightPoint.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\osgPlugins\ive\LightPointNode.h +# End Source File # End Group # Begin Group "Resource Files" diff --git a/src/osgPlugins/ive/AzimElevationSector.cpp b/src/osgPlugins/ive/AzimElevationSector.cpp new file mode 100644 index 000000000..1e7164c18 --- /dev/null +++ b/src/osgPlugins/ive/AzimElevationSector.cpp @@ -0,0 +1,54 @@ +/********************************************************************** + * + * FILE: AzimElevationSector.cpp + * + * DESCRIPTION: Read/Write osgSim::AzimElevationSector in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator.exe + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 9.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "AzimElevationSector.h" + +using namespace ive; + +void AzimElevationSector::write(DataOutputStream* out){ + // Write AzimElevationSector's identification. + out->writeInt(IVEAZIMELEVATIONSECTOR); + // Write AzimElevationSector's properties. + out->writeFloat(getMinElevation()); + out->writeFloat(getMaxElevation()); + out->writeFloat(getFadeAngle()); + + float minAzimuth, maxAzimuth, fadeAngle; + getAzimuthRange(minAzimuth, maxAzimuth, fadeAngle); + out->writeFloat(minAzimuth); + out->writeFloat(maxAzimuth); + out->writeFloat(fadeAngle); +} + +void AzimElevationSector::read(DataInputStream* in){ + // Peek on AzimElevationSector's identification. + int id = in->peekInt(); + if(id == IVEAZIMELEVATIONSECTOR){ + // Read AzimElevationSector's identification. + id = in->readInt(); + // Read AzimElevationSector's properties + float minElevation = in->readFloat(); + float maxElevation = in->readFloat(); + float fadeAngle = in->readFloat(); + setElevationRange(minElevation, maxElevation, fadeAngle); + + float minAzimuth = in->readFloat(); + float maxAzimuth = in->readFloat(); + fadeAngle = in->readFloat(); + setAzimuthRange(minAzimuth, maxAzimuth, fadeAngle); + } + else{ + throw Exception("AzimElevationSector::read(): Expected AzimElevationSector identification."); + } +} diff --git a/src/osgPlugins/ive/AzimElevationSector.h b/src/osgPlugins/ive/AzimElevationSector.h new file mode 100644 index 000000000..0f6ef7722 --- /dev/null +++ b/src/osgPlugins/ive/AzimElevationSector.h @@ -0,0 +1,15 @@ +#ifndef IVE_AZIMELEVATIONSECTOR +#define IVE_AZIMELEVATIONSECTOR 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class AzimElevationSector : public osgSim::AzimElevationSector, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/AzimSector.cpp b/src/osgPlugins/ive/AzimSector.cpp new file mode 100644 index 000000000..a1209cf37 --- /dev/null +++ b/src/osgPlugins/ive/AzimSector.cpp @@ -0,0 +1,45 @@ +/********************************************************************** + * + * FILE: AzimSector.cpp + * + * DESCRIPTION: Read/Write osgSim::AzimSector in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator.exe + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 9.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "AzimSector.h" + +using namespace ive; + +void AzimSector::write(DataOutputStream* out){ + // Write AzimSector's identification. + out->writeInt(IVEAZIMSECTOR); + // Write AzimSector's properties. + float minAzimuth, maxAzimuth, fadeAngle; + getAzimuthRange(minAzimuth, maxAzimuth, fadeAngle); + out->writeFloat(minAzimuth); + out->writeFloat(maxAzimuth); + out->writeFloat(fadeAngle); +} + +void AzimSector::read(DataInputStream* in){ + // Peek on AzimSector's identification. + int id = in->peekInt(); + if(id == IVEAZIMSECTOR){ + // Read AzimSector's identification. + id = in->readInt(); + // Read AzimSector's properties + float minAzimuth = in->readFloat(); + float maxAzimuth = in->readFloat(); + float fadeAngle = in->readFloat(); + setAzimuthRange(minAzimuth, maxAzimuth, fadeAngle); + } + else{ + throw Exception("AzimSector::read(): Expected AzimSector identification."); + } +} diff --git a/src/osgPlugins/ive/AzimSector.h b/src/osgPlugins/ive/AzimSector.h new file mode 100644 index 000000000..f428b8ef8 --- /dev/null +++ b/src/osgPlugins/ive/AzimSector.h @@ -0,0 +1,15 @@ +#ifndef IVE_AZIMSECTOR +#define IVE_AZIMSECTOR 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class AzimSector : public osgSim::AzimSector, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/BlinkSequence.cpp b/src/osgPlugins/ive/BlinkSequence.cpp new file mode 100644 index 000000000..63ca4000a --- /dev/null +++ b/src/osgPlugins/ive/BlinkSequence.cpp @@ -0,0 +1,81 @@ +/********************************************************************** + * + * FILE: BlinkSequence.cpp + * + * DESCRIPTION: Read/Write osgSim::BlinkSequence in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 5.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "BlinkSequence.h" +#include "Object.h" + +using namespace ive; + +void BlinkSequence::write(DataOutputStream* out){ + // Write BlinkSequence's identification. + out->writeInt(IVEBLINKSEQUENCE); + // If the osgSim 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("BlinkSequence::write(): Could not cast this osgSim::BlinkSequence to an osg::Object."); + + // Write BlinkSequence's properties. + + // Write out pulse data. + unsigned int size = getNumPulses(); + out->writeInt(size); + for(unsigned int i=0; iwriteDouble(length); + out->writeVec4(color); + } + // Write out phase shift. + out->writeDouble(getPhaseShift()); + // Write out SequenceGroup. + out->writeDouble(getSequenceGroup()->_baseTime); + +} + +void BlinkSequence::read(DataInputStream* in){ + // Peek on BlinkSequence's identification. + int id = in->peekInt(); + if(id == IVEBLINKSEQUENCE){ + // Read BlinkSequence's identification. + id = in->readInt(); + // If the osgSim 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("BlinkSequence::read(): Could not cast this osgSim::BlinkSequence to an osg::Object."); + // Read BlinkSequence's properties + + // Read in pulse data. + unsigned int size = in->readInt(); + for(unsigned int i=0; ireadDouble(); + osg::Vec4 color = in->readVec4(); + addPulse(length,color); + } + // Read in phase shift. + setPhaseShift(in->readDouble()); + // Read in SequenceGroup + setSequenceGroup(new SequenceGroup(in->readDouble())); + + } + else{ + throw Exception("BlinkSequence::read(): Expected BlinkSequence identification."); + } +} diff --git a/src/osgPlugins/ive/BlinkSequence.h b/src/osgPlugins/ive/BlinkSequence.h new file mode 100644 index 000000000..e2442de0a --- /dev/null +++ b/src/osgPlugins/ive/BlinkSequence.h @@ -0,0 +1,15 @@ +#ifndef IVE_BLINKSEQUENCE +#define IVE_BLINKSEQUENCE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class BlinkSequence : public osgSim::BlinkSequence, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/ConeSector.cpp b/src/osgPlugins/ive/ConeSector.cpp new file mode 100644 index 000000000..4b3d8fbfb --- /dev/null +++ b/src/osgPlugins/ive/ConeSector.cpp @@ -0,0 +1,43 @@ +/********************************************************************** + * + * FILE: ConeSector.cpp + * + * DESCRIPTION: Read/Write osgSim::ConeSector in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator.exe + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 9.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "ConeSector.h" + +using namespace ive; + +void ConeSector::write(DataOutputStream* out){ + // Write ConeSector's identification. + out->writeInt(IVECONESECTOR); + // Write ConeSector's properties. + out->writeVec3(getAxis()); + out->writeFloat(getAngle()); + out->writeFloat(getFadeAngle()); +} + +void ConeSector::read(DataInputStream* in){ + // Peek on ConeSector's identification. + int id = in->peekInt(); + if(id == IVECONESECTOR){ + // Read ConeSector's identification. + id = in->readInt(); + // Read ConeSector's properties + setAxis(in->readVec3()); + float angle = in->readFloat(); + float fadeangle = in->readFloat();; + setAngle(angle, fadeangle); + } + else{ + throw Exception("ConeSector::read(): Expected ConeSector identification."); + } +} diff --git a/src/osgPlugins/ive/ConeSector.h b/src/osgPlugins/ive/ConeSector.h new file mode 100644 index 000000000..c56e21ba6 --- /dev/null +++ b/src/osgPlugins/ive/ConeSector.h @@ -0,0 +1,15 @@ +#ifndef IVE_CONESECTOR +#define IVE_CONESECTOR 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class ConeSector : public osgSim::ConeSector, 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 9563f117e..3bc24461e 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -34,12 +34,12 @@ #include "Sequence.h" #include "LOD.h" #include "PagedLOD.h" -//#include "ViewPoint.h" #include "PositionAttitudeTransform.h" #include "Transform.h" #include "Switch.h" #include "OccluderNode.h" #include "Impostor.h" +#include "LightPointNode.h" #include "Geometry.h" @@ -604,10 +604,6 @@ osg::Node* DataInputStream::readNode() node = new osg::MatrixTransform(); ((ive::MatrixTransform*)(node))->read(this); } -// else if(nodeTypeID== IVEVIEWPOINT){ -// node = new osgfIVE::ViewPoint(); -// ((ive::ViewPoint*)(node))->read(this); -// } else if(nodeTypeID== IVEPOSITIONATTITUDETRANSFORM){ node = new osg::PositionAttitudeTransform(); ((ive::PositionAttitudeTransform*)(node))->read(this); @@ -656,11 +652,15 @@ osg::Node* DataInputStream::readNode() node = new osg::Geode(); ((ive::Geode*)(node))->read(this); } + else if(nodeTypeID== IVELIGHTPOINTNODE){ + node = new osgSim::LightPointNode(); + ((ive::LightPointNode*)(node))->read(this); + } else{ throw Exception("Unknown node identification in DataInputStream::readNode()"); } - // and add it to the stateattribute map, + // and add it to the node map, _nodeMap[id] = node; diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index 00506b82c..9d2977e4f 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -1,11 +1,11 @@ /********************************************************************** * - * FILE: DataOutputStream.cpp + * FILE: DataOutputStream.cpp * * DESCRIPTION: Implements methods to write simpel datatypes to an * output stream. * - * CREATED BY: Rune Schmidt Jensen + * CREATED BY: Rune Schmidt Jensen * * HISTORY: Created 11.03.2003 * @@ -36,12 +36,12 @@ #include "Sequence.h" #include "LOD.h" #include "PagedLOD.h" -//#include "ViewPoint.h" #include "PositionAttitudeTransform.h" #include "Transform.h" #include "Switch.h" #include "OccluderNode.h" #include "Impostor.h" +#include "LightPointNode.h" #include "Geometry.h" @@ -491,9 +491,6 @@ void DataOutputStream::writeNode(const osg::Node* node) if(dynamic_cast(node)){ ((ive::MatrixTransform*)(node))->write(this); } -// else if(dynamic_cast(node)){ -// ((ive::ViewPoint*)(node))->write(this); -// } else if(dynamic_cast(node)){ ((ive::PositionAttitudeTransform*)(node))->write(this); } @@ -530,6 +527,9 @@ void DataOutputStream::writeNode(const osg::Node* node) else if(dynamic_cast(node)){ ((ive::Geode*)(node))->write(this); } + else if(dynamic_cast(node)){ + ((ive::LightPointNode*)(node))->write(this); + } else throw Exception("Unknown node in Group::write()"); diff --git a/src/osgPlugins/ive/ElevationSector.cpp b/src/osgPlugins/ive/ElevationSector.cpp new file mode 100644 index 000000000..b60bbb6b6 --- /dev/null +++ b/src/osgPlugins/ive/ElevationSector.cpp @@ -0,0 +1,43 @@ +/********************************************************************** + * + * FILE: ElevationSector.cpp + * + * DESCRIPTION: Read/Write osgSim::ElevationSector in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator.exe + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 9.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "ElevationSector.h" + +using namespace ive; + +void ElevationSector::write(DataOutputStream* out){ + // Write ElevationSector's identification. + out->writeInt(IVEELEVATIONSECTOR); + // Write ElevationSector's properties. + out->writeFloat(getMinElevation()); + out->writeFloat(getMaxElevation()); + out->writeFloat(getFadeAngle()); +} + +void ElevationSector::read(DataInputStream* in){ + // Peek on ElevationSector's identification. + int id = in->peekInt(); + if(id == IVEELEVATIONSECTOR){ + // Read ElevationSector's identification. + id = in->readInt(); + // Read ElevationSector's properties + float minElevation = in->readFloat(); + float maxElevation = in->readFloat(); + float fadeAngle = in->readFloat(); + setElevationRange(minElevation, maxElevation, fadeAngle); + } + else{ + throw Exception("ElevationSector::read(): Expected ElevationSector identification."); + } +} diff --git a/src/osgPlugins/ive/ElevationSector.h b/src/osgPlugins/ive/ElevationSector.h new file mode 100644 index 000000000..af99810e4 --- /dev/null +++ b/src/osgPlugins/ive/ElevationSector.h @@ -0,0 +1,15 @@ +#ifndef IVE_ELEVATIONSECTOR +#define IVE_ELEVATIONSECTOR 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class ElevationSector : public osgSim::ElevationSector, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/GNUmakefile b/src/osgPlugins/ive/GNUmakefile index 24b1bffdb..89ab3b513 100644 --- a/src/osgPlugins/ive/GNUmakefile +++ b/src/osgPlugins/ive/GNUmakefile @@ -47,8 +47,15 @@ CXXFILES =\ TextureCubeMap.cpp\ Transform.cpp\ ReaderWriterIVE.cpp\ + AzimElevationSector.cpp\ + AzimSector.cpp\ + BlinkSequence.cpp\ + ConeSector.cpp\ + ElevationSector.cpp\ + LightPoint.cpp\ + LightPointNode.cpp\ -LIBS += $(OSG_LIBS) $(OTHER_LIBS) +LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS) TARGET_BASENAME = ive include $(TOPDIR)/Make/cygwin_plugin_def diff --git a/src/osgPlugins/ive/LightPoint.cpp b/src/osgPlugins/ive/LightPoint.cpp new file mode 100644 index 000000000..218de0856 --- /dev/null +++ b/src/osgPlugins/ive/LightPoint.cpp @@ -0,0 +1,119 @@ +/********************************************************************** + * + * FILE: LightPoint.cpp + * + * DESCRIPTION: Read/Write osgSim::LightPoint in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 5.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "LightPoint.h" +#include "BlinkSequence.h" +#include "AzimElevationSector.h" +#include "ElevationSector.h" +#include "AzimSector.h" +#include "ConeSector.h" + +using namespace ive; + +void LightPoint::write(DataOutputStream* out){ + // Write LightPoint's identification. + out->writeInt(IVELIGHTPOINT); + + // Write LightPoint's properties. + out->writeBool(_on); + out->writeVec3(_position); + out->writeVec4(_color); + out->writeFloat(_intensity); + out->writeFloat(_radius); + + // Write out osgSim::sector. + out->writeBool(_sector.valid()); + if(_sector.valid()){ + if(dynamic_cast(_sector.get())){ + ((ive::AzimElevationSector*)(_sector.get()))->write(out); + } + else if(dynamic_cast(_sector.get())){ + ((ive::ElevationSector*)(_sector.get()))->write(out); + } + else if(dynamic_cast(_sector.get())){ + ((ive::AzimSector*)(_sector.get()))->write(out); + } + else if(dynamic_cast(_sector.get())){ + ((ive::ConeSector*)(_sector.get()))->write(out); + } + else + throw Exception("Unknown sector in LightPoint::write()"); + } + + // Write out osgSim::BlinkSequence. + out->writeBool(_blinkSequence.valid()); + if(_blinkSequence.valid()){ + ((ive::BlinkSequence*)(_blinkSequence.get()))->write(out); + } + + // Write out blendingMode. + out->writeInt(_blendingMode); +} + +void LightPoint::read(DataInputStream* in){ + // Peek on LightPoint's identification. + int id = in->peekInt(); + if(id == IVELIGHTPOINT){ + // Read LightPoint's identification. + id = in->readInt(); + + // Read LightPoint's properties + _on = in->readBool(); + _position = in->readVec3(); + _color = in->readVec4(); + _intensity = in->readFloat(); + _radius = in->readFloat(); + + // read in osgSim::sector. + if(in->readBool()){ + osgSim::Sector* sector; + int attributeID = in->peekInt(); + if(attributeID == IVEAZIMELEVATIONSECTOR){ + sector = new osgSim::AzimElevationSector(); + ((ive::AzimElevationSector*)(sector))->read(in); + _sector = sector; + } + else if(attributeID == IVEELEVATIONSECTOR){ + sector = new osgSim::ElevationSector(); + ((ive::ElevationSector*)(sector))->read(in); + _sector = sector; + } + else if(attributeID == IVEAZIMSECTOR){ + sector = new osgSim::AzimSector(); + ((ive::AzimSector*)(sector))->read(in); + _sector = sector; + } + else if(attributeID == IVECONESECTOR){ + sector = new osgSim::ConeSector(); + ((ive::ConeSector*)(sector))->read(in); + _sector = sector; + } + else + throw Exception("Unknown sector in LightPoint::read()"); + } + + // Read in osgSim::BlinkSequence. + if(in->readBool()){ + osgSim::BlinkSequence* blinkSequence = new osgSim::BlinkSequence(); + ((ive::BlinkSequence*)(blinkSequence))->read(in); + _blinkSequence = blinkSequence; + } + + // Read in blendingMode. + _blendingMode = (osgSim::LightPoint::BlendingMode)in->readInt(); + } + else{ + throw Exception("LightPoint::read(): Expected LightPoint identification."); + } +} diff --git a/src/osgPlugins/ive/LightPoint.h b/src/osgPlugins/ive/LightPoint.h new file mode 100644 index 000000000..bbfc021de --- /dev/null +++ b/src/osgPlugins/ive/LightPoint.h @@ -0,0 +1,15 @@ +#ifndef IVE_LIGHTPOINT +#define IVE_LIGHTPOINT 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class LightPoint : public osgSim::LightPoint, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/LightPointNode.cpp b/src/osgPlugins/ive/LightPointNode.cpp new file mode 100644 index 000000000..00b8cfc69 --- /dev/null +++ b/src/osgPlugins/ive/LightPointNode.cpp @@ -0,0 +1,74 @@ +/********************************************************************** + * + * FILE: LightPointNode.cpp + * + * DESCRIPTION: Read/Write osgSim::LightPointNode in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator.exe + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 14.9.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "LightPointNode.h" +#include "LightPoint.h" +#include "Node.h" + +using namespace ive; + +void LightPointNode::write(DataOutputStream* out){ + // Write LightPointNode's identification. + out->writeInt(IVELIGHTPOINTNODE); + // If the osgSim class is inherited by any other class we should also write this to file. + osg::Node* node = dynamic_cast(this); + if(node){ + ((ive::Node*)(node))->write(out); + } + else + throw Exception("LightPointNode::write(): Could not cast this osgSim::LightPointNode to an osg::Node."); + + // Write LightPointNode's properties. + out->writeFloat(getMinPixelSize()); + out->writeFloat(getMaxPixelSize()); + out->writeFloat(getMaxVisibleDistance2()); + + // Write out LightPoints. + unsigned int size = getNumLightPoints(); + out->writeUInt(size); + for(unsigned int i=0; iwrite(out); + } +} + +void LightPointNode::read(DataInputStream* in){ + // Peek on LightPointNode's identification. + int id = in->peekInt(); + if(id == IVELIGHTPOINTNODE){ + // Read LightPointNode's identification. + id = in->readInt(); + // If the osgSim class is inherited by any other class we should also read this from file. + osg::Node* node = dynamic_cast(this); + if(node){ + ((ive::Node*)(node))->read(in); + } + else + throw Exception("LightPointNode::read(): Could not cast this osgSim::LightPointNode to an osg::Object."); + // Read LightPointNode's properties + setMinPixelSize(in->readFloat()); + setMaxPixelSize(in->readFloat()); + setMaxVisibleDistance2(in->readFloat()); + + // Read in lightpoints. + unsigned int size = in->readUInt(); + for(unsigned int i=0; iread(in); + addLightPoint(*lightPoint); + } + } + else{ + throw Exception("LightPointNode::read(): Expected LightPointNode identification."); + } +} diff --git a/src/osgPlugins/ive/LightPointNode.h b/src/osgPlugins/ive/LightPointNode.h new file mode 100644 index 000000000..7c5f29b7c --- /dev/null +++ b/src/osgPlugins/ive/LightPointNode.h @@ -0,0 +1,15 @@ +#ifndef IVE_LIGHTPOINTNODE +#define IVE_LIGHTPOINTNODE 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class LightPointNode : public osgSim::LightPointNode, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/PagedLOD.cpp b/src/osgPlugins/ive/PagedLOD.cpp index 6fda87f05..499f4c9ab 100644 --- a/src/osgPlugins/ive/PagedLOD.cpp +++ b/src/osgPlugins/ive/PagedLOD.cpp @@ -1,8 +1,8 @@ /********************************************************************** * - * FILE: LOD.cpp + * FILE: PagedLOD.cpp * - * DESCRIPTION: Read/Write osg::LOD in binary format to disk. + * DESCRIPTION: Read/Write osg::PagedLOD in binary format to disk. * * CREATED BY: Auto generated by iveGenerate * and later modified by Rune Schmidt Jensen. diff --git a/src/osgPlugins/ive/ReadWrite.h b/src/osgPlugins/ive/ReadWrite.h index be99cc8f8..1c04f44f5 100644 --- a/src/osgPlugins/ive/ReadWrite.h +++ b/src/osgPlugins/ive/ReadWrite.h @@ -34,36 +34,43 @@ namespace ive { #define IVEANIMATIONPATHCALLBACK 0x00000051 // State attributes. -#define IVESTATEATTRIBUTE 0x00000100 -#define IVEALPHAFUNC 0x00000101 -#define IVEBLENDFUNC 0x00000102 -#define IVEMATERIAL 0x00000110 -#define IVETEXTURE 0x00000120 -#define IVETEXTURE1D 0x00000121 -#define IVETEXTURE2D 0x00000122 -#define IVETEXTURE3D 0x00000123 -#define IVETEXTURECUBEMAP 0x00000124 -#define IVETEXENV 0x00000125 -#define IVETEXENVCOMBINE 0x00000126 -#define IVETEXGEN 0x00000127 -#define IVECULLFACE 0x00000128 -#define IVEPOLYGONOFFSET 0x00000129 -#define IVESHADEMODEL 0x0000012A -#define IVEPOINT 0x0000012B +#define IVESTATEATTRIBUTE 0x00000100 +#define IVEALPHAFUNC 0x00000101 +#define IVEBLENDFUNC 0x00000102 +#define IVEMATERIAL 0x00000110 +#define IVETEXTURE 0x00000120 +#define IVETEXTURE1D 0x00000121 +#define IVETEXTURE2D 0x00000122 +#define IVETEXTURE3D 0x00000123 +#define IVETEXTURECUBEMAP 0x00000124 +#define IVETEXENV 0x00000125 +#define IVETEXENVCOMBINE 0x00000126 +#define IVETEXGEN 0x00000127 +#define IVECULLFACE 0x00000128 +#define IVEPOLYGONOFFSET 0x00000129 +#define IVESHADEMODEL 0x0000012A +#define IVEPOINT 0x0000012B // Drawables -#define IVEDRAWABLE 0x00001000 -#define IVEGEOMETRY 0x00001001 +#define IVEDRAWABLE 0x00001000 +#define IVEGEOMETRY 0x00001001 // Primitive set -#define IVEPRIMITIVESET 0x00010000 -#define IVEDRAWARRAYS 0x00010001 -#define IVEDRAWARRAYLENGTHS 0x00010002 -#define IVEDRAWELEMENTSUSHORT 0x00010003 -#define IVEDRAWELEMENTSUINT 0x00010004 +#define IVEPRIMITIVESET 0x00010000 +#define IVEDRAWARRAYS 0x00010001 +#define IVEDRAWARRAYLENGTHS 0x00010002 +#define IVEDRAWELEMENTSUSHORT 0x00010003 +#define IVEDRAWELEMENTSUINT 0x00010004 + +// osgSim classes +#define IVEBLINKSEQUENCE 0x00100001 +#define IVEAZIMELEVATIONSECTOR 0x00100002 +#define IVEELEVATIONSECTOR 0x00100003 +#define IVEAZIMSECTOR 0x00100004 +#define IVECONESECTOR 0x00100005 +#define IVELIGHTPOINT 0x00100006 +#define IVELIGHTPOINTNODE 0x00100007 -// Our own classes -#define IVEVIEWPOINT 0x00100001 class ReadWrite{