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