1 /**********************************************************************
2  *
3  *    FILE:            AnimationPathCallback.cpp
4  *
5  *    DESCRIPTION:    Read/Write osg::AnimationPathCallback in binary format to disk.
6  *
7  *    CREATED BY:        Auto generated by iveGenerate
8  *                    and later modified by Rune Schmidt Jensen.
9  *
10  *    HISTORY:        Created 25.3.2003
11  *
12  *    Copyright 2003 VR-C
13  **********************************************************************/
14 
15 #include "Exception.h"
16 #include "AnimationPathCallback.h"
17 #include "AnimationPath.h"
18 #include "Object.h"
19 
20 using namespace ive;
21 
write(DataOutputStream * out)22 void AnimationPathCallback::write(DataOutputStream* out){
23     // Write AnimationPathCallback's identification.
24     out->writeInt(IVEANIMATIONPATHCALLBACK);
25     // If the osg class is inherited by any other class we should also write this to file.
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     // Write AnimationPathCallback's properties.
33 
34     out->writeVec3(_pivotPoint);
35     out->writeDouble(_timeOffset);
36     out->writeDouble(_timeMultiplier);
37     out->writeDouble(_firstTime);
38     out->writeDouble(_pauseTime);
39     // Write animationpath if any
40     if(getAnimationPath())
41     {
42         out->writeInt(1); // true we have an animation path.
43         ((ive::AnimationPath*)(getAnimationPath()))->write(out);
44     }
45     else
46     {
47         out->writeInt(0); // false we don't have an animation path.
48     }
49 }
50 
read(DataInputStream * in)51 void AnimationPathCallback::read(DataInputStream* in){
52     // Peek on AnimationPathCallback's identification.
53     int id = in->peekInt();
54     if(id == IVEANIMATIONPATHCALLBACK){
55         // Read AnimationPathCallback's identification.
56         id = in->readInt();
57         // If the osg class is inherited by any other class we should also read this from file.
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         // Read AnimationPathCallback's properties
66         _pivotPoint = in->readVec3();
67         _timeOffset = in->readDouble();
68         _timeMultiplier = in->readDouble();
69         _firstTime = in->readDouble();
70         _pauseTime = in->readDouble();
71         // Read animationpath if any
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 }
83