1 #include <osg/MatrixTransform>
2 
3 #include <osgDB/Registry>
4 #include <osgDB/Input>
5 #include <osgDB/Output>
6 
7 #include "Matrix.h"
8 
9 using namespace osg;
10 using namespace osgDB;
11 
12 // forward declare functions to use later.
13 bool MatrixTransform_readLocalData(Object& obj, Input& fr);
14 bool MatrixTransform_writeLocalData(const Object& obj, Output& fw);
15 
16 // register the read and write functions with the osgDB::Registry.
17 REGISTER_DOTOSGWRAPPER(MatrixTransform)
18 (
19     new osg::MatrixTransform,
20     "MatrixTransform",
21     "Object Node Transform MatrixTransform Group",
22     &MatrixTransform_readLocalData,
23     &MatrixTransform_writeLocalData,
24     DotOsgWrapper::READ_AND_WRITE
25 );
26 
27 // register old style 'DCS' read and write functions with the osgDB::Registry.
28 REGISTER_DOTOSGWRAPPER(DCS)
29 (
30     new osg::MatrixTransform,
31     "DCS",
32     "Object Node Group DCS",
33     &MatrixTransform_readLocalData,
34     NULL,
35     DotOsgWrapper::READ_ONLY
36 );
37 
MatrixTransform_readLocalData(Object & obj,Input & fr)38 bool MatrixTransform_readLocalData(Object& obj, Input& fr)
39 {
40     bool iteratorAdvanced = false;
41 
42     MatrixTransform& transform = static_cast<MatrixTransform&>(obj);
43 
44     if (fr[0].matchWord("Type"))
45     {
46         if (fr[1].matchWord("DYNAMIC"))
47         {
48             transform.setDataVariance(osg::Object::DYNAMIC);
49             fr +=2 ;
50             iteratorAdvanced = true;
51         }
52         else if (fr[1].matchWord("STATIC"))
53         {
54             transform.setDataVariance(osg::Object::STATIC);
55             fr +=2 ;
56             iteratorAdvanced = true;
57         }
58 
59     }
60 
61     Matrix matrix;
62     if (readMatrix(matrix,fr))
63     {
64         transform.setMatrix(matrix);
65         iteratorAdvanced = true;
66     }
67 
68     return iteratorAdvanced;
69 }
70 
71 
MatrixTransform_writeLocalData(const Object & obj,Output & fw)72 bool MatrixTransform_writeLocalData(const Object& obj, Output& fw)
73 {
74     const MatrixTransform& transform = static_cast<const MatrixTransform&>(obj);
75 
76     writeMatrix(transform.getMatrix(),fw);
77 
78     return true;
79 }
80