From Wang Rui, osgText serializers and support for PagedLOD+ProxyNode

This commit is contained in:
Robert Osfield
2010-01-29 11:35:09 +00:00
parent 4ae1c275f2
commit 94e3b5a345
8 changed files with 473 additions and 1 deletions

View File

@@ -34,6 +34,49 @@ static bool writeFileNames( osgDB::OutputStream& os, const osg::ProxyNode& node
return true;
}
// _children
static bool checkChildren( const osg::ProxyNode& node )
{
return node.getNumChildren()>0;
}
static bool readChildren( osgDB::InputStream& is, osg::ProxyNode& node )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osg::Node* child = dynamic_cast<osg::Node*>( is.readObject() );
if ( child ) node.addChild( child );
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeChildren( osgDB::OutputStream& os, const osg::ProxyNode& node )
{
unsigned int size=node.getNumFileNames(), dynamicLoadedSize=0;
for ( unsigned int i=0; i<size; ++i )
{
if ( !node.getFileName(i).empty() )
dynamicLoadedSize++;
}
unsigned int realSize = size-dynamicLoadedSize; os << realSize;
if ( realSize>0 )
{
os << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
if ( !node.getFileName(i).empty() ) continue;
if ( i<node.getNumChildren() )
os << node.getChild(i);
}
os << osgDB::END_BRACKET;
}
os << std::endl;
return true;
}
// _userDefinedCenter, _radius
static bool checkUserCenter( const osg::ProxyNode& node )
{
@@ -62,6 +105,7 @@ REGISTER_OBJECT_WRAPPER( ProxyNode,
// Note: osg::Group is not in the list to prevent recording dynamic loaded children
ADD_USER_SERIALIZER( FileNames ); // _filenameList
ADD_USER_SERIALIZER( Children ); // _children (which are not loaded from external)
ADD_STRING_SERIALIZER( DatabasePath, "" ); // _databasePath
BEGIN_ENUM_SERIALIZER( LoadingExternalReferenceMode, LOAD_IMMEDIATELY );