email comments from Andew Sampson, "I've contacted Terrex, and obtained the 2.2 version of their trpage library. The library included a fork of OSG 0.9.8's txp plugin, modified to load 2.1+ txp DBs. I've done the work of incorporating the changes made to OSG's txp plugin since 0.9.8 into Terrex's fork. The forked version is now up-to-date with the changes made to OSG 0.9.9 and 1.0. Terrex made a lot of changes (especially differences in whitespace), so the diff between the forked version and OSG 1.0's txp plugin is yucky. I did my best, but keep in mind that this is the result of a 4-way merge (kinda... terrex-0.9.8, stock-0.9.8, stock-0.9.9, stock-1.0). I really want to see this forked version merged back into the main OSG branch. The new features offered by this version of the plugin (2.1+ support, variable LOD support, bug fixes) are worth the trouble." -- Don Tidrow then took this code and added his work. -- Robert Osfield then fixed all the warnings that abound in the trpage code base.
82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
#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());
|
|
txpNode.loadArchive();
|
|
|
|
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;
|
|
};
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|