root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgAnimation/StackedTransform.cpp @ 13041

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

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/*  -*-c++-*-
2 *  Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
3 *
4 * This library is open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version.  The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * OpenSceneGraph Public License for more details.
13 */
14
15#include <osgAnimation/StackedTranslateElement>
16#include <osgAnimation/StackedMatrixElement>
17#include <osgAnimation/StackedScaleElement>
18#include <osgAnimation/StackedRotateAxisElement>
19#include <osgAnimation/StackedQuaternionElement>
20#include <osgDB/Input>
21#include <osgDB/Output>
22#include <osgDB/Registry>
23#include <osgDB/ReaderWriter>
24#include <osg/io_utils>
25
26#include "Matrix.h"
27
28using namespace osgDB;
29using namespace osg;
30
31bool readStackedTranslateElement(Object& obj, Input& fr)
32{
33    osgAnimation::StackedTranslateElement& element = dynamic_cast<osgAnimation::StackedTranslateElement&>(obj);
34    bool iteratorAdvanced = false;
35    if (fr.matchSequence("translate %f %f %f"))
36    {
37        ++fr;
38        osg::Vec3 translate;
39        fr[0].getFloat(translate.x());
40        fr[1].getFloat(translate.y());
41        fr[2].getFloat(translate.z());
42        element.setTranslate(translate);
43        fr += 3;
44        iteratorAdvanced = true;
45    }
46    return iteratorAdvanced;
47}
48
49bool writeStackedTranslateElement(const Object& obj, Output& fw)
50{
51    const osgAnimation::StackedTranslateElement& element = dynamic_cast<const osgAnimation::StackedTranslateElement&>(obj);
52    fw.indent() << "translate " << element.getTranslate() << std::endl;
53    return true;
54}
55
56RegisterDotOsgWrapperProxy g_StackedTranslateElementProxy
57(
58    new osgAnimation::StackedTranslateElement,
59    "osgAnimation::StackedTranslateElement",
60    "Object osgAnimation::StackedTranslateElement",
61    &readStackedTranslateElement,
62    &writeStackedTranslateElement,
63    DotOsgWrapper::READ_AND_WRITE
64    );
65
66
67bool readStackedScaleElement(Object& obj, Input& fr)
68{
69    osgAnimation::StackedScaleElement& element = dynamic_cast<osgAnimation::StackedScaleElement&>(obj);
70    bool iteratorAdvanced = false;
71    if (fr.matchSequence("scale %f %f %f"))
72    {
73        ++fr;
74        osg::Vec3 scale;
75        fr[0].getFloat(scale.x());
76        fr[1].getFloat(scale.y());
77        fr[2].getFloat(scale.z());
78        element.setScale(scale);
79        fr += 3;
80        iteratorAdvanced = true;
81    }
82    return iteratorAdvanced;
83}
84
85bool writeStackedScaleElement(const Object& obj, Output& fw)
86{
87    const osgAnimation::StackedScaleElement& element = dynamic_cast<const osgAnimation::StackedScaleElement&>(obj);
88    fw.indent() << "scale " << element.getScale() << std::endl;
89    return true;
90}
91
92
93RegisterDotOsgWrapperProxy g_StackedScaleElementProxy
94(
95    new osgAnimation::StackedScaleElement,
96    "osgAnimation::StackedScaleElement",
97    "Object osgAnimation::StackedScaleElement",
98    &readStackedScaleElement,
99    &writeStackedScaleElement,
100    DotOsgWrapper::READ_AND_WRITE
101    );
102
103
104
105
106
107
108
109bool readStackedMatrixElement(Object& obj, Input& fr)
110{
111    osgAnimation::StackedMatrixElement& element = dynamic_cast<osgAnimation::StackedMatrixElement&>(obj);
112    bool iteratorAdvanced = false;
113    if (fr[0].matchWord("Matrix"))
114    {
115        osg::Matrix matrix;
116        matrix.makeIdentity();
117        iteratorAdvanced = readMatrix(matrix, fr);
118        element.setMatrix(matrix);
119    }
120
121    return iteratorAdvanced;
122}
123
124bool writeStackedMatrixElement(const Object& obj, Output& fw)
125{
126    const osgAnimation::StackedMatrixElement& element = dynamic_cast<const osgAnimation::StackedMatrixElement&>(obj);
127    writeMatrix(element.getMatrix(), fw);
128    return true;
129}
130
131RegisterDotOsgWrapperProxy g_StackedMatrixElementProxy
132(
133    new osgAnimation::StackedMatrixElement,
134    "osgAnimation::StackedMatrixElement",
135    "Object osgAnimation::StackedMatrixElement",
136    &readStackedMatrixElement,
137    &writeStackedMatrixElement,
138    DotOsgWrapper::READ_AND_WRITE
139    );
140
141
142
143
144bool writeStackedRotateAxisElement(const Object& obj, Output& fw)
145{
146    const osgAnimation::StackedRotateAxisElement& element = dynamic_cast<const osgAnimation::StackedRotateAxisElement&>(obj);
147    fw.indent() << "axis " << element.getAxis() << std::endl;
148    fw.indent() << "angle " << element.getAngle() << std::endl;
149    return true;
150}
151
152bool readStackedRotateAxisElement(Object& obj, Input& fr)
153{
154    osgAnimation::StackedRotateAxisElement& element = dynamic_cast<osgAnimation::StackedRotateAxisElement&>(obj);
155    bool iteratorAdvanced = false;
156    if (fr.matchSequence("axis %f %f %f"))
157    {
158        ++fr;
159        osg::Vec3 axis;
160        fr[0].getFloat(axis.x());
161        fr[1].getFloat(axis.y());
162        fr[2].getFloat(axis.z());
163        element.setAxis(axis);
164        fr += 3;
165        iteratorAdvanced = true;
166    }
167
168    if (fr.matchSequence("angle %f"))
169    {
170        ++fr;
171        double angle = 0;
172        fr[0].getFloat(angle);
173        ++fr;
174        element.setAngle(angle);
175        iteratorAdvanced = true;
176    }
177    return iteratorAdvanced;
178}
179
180RegisterDotOsgWrapperProxy g_StackedRotateAxisElementProxy
181(
182    new osgAnimation::StackedRotateAxisElement,
183    "osgAnimation::StackedRotateAxisElement",
184    "Object osgAnimation::StackedRotateAxisElement",
185    &readStackedRotateAxisElement,
186    &writeStackedRotateAxisElement,
187    DotOsgWrapper::READ_AND_WRITE
188    );
189
190
191
192
193
194bool readStackedQuaternionElement(Object& obj, Input& fr)
195{
196    osgAnimation::StackedQuaternionElement& element = dynamic_cast<osgAnimation::StackedQuaternionElement&>(obj);
197    bool iteratorAdvanced = false;
198    if (fr.matchSequence("quaternion %f %f %f %f"))
199    {
200        ++fr;
201        osg::Quat quaternion;
202        fr[0].getFloat(quaternion[0]);
203        fr[1].getFloat(quaternion[1]);
204        fr[2].getFloat(quaternion[2]);
205        fr[3].getFloat(quaternion[3]);
206        element.setQuaternion(quaternion);
207        fr += 4;
208        iteratorAdvanced = true;
209    }
210    return iteratorAdvanced;
211}
212
213bool writeStackedQuaternionElement(const Object& obj, Output& fw)
214{
215    const osgAnimation::StackedQuaternionElement& element = dynamic_cast<const osgAnimation::StackedQuaternionElement&>(obj);
216    fw.indent() << "quaternion " << element.getQuaternion() << std::endl;
217    return true;
218}
219
220RegisterDotOsgWrapperProxy g_StackedQuaternionElementProxy
221(
222    new osgAnimation::StackedQuaternionElement,
223    "osgAnimation::StackedQuaternionElement",
224    "Object osgAnimation::StackedQuaternionElement",
225    &readStackedQuaternionElement,
226    &writeStackedQuaternionElement,
227    DotOsgWrapper::READ_AND_WRITE
228    );
Note: See TracBrowser for help on using the browser.