From bdc7e8b4a97368bf5520e4255404e82fc2c41839 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 11 May 2005 19:34:03 +0000 Subject: [PATCH] From Don Tidrow, "I added some code to assign the archive pointer in TXPnode with the archive that ReaderWriterTXP actually loads. I also added a function in TXPArchive to help in manipulating the lightpoints." --- src/osgPlugins/txp/ReaderWriterTXP.cpp | 12 ++++++------ src/osgPlugins/txp/TXPArchive.h | 2 ++ src/osgPlugins/txp/TXPNode.h | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/osgPlugins/txp/ReaderWriterTXP.cpp b/src/osgPlugins/txp/ReaderWriterTXP.cpp index 8ac256da7..aa97f57fc 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.cpp +++ b/src/osgPlugins/txp/ReaderWriterTXP.cpp @@ -44,7 +44,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterTXP::local_readNode(const std::strin { int id = _archiveId++; archive->setId(id); - getArchive(id,osgDB::getFilePath(fileName)); + txpNode->setArchive(getArchive(id,osgDB::getFilePath(fileName))); } return txpNode.get(); } @@ -217,11 +217,11 @@ TXPArchive *ReaderWriterTXP::getArchive(int id, const std::string& dir) return NULL; } - if (archive->loadTextStyles() == false) - { - ReaderWriterTXPERROR("getArchive()") << "failed to load text styles from archive: \"" << archiveName << "\"" << std::endl; - return NULL; - } + if (archive->loadTextStyles() == false) + { + ReaderWriterTXPERROR("getArchive()") << "failed to load text styles from archive: \"" << archiveName << "\"" << std::endl; + return NULL; + } archive->setId(id); diff --git a/src/osgPlugins/txp/TXPArchive.h b/src/osgPlugins/txp/TXPArchive.h index 83e0a3bf8..0fb6766ee 100644 --- a/src/osgPlugins/txp/TXPArchive.h +++ b/src/osgPlugins/txp/TXPArchive.h @@ -89,6 +89,8 @@ public: // Add light attrib void addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback , const osg::Vec3& attitude); + int getNumLightAttributes() { return _lights.size(); } + // Get light attrib inline DeferredLightAttribute& getLightAttribute(unsigned int i) { diff --git a/src/osgPlugins/txp/TXPNode.h b/src/osgPlugins/txp/TXPNode.h index 25c1dfaad..711d79bb5 100644 --- a/src/osgPlugins/txp/TXPNode.h +++ b/src/osgPlugins/txp/TXPNode.h @@ -66,6 +66,8 @@ public: bool loadArchive(); TXPArchive* getArchive(); + + void setArchive(TXPArchive* archive) { _archive = archive; } protected: @@ -78,7 +80,7 @@ protected: osg::Node* addPagedLODTile(int x, int y, int lod); - std::string _archiveName; + std::string _archiveName; std::string _options; osg::ref_ptr _archive;