From Joakim Simonsson, DOFTransform multiplication order support added to .ive format.

With tweak from Robert Osfield to wrap new read and write with a new version number
     to allow old files contain DOFTransforms to continue to work.
This commit is contained in:
Robert Osfield
2005-05-18 19:04:35 +00:00
parent 2ad67b1727
commit a83f7a245d
2 changed files with 76 additions and 64 deletions

View File

@@ -1,13 +1,13 @@
/**********************************************************************
*
* FILE: DOFTransform.cpp
* FILE: DOFTransform.cpp
*
* DESCRIPTION: Read/Write osg::DOFTransform in binary format to disk.
* DESCRIPTION: Read/Write osg::DOFTransform in binary format to disk.
*
* CREATED BY: Copied from file auto generated by iveGenerate
* and modified by Sondra Iverson.
* CREATED BY: Copied from file auto generated by iveGenerate
* and modified by Sondra Iverson.
*
* HISTORY: Created 21.11.2003
* HISTORY: Created 21.11.2003
*
**********************************************************************/
@@ -18,74 +18,85 @@
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 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->writeMatrixd(getPutMatrix());
// Write DOFTransform's properties.
out->writeMatrixd(getPutMatrix());
out->writeVec3(getMinHPR());
out->writeVec3(getMaxHPR());
out->writeVec3(getIncrementHPR());
out->writeVec3(getCurrentHPR());
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(getMinTranslate());
out->writeVec3(getMaxTranslate());
out->writeVec3(getIncrementTranslate());
out->writeVec3(getCurrentTranslate());
out->writeVec3(getMinScale());
out->writeVec3(getMaxScale());
out->writeVec3(getIncrementScale());
out->writeVec3(getCurrentScale());
out->writeVec3(getMinScale());
out->writeVec3(getMaxScale());
out->writeVec3(getIncrementScale());
out->writeVec3(getCurrentScale());
out->writeULong(getLimitationFlags());
out->writeBool(getAnimationOn());
if ( out->getVersion() >= VERSION_0011 )
{
out->writeChar((char)(getHPRMultOrder()));
}
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->readMatrixd());
setInversePutMatrix( osg::Matrixd::inverse( getPutMatrix() ) );
// 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.");
setMinHPR(in->readVec3());
setMaxHPR(in->readVec3());
setIncrementHPR(in->readVec3());
setCurrentHPR(in->readVec3());
// Read DOFTransform's properties
setPutMatrix(in->readMatrixd());
setInversePutMatrix( osg::Matrixd::inverse( getPutMatrix() ) );
setMinTranslate(in->readVec3());
setMaxTranslate(in->readVec3());
setIncrementTranslate(in->readVec3());
setCurrentTranslate(in->readVec3());
setMinHPR(in->readVec3());
setMaxHPR(in->readVec3());
setIncrementHPR(in->readVec3());
setCurrentHPR(in->readVec3());
setMinScale(in->readVec3());
setMaxScale(in->readVec3());
setIncrementScale(in->readVec3());
setCurrentScale(in->readVec3());
setMinTranslate(in->readVec3());
setMaxTranslate(in->readVec3());
setIncrementTranslate(in->readVec3());
setCurrentTranslate(in->readVec3());
setLimitationFlags(in->readULong());
setAnimationOn(in->readBool());
}
else{
throw Exception("DOFTransform::read(): Expected DOFTransform identification.");
}
setMinScale(in->readVec3());
setMaxScale(in->readVec3());
setIncrementScale(in->readVec3());
setCurrentScale(in->readVec3());
if ( in->getVersion() >= VERSION_0011 )
{
setHPRMultOrder((MultOrder)(in->readChar()));
}
setLimitationFlags(in->readULong());
setAnimationOn(in->readBool());
}
else{
throw Exception("DOFTransform::read(): Expected DOFTransform identification.");
}
}

View File

@@ -19,8 +19,9 @@
#define VERSION_0008 8
#define VERSION_0009 9
#define VERSION_0010 10
#define VERSION_0011 11
#define VERSION VERSION_0010
#define VERSION VERSION_0011
/* The BYTE_SEX tag is used to check the endian