Fixes for IRIX and Boris Bralo's TerraPage loader.

This commit is contained in:
Robert Osfield
2002-02-08 09:30:02 +00:00
parent 62d8b1e8de
commit 4c5fcd3f61
45 changed files with 11037 additions and 11 deletions

View File

@@ -0,0 +1,93 @@
#include "ReaderWriterTXP.h"
#include "TrPageArchive.h"
#include <osg/Group>
#include <osg/Object>
#include <osg/Node>
#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/FileUtils>
#include <iostream>
using namespace txp;
using namespace osg;
//----------------------------------------------------------------------------
// private class for txp file
class TXPFile
{
public:
TrPageArchive archive;
TXPFile()
{
};
~TXPFile()
{
};
Node* readNode(const string &filename)
{
Group* ret = 0;
// search the SGL data path
string foundname = osgDB::findFile(filename.c_str());
if( !foundname.empty())
{
if (archive.OpenFile(foundname))
{
notify(INFO) << "TXPFile::loadFile(): loading archive: "
<< foundname << std::endl;
archive.LoadMaterials();
archive.LoadModels();
notify(INFO) << "TXPFile::loadFile(): loading geometry"
<< std::endl;
ret = new Group;
ret->addChild(archive.LoadAllTiles());
notify(INFO) << "TXPFile::loadFile(): loaded archive: "
<< foundname << std::endl;
//sgluOutputTree(sceneGraph, cout, 3);
}
else
{
notify(WARN) << "Failed to load archive: " << foundname << std::endl;
}
}
else
{
notify(WARN) <<"sglTrPageGroup::loadFile() failed to find archive: "
<< foundname << std::endl;
}
return ret;
};
Object* readObject(const string &filename)
{
return readNode(filename);
};
};
osgDB::ReaderWriter::ReadResult ReaderWriterTXP::readObject(const std::string& fileName, const osgDB::ReaderWriter::Options*)
{
TXPFile read;
Object* obj = read.readObject(fileName);
if (obj) return obj;
else return ReadResult::FILE_NOT_HANDLED;
}
osgDB::ReaderWriter::ReadResult ReaderWriterTXP::readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*)
{
TXPFile read;
Node* node = read.readNode(fileName);
if (node) return node;
else return ReadResult::FILE_NOT_HANDLED;
}
osgDB::RegisterReaderWriterProxy<ReaderWriterTXP> g_txpReaderWriterProxy;