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

Revision 13041, 1.4 kB (checked in by robert, 3 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/Geode"
2
3#include "osgDB/Registry"
4#include "osgDB/Input"
5#include "osgDB/Output"
6
7using namespace osg;
8using namespace osgDB;
9
10// forward declare functions to use later.
11bool Geode_readLocalData(Object& obj, Input& fr);
12bool Geode_writeLocalData(const Object& obj, Output& fw);
13
14// register the read and write functions with the osgDB::Registry.
15REGISTER_DOTOSGWRAPPER(Geode)
16(
17    new osg::Geode,
18    "Geode",
19    "Object Node Geode",
20    &Geode_readLocalData,
21    &Geode_writeLocalData
22);
23
24bool Geode_readLocalData(Object& obj, Input& fr)
25{
26    bool iteratorAdvanced = false;
27
28    Geode& geode = static_cast<Geode&>(obj);
29
30    int num_drawables;
31    if ((fr[0].matchWord("num_drawables") || fr[0].matchWord("num_geosets")) &&
32        fr[1].getInt(num_drawables))
33    {
34        // could allocate space for children here...
35        fr+=2;
36        iteratorAdvanced = true;
37    }
38
39    Drawable* drawable = NULL;
40    while((drawable=fr.readDrawable())!=NULL)
41    {
42        geode.addDrawable(drawable);
43        iteratorAdvanced = true;
44    }
45
46    return iteratorAdvanced;
47}
48
49
50bool Geode_writeLocalData(const osg::Object& obj, Output& fw)
51{
52    const Geode& geode = static_cast<const Geode&>(obj);
53
54    fw.indent() << "num_drawables " << geode.getNumDrawables() << std::endl;
55
56    for(unsigned int i=0;i<geode.getNumDrawables();++i)
57    {
58        fw.writeObject(*geode.getDrawable(i));
59    }
60
61    return true;
62}
Note: See TracBrowser for help on using the browser.