| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include "Exception.h" |
|---|
| 15 | #include "DOFTransform.h" |
|---|
| 16 | #include "Transform.h" |
|---|
| 17 | |
|---|
| 18 | using namespace ive; |
|---|
| 19 | |
|---|
| 20 | void DOFTransform::write(DataOutputStream* out){ |
|---|
| 21 | |
|---|
| 22 | out->writeInt(IVEDOFTRANSFORM); |
|---|
| 23 | |
|---|
| 24 | osg::Transform* trans = dynamic_cast<osg::Transform*>(this); |
|---|
| 25 | if(trans){ |
|---|
| 26 | ((ive::Transform*)(trans))->write(out); |
|---|
| 27 | } |
|---|
| 28 | else |
|---|
| 29 | out_THROW_EXCEPTION("DOFTransform::write(): Could not cast this osg::DOFTransform to an osg::Transform."); |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | out->writeMatrixd(getPutMatrix()); |
|---|
| 33 | |
|---|
| 34 | out->writeVec3(getMinHPR()); |
|---|
| 35 | out->writeVec3(getMaxHPR()); |
|---|
| 36 | out->writeVec3(getIncrementHPR()); |
|---|
| 37 | out->writeVec3(getCurrentHPR()); |
|---|
| 38 | |
|---|
| 39 | out->writeVec3(getMinTranslate()); |
|---|
| 40 | out->writeVec3(getMaxTranslate()); |
|---|
| 41 | out->writeVec3(getIncrementTranslate()); |
|---|
| 42 | out->writeVec3(getCurrentTranslate()); |
|---|
| 43 | |
|---|
| 44 | out->writeVec3(getMinScale()); |
|---|
| 45 | out->writeVec3(getMaxScale()); |
|---|
| 46 | out->writeVec3(getIncrementScale()); |
|---|
| 47 | out->writeVec3(getCurrentScale()); |
|---|
| 48 | |
|---|
| 49 | if ( out->getVersion() >= VERSION_0011 ) |
|---|
| 50 | { |
|---|
| 51 | out->writeChar((char)(getHPRMultOrder())); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | out->writeULong(getLimitationFlags()); |
|---|
| 55 | out->writeBool(getAnimationOn()); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | void DOFTransform::read(DataInputStream* in){ |
|---|
| 59 | |
|---|
| 60 | int id = in->peekInt(); |
|---|
| 61 | if(id == IVEDOFTRANSFORM){ |
|---|
| 62 | |
|---|
| 63 | id = in->readInt(); |
|---|
| 64 | |
|---|
| 65 | osg::Transform* trans = dynamic_cast<osg::Transform*>(this); |
|---|
| 66 | if(trans){ |
|---|
| 67 | ((ive::Transform*)(trans))->read(in); |
|---|
| 68 | } |
|---|
| 69 | else |
|---|
| 70 | in_THROW_EXCEPTION("DOFTransform::read(): Could not cast this osg::DOFTransform to an osg::Transform."); |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | setPutMatrix(in->readMatrixd()); |
|---|
| 74 | setInversePutMatrix( osg::Matrixd::inverse( getPutMatrix() ) ); |
|---|
| 75 | |
|---|
| 76 | setMinHPR(in->readVec3()); |
|---|
| 77 | setMaxHPR(in->readVec3()); |
|---|
| 78 | setIncrementHPR(in->readVec3()); |
|---|
| 79 | setCurrentHPR(in->readVec3()); |
|---|
| 80 | |
|---|
| 81 | setMinTranslate(in->readVec3()); |
|---|
| 82 | setMaxTranslate(in->readVec3()); |
|---|
| 83 | setIncrementTranslate(in->readVec3()); |
|---|
| 84 | setCurrentTranslate(in->readVec3()); |
|---|
| 85 | |
|---|
| 86 | setMinScale(in->readVec3()); |
|---|
| 87 | setMaxScale(in->readVec3()); |
|---|
| 88 | setIncrementScale(in->readVec3()); |
|---|
| 89 | setCurrentScale(in->readVec3()); |
|---|
| 90 | |
|---|
| 91 | if ( in->getVersion() >= VERSION_0011 ) |
|---|
| 92 | { |
|---|
| 93 | setHPRMultOrder((MultOrder)(in->readChar())); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | setLimitationFlags(in->readULong()); |
|---|
| 97 | setAnimationOn(in->readBool()); |
|---|
| 98 | } |
|---|
| 99 | else{ |
|---|
| 100 | in_THROW_EXCEPTION("DOFTransform::read(): Expected DOFTransform identification."); |
|---|
| 101 | } |
|---|
| 102 | } |
|---|