Robert Osfield wrote:
Hi Leo,
There isn't any OSG mechansim designed to help you determine this, so
you'll have to produce your own metrics by writing a NodeVisitor to
traverse through the scene and collate sizes of objects. This isn't
trivial to do completely.
I wonder if there is another route, perhaps you could implement a
streambuffer than just eats bytes, not writing them to disk, but
counts the bytes as they come in. You'd attach the stream buffer to
an istream as then pass this to the appropriate plugin. Again this
isn't a trivial thing to code, but you'll sure learn more about C++
and OSG in the process :-)
The later technique will be 100% accurate of course, so this is the
route to go. Have a look at the osgDB::Archive implementation in
src/osgDB/Archive.cpp and src/osgPlugins/osga for an example of custom
streambuffer, the .net plugin also has an example.
Robert.
A quick and dirty solution (consumes memory) is to use a stringstream
for that:
you pass the stringstrem to the osg or ive plugin and write the node
like the following snippet (not tested)
t
int GetFileSize(osg::Group *node,std::string fileextension)
{
std::stringstream s;
std::string retstring;
osg::ref_ptr<osgDB::ReaderWriter> writer =
osgDB::Registry::instance()->getReaderWriterForExtension(fileext);
if( !writer.valid() )
{
//setErrNo(OSG_VIEW_ERROR_GET_MATRIX, "
osgDB::getReaderWriterForExtension() failed!", false);
return -1;
}
osgDB::ReaderWriter::WriteResult res = writer->writeObject(*m,s);
if(res.success())
{
return( s.str().length();
}
else
{
//setErrNo(OSG_VIEW_ERROR_GET_MATRIX, "Stream MatrixTransform
failed!", false);
return -1
}
}
the call GetFileSize(mygroup,std::string("osg")) should return the
size of mygroup when written to an osg file.
If you keep retstring, you can save it in the file
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/