#include #include #include #include // _fontSize static bool checkFontSize( const osgText::TextBase& text ) { return true; } static bool readFontSize( osgDB::InputStream& is, osgText::TextBase& text ) { unsigned int width, height; is >> width >> height; text.setFontResolution( width, height ); return true; } static bool writeFontSize( osgDB::OutputStream& os, const osgText::TextBase& text ) { os << text.getFontWidth() << text.getFontHeight() << std::endl; return true; } // _characterHeight, _characterAspectRatio static bool checkCharacterSize( const osgText::TextBase& text ) { return true; } static bool readCharacterSize( osgDB::InputStream& is, osgText::TextBase& text ) { float height, aspectRatio; is >> height >> aspectRatio; text.setCharacterSize( height, aspectRatio ); return true; } static bool writeCharacterSize( osgDB::OutputStream& os, const osgText::TextBase& text ) { os << text.getCharacterHeight() << text.getCharacterAspectRatio() << std::endl; return true; } // _text static bool checkText( const osgText::TextBase& text ) { return text.getText().size()>0; } static bool readText( osgDB::InputStream& is, osgText::TextBase& text ) { bool isACString; is >> isACString; if ( isACString ) { std::string acString; is.readWrappedString( acString ); text.setText( acString ); } else { osg::UIntArray* array = dynamic_cast( is.readArray() ); if ( array ) { osgText::String string; string; for ( osg::UIntArray::iterator itr=array->begin(); itr!=array->end(); ++itr ) { string.push_back( *itr ); } text.setText( string ); } } return true; } static bool writeText( osgDB::OutputStream& os, const osgText::TextBase& text ) { bool isACString = true; const osgText::String& string = text.getText(); for ( osgText::String::const_iterator itr=string.begin(); itr!=string.end(); ++itr ) { if ( *itr==0 || *itr>256 ) { isACString = false; break; } } os << isACString; if ( isACString ) { std::string acString; for ( osgText::String::const_iterator itr=string.begin(); itr!=string.end(); ++itr ) { acString += (char)(*itr); } os.writeWrappedString( acString ); os << std::endl; } else { osg::ref_ptr array = new osg::UIntArray( string.begin(), string.end() ); os << array.get(); } return true; } // _drawMode static bool checkDrawMode( const osgText::TextBase& text ) { return text.getDrawMode()!=osgText::TextBase::TEXT; } static bool readDrawMode( osgDB::InputStream& is, osgText::TextBase& text ) { unsigned int mask = osgText::TextBase::TEXT; if ( is.isBinary() ) is >> mask; else { std::string maskSetString; is >> maskSetString; osgDB::StringList maskList; osgDB::split( maskSetString, maskList, '|' ); for ( unsigned int i=0; i