root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/PositionAttitudeTransform.cpp @ 13041

Revision 13041, 2.5 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#include "osg/PositionAttitudeTransform"
2#include <osg/io_utils>
3
4#include "osgDB/Registry"
5#include "osgDB/Input"
6#include "osgDB/Output"
7
8using namespace osg;
9using namespace osgDB;
10
11// forward declare functions to use later.
12bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr);
13bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw);
14
15// register the read and write functions with the osgDB::Registry.
16REGISTER_DOTOSGWRAPPER(PositionAttitudeTransform)
17(
18    new osg::PositionAttitudeTransform,
19    "PositionAttitudeTransform",
20    "Object Node Transform PositionAttitudeTransform Group",
21    &PositionAttitudeTransform_readLocalData,
22    &PositionAttitudeTransform_writeLocalData,
23    DotOsgWrapper::READ_AND_WRITE
24);
25
26bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr)
27{
28    bool iteratorAdvanced = false;
29
30    PositionAttitudeTransform& transform = static_cast<PositionAttitudeTransform&>(obj);
31
32    if (fr.matchSequence("position %f %f %f"))
33    {
34        osg::Vec3d pos;
35        fr[1].getFloat(pos[0]);
36        fr[2].getFloat(pos[1]);
37        fr[3].getFloat(pos[2]);
38
39        transform.setPosition(pos);
40
41        fr += 4;
42        iteratorAdvanced = true;
43    }
44
45    if (fr.matchSequence("attitude %f %f %f %f"))
46    {
47        osg::Quat att;
48        fr[1].getFloat(att[0]);
49        fr[2].getFloat(att[1]);
50        fr[3].getFloat(att[2]);
51        fr[4].getFloat(att[3]);
52
53        transform.setAttitude(att);
54
55        fr += 5;
56        iteratorAdvanced = true;
57    }
58
59    if (fr.matchSequence("scale %f %f %f"))
60    {
61        osg::Vec3d scale;
62        fr[1].getFloat(scale[0]);
63        fr[2].getFloat(scale[1]);
64        fr[3].getFloat(scale[2]);
65
66        transform.setScale(scale);
67
68        fr += 4;
69        iteratorAdvanced = true;
70    }
71
72    if (fr.matchSequence("pivotPoint %f %f %f"))
73    {
74        osg::Vec3d pivot;
75        fr[1].getFloat(pivot[0]);
76        fr[2].getFloat(pivot[1]);
77        fr[3].getFloat(pivot[2]);
78
79        transform.setPivotPoint(pivot);
80
81        fr += 4;
82        iteratorAdvanced = true;
83    }
84
85    return iteratorAdvanced;
86}
87
88
89bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw)
90{
91    const PositionAttitudeTransform& transform = static_cast<const PositionAttitudeTransform&>(obj);
92
93    fw.indent()<<"position "<<transform.getPosition()<<std::endl;
94    fw.indent()<<"attitude "<<transform.getAttitude()<<std::endl;
95    fw.indent()<<"scale "<<transform.getScale()<<std::endl;
96    fw.indent()<<"pivotPoint "<<transform.getPivotPoint()<<std::endl;
97
98
99    return true;
100}
Note: See TracBrowser for help on using the browser.