root/OpenSceneGraph/trunk/src/osgPlugins/ive/DOFTransform.cpp @ 13041

Revision 13041, 3.2 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            DOFTransform.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::DOFTransform in binary format to disk.
6 *
7 *    CREATED BY:        Copied from file auto generated by iveGenerate
8 *                    and modified by Sondra Iverson.
9 *
10 *    HISTORY:        Created 21.11.2003
11 *
12 **********************************************************************/
13
14#include "Exception.h"
15#include "DOFTransform.h"
16#include "Transform.h"
17
18using namespace ive;
19
20void DOFTransform::write(DataOutputStream* out){
21    // Write DOFTransform's identification.
22    out->writeInt(IVEDOFTRANSFORM);
23    // If the osg class is inherited by any other class we should also write this to file.
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    // Write DOFTransform's properties.
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
58void DOFTransform::read(DataInputStream* in){
59    // Peek on DOFTransform's identification.
60    int id = in->peekInt();
61    if(id == IVEDOFTRANSFORM){
62        // Read DOFTransform's identification.
63        id = in->readInt();
64        // If the osg class is inherited by any other class we should also read this from file.
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        // Read DOFTransform's properties
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}
Note: See TracBrowser for help on using the browser.