Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added explict handling of osg::Image, osg::HeightField, osg::Shader a…

…nd osg::Node when doing writes to the archive.
  • Loading branch information...
commit 3ed09cd6aedf2894ab9937a45ae610906beaf286 1 parent a219edf
Robert OSFIELD authored
View
10 applications/osgarchive/osgarchive.cpp
@@ -139,7 +139,15 @@ int main( int argc, char **argv )
if (obj.valid())
{
std::cout<<" write to archive "<<*itr<<std::endl;
- archive->writeObject(*obj, *itr);
+ osg::Image* image = dynamic_cast<osg::Image*>(obj.get());
+ osg::HeightField* hf = dynamic_cast<osg::HeightField*>(obj.get());
+ osg::Node* node = dynamic_cast<osg::Node*>(obj.get());
+ osg::Shader* shader = dynamic_cast<osg::Shader*>(obj.get());
+ if (image) archive->writeImage(*image, *itr);
+ else if (hf) archive->writeHeightField(*hf, *itr);
+ else if (node) archive->writeNode(*node, *itr);
+ else if (shader) archive->writeShader(*shader, *itr);
+ else archive->writeObject(*obj, *itr);
}
}
}
View
12 src/osgPlugins/osga/OSGA_Archive.cpp
@@ -753,7 +753,7 @@ struct OSGA_Archive::WriteImageFunctor : public OSGA_Archive::WriteFunctor
_object(object) {}
const osg::Image& _object;
- virtual ReaderWriter::WriteResult doWrite(ReaderWriter& rw, std::ostream& output) const { return rw.writeImage(_object, output, _options); }
+ virtual ReaderWriter::WriteResult doWrite(ReaderWriter& rw, std::ostream& output) const { OSG_NOTICE<<"doWrite() rw.writeImage(), "<<std::endl; return rw.writeImage(_object, output, _options); }
};
struct OSGA_Archive::WriteHeightFieldFunctor : public OSGA_Archive::WriteFunctor
@@ -812,7 +812,15 @@ ReaderWriter::WriteResult OSGA_Archive::write(const WriteFunctor& writeFunctor)
pos_type final_position = ARCHIVE_POS( _output.tellp() );
size_type size = size_type( final_position-position );
- if (result.success()) addFileReference(position, size, writeFunctor._filename);
+ if (result.success())
+ {
+ OSG_INFO<<"Adding file "<<writeFunctor._filename<<" reference to archive."<<std::endl;
+ addFileReference(position, size, writeFunctor._filename);
+ }
+ else
+ {
+ OSG_INFO<<"writeFunctor unsuccessful."<<std::endl;
+ }
return result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.