diff --git a/src/osgPlugins/ive/DOFTransform.cpp b/src/osgPlugins/ive/DOFTransform.cpp new file mode 100644 index 000000000..ccd1a3955 --- /dev/null +++ b/src/osgPlugins/ive/DOFTransform.cpp @@ -0,0 +1,91 @@ +/********************************************************************** + * + * FILE: DOFTransform.cpp + * + * DESCRIPTION: Read/Write osg::DOFTransform in binary format to disk. + * + * CREATED BY: Copied from file auto generated by iveGenerate + * and modified by Sondra Iverson. + * + * HISTORY: Created 21.11.2003 + * + **********************************************************************/ + +#include "Exception.h" +#include "DOFTransform.h" +#include "Transform.h" + +using namespace ive; + +void DOFTransform::write(DataOutputStream* out){ + // Write DOFTransform's identification. + out->writeInt(IVEDOFTRANSFORM); + // If the osg class is inherited by any other class we should also write this to file. + osg::Transform* trans = dynamic_cast(this); + if(trans){ + ((ive::Transform*)(trans))->write(out); + } + else + throw Exception("DOFTransform::write(): Could not cast this osg::DOFTransform to an osg::Transform."); + + // Write DOFTransform's properties. + out->writeMatrix(getPutMatrix()); + + out->writeVec3(getMinHPR()); + out->writeVec3(getMaxHPR()); + out->writeVec3(getIncrementHPR()); + out->writeVec3(getCurrentHPR()); + + out->writeVec3(getMinTranslate()); + out->writeVec3(getMaxTranslate()); + out->writeVec3(getIncrementTranslate()); + out->writeVec3(getCurrentTranslate()); + + out->writeVec3(getMinScale()); + out->writeVec3(getMaxScale()); + out->writeVec3(getIncrementScale()); + out->writeVec3(getCurrentScale()); + + out->writeULong(getLimitationFlags()); + out->writeBool(getAnimationOn()); +} + +void DOFTransform::read(DataInputStream* in){ + // Peek on DOFTransform's identification. + int id = in->peekInt(); + if(id == IVEDOFTRANSFORM){ + // Read DOFTransform's identification. + id = in->readInt(); + // If the osg class is inherited by any other class we should also read this from file. + osg::Transform* trans = dynamic_cast(this); + if(trans){ + ((ive::Transform*)(trans))->read(in); + } + else + throw Exception("DOFTransform::read(): Could not cast this osg::DOFTransform to an osg::Transform."); + // Read DOFTransform's properties + setPutMatrix(in->readMatrix()); + setInversePutMatrix( osg::Matrix::inverse( getPutMatrix() ) ); + + setMinHPR(in->readVec3()); + setMaxHPR(in->readVec3()); + setIncrementHPR(in->readVec3()); + setCurrentHPR(in->readVec3()); + + setMinTranslate(in->readVec3()); + setMaxTranslate(in->readVec3()); + setIncrementTranslate(in->readVec3()); + setCurrentTranslate(in->readVec3()); + + setMinScale(in->readVec3()); + setMaxScale(in->readVec3()); + setIncrementScale(in->readVec3()); + setCurrentScale(in->readVec3()); + + setLimitationFlags(in->readULong()); + setAnimationOn(in->readBool()); + } + else{ + throw Exception("DOFTransform::read(): Expected DOFTransform identification."); + } +} diff --git a/src/osgPlugins/ive/DOFTransform.h b/src/osgPlugins/ive/DOFTransform.h new file mode 100644 index 000000000..57b6d9a35 --- /dev/null +++ b/src/osgPlugins/ive/DOFTransform.h @@ -0,0 +1,15 @@ +#ifndef IVE_DOFTRANSFORM +#define IVE_DOFTRANSFORM 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class DOFTransform : public osgSim::DOFTransform, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif diff --git a/src/osgPlugins/ive/MultiSwitch.cpp b/src/osgPlugins/ive/MultiSwitch.cpp new file mode 100644 index 000000000..efefbae3b --- /dev/null +++ b/src/osgPlugins/ive/MultiSwitch.cpp @@ -0,0 +1,76 @@ +/********************************************************************** + * + * FILE: Switch.cpp + * + * DESCRIPTION: Read/Write osg::Switch in binary format to disk. + * + * CREATED BY: Auto generated by iveGenerator + * and later modified by Rune Schmidt Jensen. + * + * HISTORY: Created 9.4.2003 + * + * Copyright 2003 VR-C + **********************************************************************/ + +#include "Exception.h" +#include "MultiSwitch.h" +#include "Group.h" + +using namespace ive; + +void MultiSwitch::write(DataOutputStream* out){ + // Write Switch's identification. + out->writeInt(IVEMULTISWITCH); + // 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("Switch::write(): Could not cast this osg::Switch to an osg::Group."); + // Write Switch's properties. + + out->writeBool(getNewChildDefaultValue()); + out->writeUInt(getActiveSwitchSet()); + + const osgSim::MultiSwitch::SwitchSetList& switchset = getSwitchSetList(); + out->writeUInt(switchset.size()); + for(unsigned int s=0;swriteBool(getValue(s,i)); + } +} + +void MultiSwitch::read(DataInputStream* in){ + // Peek on Switch's identification. + int id = in->peekInt(); + if(id == IVEMULTISWITCH){ + // Read Switch'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("Switch::read(): Could not cast this osg::Switch to an osg::Group."); + // Read Switch's properties + + setNewChildDefaultValue(in->readBool()); + setActiveSwitchSet(in->readUInt()); + + unsigned int numSwitchSets = in->readUInt(); + + for(unsigned int s=0;sreadBool()); + } + } + else{ + throw Exception("Switch::read(): Expected Switch identification."); + } +} diff --git a/src/osgPlugins/ive/MultiSwitch.h b/src/osgPlugins/ive/MultiSwitch.h new file mode 100644 index 000000000..c1ae42d25 --- /dev/null +++ b/src/osgPlugins/ive/MultiSwitch.h @@ -0,0 +1,15 @@ +#ifndef IVE_MULTISWITCH +#define IVE_MULTISWITCH 1 + +#include +#include "ReadWrite.h" + +namespace ive{ +class MultiSwitch : public osgSim::MultiSwitch, public ReadWrite { +public: + void write(DataOutputStream* out); + void read(DataInputStream* in); +}; +} + +#endif