Added missing DOFTransform and MultiSwitch implementations

This commit is contained in:
Robert Osfield
2003-11-26 08:37:03 +00:00
parent b4776cd947
commit 83320374ab
4 changed files with 197 additions and 0 deletions

View File

@@ -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<osg::Transform*>(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<osg::Transform*>(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.");
}
}

View File

@@ -0,0 +1,15 @@
#ifndef IVE_DOFTRANSFORM
#define IVE_DOFTRANSFORM 1
#include <osgSim/DOFTransform>
#include "ReadWrite.h"
namespace ive{
class DOFTransform : public osgSim::DOFTransform, public ReadWrite {
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif

View File

@@ -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<osg::Group*>(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;s<switchset.size();++s)
{
// Write childrens value.
for(unsigned int i=0; i<getNumChildren();i++)
out->writeBool(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<osg::Group*>(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;s<numSwitchSets;++s)
{
// Read childrens value.
for(unsigned int i=0; i<getNumChildren();i++)
setValue(s, i, in->readBool());
}
}
else{
throw Exception("Switch::read(): Expected Switch identification.");
}
}

View File

@@ -0,0 +1,15 @@
#ifndef IVE_MULTISWITCH
#define IVE_MULTISWITCH 1
#include <osgSim/MultiSwitch>
#include "ReadWrite.h"
namespace ive{
class MultiSwitch : public osgSim::MultiSwitch, public ReadWrite {
public:
void write(DataOutputStream* out);
void read(DataInputStream* in);
};
}
#endif