~ubuntu-branches/debian/experimental/openscenegraph/experimental

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgWrappers/deprecated-dotosg/osg/Node.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Luaces
  • Date: 2011-01-29 11:36:29 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110129113629-qisrm2kdqlurc7t3
Tags: 2.9.11-1
* Removed bug-555869-ftbfs_with_binutils_gold.dpatch since upstream has
  already taken care of the issue.
* Removed bug-528229.dpatch since the pkgconfig files are now also split
  in upstream.
* Removed explicit dependency on GLU.
* Upstream no longer includes osgIntrospection (Closes: #592420).
* Disabled zip plugin as its implementation stores an embedded copy of
  zlib.
* Enabled Qt support. Thanks James Goppert.
* Enabled SVG and PDF plugins. Thanks James Goppert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "osg/Node"
 
2
#include "osg/io_utils"
 
3
 
 
4
#include "osgDB/Registry"
 
5
#include "osgDB/Input"
 
6
#include "osgDB/Output"
 
7
 
 
8
using namespace osg;
 
9
using namespace osgDB;
 
10
using namespace std;
 
11
 
 
12
// forward declare functions to use later.
 
13
bool Node_readLocalData(Object& obj, Input& fr);
 
14
bool Node_writeLocalData(const Object& obj, Output& fw);
 
15
 
 
16
// register the read and write functions with the osgDB::Registry.
 
17
REGISTER_DOTOSGWRAPPER(Node)
 
18
(
 
19
    new osg::Node,
 
20
    "Node",
 
21
    "Object Node",
 
22
    &Node_readLocalData,
 
23
    &Node_writeLocalData
 
24
);
 
25
 
 
26
bool Node_readLocalData(Object& obj, Input& fr)
 
27
{
 
28
    bool iteratorAdvanced = false;
 
29
 
 
30
    Node& node = static_cast<Node&>(obj);
 
31
 
 
32
    unsigned int mask = node.getNodeMask();
 
33
    if (fr[0].matchWord("nodeMask") && fr[1].getUInt(mask))
 
34
    {
 
35
        node.setNodeMask(mask);
 
36
        fr+=2;
 
37
        iteratorAdvanced = true;
 
38
    }
 
39
 
 
40
    if (fr[0].matchWord("cullingActive"))
 
41
    {
 
42
        if (fr[1].matchWord("FALSE"))
 
43
        {
 
44
            node.setCullingActive(false);
 
45
            iteratorAdvanced = true;
 
46
            fr+=2;
 
47
        }
 
48
        else if (fr[1].matchWord("TRUE"))
 
49
        {
 
50
            node.setCullingActive(true);
 
51
            iteratorAdvanced = true;
 
52
            fr+=2;
 
53
        }
 
54
    }
 
55
 
 
56
    while (fr.matchSequence("description {"))
 
57
    {
 
58
        int entry = fr[0].getNoNestedBrackets();
 
59
        fr += 2;
 
60
 
 
61
        while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
 
62
        {
 
63
            if (fr[0].getStr()) node.addDescription(std::string(fr[0].getStr()));
 
64
            ++fr;
 
65
        }
 
66
        iteratorAdvanced = true;
 
67
 
 
68
    }
 
69
 
 
70
    while (fr.matchSequence("description %s"))
 
71
    {
 
72
        if (fr[1].getStr()) node.addDescription(fr[1].getStr());
 
73
        fr+=2;
 
74
        iteratorAdvanced = true;
 
75
    }
 
76
 
 
77
    static ref_ptr<StateSet> s_drawstate = new osg::StateSet;
 
78
    if (StateSet* readState = static_cast<StateSet*>(fr.readObjectOfType(*s_drawstate)))
 
79
    {
 
80
        node.setStateSet(readState);
 
81
        iteratorAdvanced = true;
 
82
    }
 
83
 
 
84
 
 
85
    static ref_ptr<NodeCallback> s_nodecallback = new osg::NodeCallback;
 
86
    while (fr.matchSequence("UpdateCallback {"))
 
87
    {
 
88
        int entry = fr[0].getNoNestedBrackets();
 
89
        fr += 2;
 
90
 
 
91
        while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
 
92
        {
 
93
            NodeCallback* nodecallback = dynamic_cast<NodeCallback*>(fr.readObjectOfType(*s_nodecallback));
 
94
            if (nodecallback) {
 
95
                if (node.getUpdateCallback() == NULL) {
 
96
                    node.setUpdateCallback(nodecallback);
 
97
                } else {
 
98
                    node.getUpdateCallback()->addNestedCallback(nodecallback);
 
99
                }
 
100
            }
 
101
            else ++fr;
 
102
        }
 
103
        iteratorAdvanced = true;
 
104
 
 
105
    }
 
106
 
 
107
    while (fr.matchSequence("EventCallback {"))
 
108
    {
 
109
        int entry = fr[0].getNoNestedBrackets();
 
110
        fr += 2;
 
111
 
 
112
        while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
 
113
        {
 
114
            NodeCallback* nodecallback = dynamic_cast<NodeCallback*>(fr.readObjectOfType(*s_nodecallback));
 
115
            if (nodecallback) {
 
116
                if (node.getEventCallback() == NULL) {
 
117
                    node.setEventCallback(nodecallback);
 
118
                } else {
 
119
                    node.getEventCallback()->addNestedCallback(nodecallback);
 
120
                }
 
121
            }
 
122
            else ++fr;
 
123
        }
 
124
        iteratorAdvanced = true;
 
125
 
 
126
    }
 
127
 
 
128
    while (fr.matchSequence("CullCallbacks {"))
 
129
    {
 
130
        int entry = fr[0].getNoNestedBrackets();
 
131
        fr += 2;
 
132
 
 
133
        while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
 
134
        {
 
135
            NodeCallback* nodecallback = dynamic_cast<NodeCallback*>(fr.readObjectOfType(*s_nodecallback));
 
136
            if (nodecallback) {
 
137
                if (node.getCullCallback() == NULL) {
 
138
                    node.setCullCallback(nodecallback);
 
139
                } else {
 
140
                    node.getCullCallback()->addNestedCallback(nodecallback);
 
141
                }
 
142
            }
 
143
            else ++fr;
 
144
        }
 
145
        iteratorAdvanced = true;
 
146
 
 
147
    }
 
148
 
 
149
    if (fr.matchSequence("initialBound %f %f %f %f"))
 
150
    {
 
151
        BoundingSphere bs;
 
152
        fr[1].getFloat(bs.center().x());
 
153
        fr[2].getFloat(bs.center().y());
 
154
        fr[3].getFloat(bs.center().z());
 
155
        fr[4].getFloat(bs.radius());
 
156
        node.setInitialBound(bs);
 
157
        fr += 5;
 
158
        iteratorAdvanced = true;
 
159
    }
 
160
 
 
161
    while (fr.matchSequence("ComputeBoundingSphereCallback {"))
 
162
    {
 
163
        int entry = fr[0].getNoNestedBrackets();
 
164
        fr += 2;
 
165
 
 
166
        while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
 
167
        {
 
168
            Node::ComputeBoundingSphereCallback* callback = dynamic_cast<Node::ComputeBoundingSphereCallback*>(fr.readObjectOfType(type_wrapper<Node::ComputeBoundingSphereCallback>()));
 
169
            if (callback) {
 
170
                node.setComputeBoundingSphereCallback(callback);
 
171
            }
 
172
            else ++fr;
 
173
        }
 
174
        iteratorAdvanced = true;
 
175
 
 
176
    }
 
177
 
 
178
    return iteratorAdvanced;
 
179
}
 
180
 
 
181
 
 
182
bool Node_writeLocalData(const Object& obj, Output& fw)
 
183
{
 
184
    const Node& node = static_cast<const Node&>(obj);
 
185
 
 
186
    fw.indent() << "nodeMask 0x" << hex << node.getNodeMask() << dec << std::endl;
 
187
 
 
188
    fw.indent() << "cullingActive ";
 
189
    if (node.getCullingActive()) fw << "TRUE"<< std::endl;
 
190
    else fw << "FALSE"<< std::endl;
 
191
 
 
192
 
 
193
    if (!node.getDescriptions().empty())
 
194
    {
 
195
        if (node.getDescriptions().size()==1)
 
196
        {
 
197
            fw.indent() << "description "<<fw.wrapString(node.getDescriptions().front())<< std::endl;
 
198
        }
 
199
        else
 
200
        {
 
201
            fw.indent() << "description {"<< std::endl;
 
202
            fw.moveIn();
 
203
            for(Node::DescriptionList::const_iterator ditr=node.getDescriptions().begin();
 
204
                ditr!=node.getDescriptions().end();
 
205
                ++ditr)
 
206
            {
 
207
                fw.indent() << fw.wrapString(*ditr)<< std::endl;
 
208
            }
 
209
            fw.moveOut();
 
210
            fw.indent() << "}"<< std::endl;
 
211
        }
 
212
    }
 
213
 
 
214
    if (node.getStateSet())
 
215
    {
 
216
        fw.writeObject(*node.getStateSet());
 
217
    }
 
218
    
 
219
    if (node.getUpdateCallback())
 
220
    {
 
221
        fw.indent() << "UpdateCallbacks {" << std::endl;
 
222
        fw.moveIn();
 
223
        fw.writeObject(*node.getUpdateCallback());
 
224
        fw.moveOut();
 
225
        fw.indent() << "}" << std::endl;
 
226
    }
 
227
 
 
228
    if (node.getEventCallback())
 
229
    {
 
230
        fw.indent() << "EventCallbacks {" << std::endl;
 
231
        fw.moveIn();
 
232
        fw.writeObject(*node.getEventCallback());
 
233
        fw.moveOut();
 
234
        fw.indent() << "}" << std::endl;
 
235
    }
 
236
 
 
237
    if (node.getCullCallback())
 
238
    {
 
239
        fw.indent() << "CullCallbacks {" << std::endl;
 
240
        fw.moveIn();
 
241
        fw.writeObject(*node.getCullCallback());
 
242
        fw.moveOut();
 
243
        fw.indent() << "}" << std::endl;
 
244
    }
 
245
 
 
246
    if (node.getInitialBound().valid())
 
247
    {
 
248
        const osg::BoundingSphere& bs = node.getInitialBound();
 
249
        fw.indent()<<"initialBound "<<bs.center()<<" "<<bs.radius()<<std::endl;
 
250
    }
 
251
    
 
252
    if (node.getComputeBoundingSphereCallback())
 
253
    {
 
254
        fw.indent() << "ComputeBoundingSphereCallback {" << std::endl;
 
255
        fw.moveIn();
 
256
        fw.writeObject(*node.getComputeBoundingSphereCallback());
 
257
        fw.moveOut();
 
258
        fw.indent() << "}" << std::endl;
 
259
    }
 
260
 
 
261
    return true;
 
262
}