| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "Exception.h" |
|---|
| 16 | #include "AnimationPathCallback.h" |
|---|
| 17 | #include "AnimationPath.h" |
|---|
| 18 | #include "Object.h" |
|---|
| 19 | |
|---|
| 20 | using namespace ive; |
|---|
| 21 | |
|---|
| 22 | void AnimationPathCallback::write(DataOutputStream* out){ |
|---|
| 23 | |
|---|
| 24 | out->writeInt(IVEANIMATIONPATHCALLBACK); |
|---|
| 25 | |
|---|
| 26 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 27 | if(obj){ |
|---|
| 28 | ((ive::Object*)(obj))->write(out); |
|---|
| 29 | } |
|---|
| 30 | else |
|---|
| 31 | out_THROW_EXCEPTION("AnimationPathCallback::write(): Could not cast this osg::AnimationPathCallback to an osg::Object."); |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | out->writeVec3(_pivotPoint); |
|---|
| 35 | out->writeDouble(_timeOffset); |
|---|
| 36 | out->writeDouble(_timeMultiplier); |
|---|
| 37 | out->writeDouble(_firstTime); |
|---|
| 38 | out->writeDouble(_pauseTime); |
|---|
| 39 | |
|---|
| 40 | if(getAnimationPath()) |
|---|
| 41 | { |
|---|
| 42 | out->writeInt(1); |
|---|
| 43 | ((ive::AnimationPath*)(getAnimationPath()))->write(out); |
|---|
| 44 | } |
|---|
| 45 | else |
|---|
| 46 | { |
|---|
| 47 | out->writeInt(0); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | void AnimationPathCallback::read(DataInputStream* in){ |
|---|
| 52 | |
|---|
| 53 | int id = in->peekInt(); |
|---|
| 54 | if(id == IVEANIMATIONPATHCALLBACK){ |
|---|
| 55 | |
|---|
| 56 | id = in->readInt(); |
|---|
| 57 | |
|---|
| 58 | osg::Object* obj = dynamic_cast<osg::Object*>(this); |
|---|
| 59 | if(obj){ |
|---|
| 60 | ((ive::Object*)(obj))->read(in); |
|---|
| 61 | } |
|---|
| 62 | else |
|---|
| 63 | in_THROW_EXCEPTION("AnimationPathCallback::read(): Could not cast this osg::AnimationPathCallback to an osg::Object."); |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | _pivotPoint = in->readVec3(); |
|---|
| 67 | _timeOffset = in->readDouble(); |
|---|
| 68 | _timeMultiplier = in->readDouble(); |
|---|
| 69 | _firstTime = in->readDouble(); |
|---|
| 70 | _pauseTime = in->readDouble(); |
|---|
| 71 | |
|---|
| 72 | if(in->readInt()) |
|---|
| 73 | { |
|---|
| 74 | osg::AnimationPath* path = new osg::AnimationPath(); |
|---|
| 75 | ((ive::AnimationPath*)(path))->read(in); |
|---|
| 76 | setAnimationPath(path); |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | else{ |
|---|
| 80 | in_THROW_EXCEPTION("AnimationPathCallback::read(): Expected AnimationPathCallback identification."); |
|---|
| 81 | } |
|---|
| 82 | } |
|---|