#include "MatrixTransform.h" #include "Group.h" #include #include #include #include using namespace osg; using namespace osgDB; class IVEReaderWriter : public ReaderWriter { public: virtual const char* className() const { return "IVE Reader/Writer"; } virtual bool acceptsExtension(const std::string& extension) { return equalCaseInsensitive(extension,"ive"); } virtual ReadResult readNode(const std::string& file, const Options* options) { std::string ext = osgDB::getLowerCaseFileExtension(file); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; std::string fileName = osgDB::findDataFile( file ); if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; // code for setting up the database path so that any paged // databases can be automatically located. osg::ref_ptr local_opt = const_cast(options); if (!local_opt) local_opt = new Options; if (local_opt.valid() && local_opt->getDatabasePath().empty()) { local_opt->setDatabasePath(osgDB::getFilePath(fileName)); } std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary); return readNode(istream,local_opt.get()); } virtual ReadResult readNode(std::istream& fin, const Options* options) { #define IVE_CATCH_EXCEPTIONS #ifdef IVE_CATCH_EXCEPTIONS try{ #endif // Create datainputstream. ive::DataInputStream in(&fin); in.setOptions(options); return in.readNode(); #ifdef IVE_CATCH_EXCEPTIONS } catch(ive::Exception e) { std::cout<<"Error reading file: "<< e.getError()<getOptionString().find("noTexturesInIVEFile")==std::string::npos); osg::notify(osg::DEBUG_INFO) << "ive::DataOutpouStream.setIncludeImageData()=" << out.getIncludeImageData() << std::endl; } out.writeNode(const_cast(&node)); return WriteResult::FILE_SAVED; } catch(ive::Exception e) { osg::notify(osg::WARN)<<"Error writing IVE file: "<< e.getError() << std::endl; } return WriteResult::FILE_NOT_HANDLED; } }; // now register with Registry to instantiate the above // reader/writer. RegisterReaderWriterProxy g_IVEReaderWriterProxy;