root/OpenSceneGraph/trunk/src/osgPlugins/txp/TXPIO.cpp @ 13041

Revision 13041, 2.1 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 <osgDB/Registry>
2#include <osgDB/Input>
3#include <osgDB/Output>
4#include <osgDB/WriteFile>
5#include <osg/ref_ptr>
6#include <iostream>
7
8#include "TXPNode.h"
9
10using namespace osg;
11
12bool TXPNode_readLocalData(osg::Object &obj, osgDB::Input &fr);
13bool TXPNode_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
14
15osgDB::RegisterDotOsgWrapperProxy TXPNode_Proxy
16(
17    new txp::TXPNode,
18    "TXPNode",
19    "Object Node TXPNode",
20    TXPNode_readLocalData,
21    TXPNode_writeLocalData
22);
23
24bool TXPNode_readLocalData(osg::Object &obj, osgDB::Input &fr)
25{
26    txp::TXPNode &txpNode = static_cast<txp::TXPNode &>(obj);
27    bool itrAdvanced = false;
28
29    if (fr.matchSequence("databaseOptions %s"))
30    {
31        txpNode.setOptions(fr[1].getStr());
32        fr += 2;
33        itrAdvanced = true;
34    }
35
36    if (fr.matchSequence("databaseName %s"))
37    {
38        txpNode.setArchiveName(fr[1].getStr());
39
40        //modified by Brad Anderegg on May-27-08
41        //this function now takes the archive to load as a parameter
42        //passing in NULL will have the same effect as before.
43        txpNode.loadArchive(NULL);
44
45        fr += 2;
46        itrAdvanced = true;
47    }
48
49
50    return itrAdvanced;
51}
52
53class Dump2Osg : public osg::NodeVisitor
54{
55public:
56    Dump2Osg( osgDB::Output &fw ) : osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ), _fw( fw )
57    {}
58
59    virtual void apply(osg::Node& node)
60    {
61        _fw.writeObject(node);
62        NodeVisitor::apply(node);
63    }
64    osgDB::Output &_fw;
65
66protected:
67
68    Dump2Osg& operator = (const Dump2Osg&) { return *this; }
69};
70
71
72bool TXPNode_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
73{
74    const txp::TXPNode &txpNode = static_cast<const txp::TXPNode&>(obj);
75
76    if ( !txpNode.getOptions().empty() )
77        fw.indent() << "databaseOptions \"" << txpNode.getOptions() << "\"" << std::endl;
78    if ( !txpNode.getArchiveName().empty() )
79        fw.indent() << "databaseName \"" << txpNode.getArchiveName() << "\"" << std::endl;
80
81    osg::Group* grp = const_cast<osg::Group*>(txpNode.asGroup());
82
83    Dump2Osg wrt(fw);
84    grp->accept(wrt);
85
86    return true;
87}
88
Note: See TracBrowser for help on using the browser.