Пример #1
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<osg::UIntArray*>(is.readArray());
        if (array)
        {
            osgText::String string;

            for (osg::UIntArray::iterator itr = array->begin(); itr != array->end(); ++itr)
            {
                string.push_back(*itr);
            }

            text.setText(string);
        }
    }

    return true;
}
Пример #2
0
static bool readInfluenceMap( osgDB::InputStream& is, osgAnimation::RigGeometry& geom )
{
    osg::ref_ptr<osgAnimation::VertexInfluenceMap> map = new osgAnimation::VertexInfluenceMap;
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        std::string name;
        unsigned int viSize = 0;
        is >> is.PROPERTY("VertexInfluence");
        is.readWrappedString(name);
        viSize = is.readSize(); is >> is.BEGIN_BRACKET;

        osgAnimation::VertexInfluence vi;
        vi.setName( name );
        vi.reserve( viSize );
        for ( unsigned int j=0; j<viSize; ++j )
        {
            int index = 0;
            float weight = 0.0f;
            is >> index >> weight;
            vi.push_back( osgAnimation::VertexIndexWeight(index, weight) );
        }
        (*map)[name] = vi;
        is >> is.END_BRACKET;
    }
    is >> is.END_BRACKET;

    if ( !map->empty() ) geom.setInfluenceMap( map.get() );
    return true;
}
Пример #3
0
//------------------------------------------------------------------------------
static bool readModules( osgDB::InputStream& is, osgCuda::Computation& computation )
{
    unsigned int numMods = 0;
    is >> numMods >> osgDB::BEGIN_BRACKET;

    for( unsigned int i=0; i<numMods; ++i )
    {
        std::string moduleLibraryName;
        is.readWrappedString( moduleLibraryName );
        moduleLibraryName = osgCuda::trim( moduleLibraryName );

        if( !osgCompute::Module::existsModule(moduleLibraryName) )
        {
            osg::notify(osg::WARN)
                    <<" osgCuda_Computation::readModules(): cannot find module library "
                    << moduleLibraryName << "." << std::endl;

            continue;
        }

        osgCompute::Module* module = osgCompute::Module::loadModule( moduleLibraryName );
        if( module != NULL )
        {
            computation.addModule( *module );
        }
    }

    is >> osgDB::END_BRACKET;
    return true;
}
Пример #4
0
static bool readFont(osgDB::InputStream &is, osgText::TextBase &text)
{
    std::string fontName; is.readWrappedString(fontName);

    text.setFont(osgText::readFontFile(fontName));
    return true;
}
Пример #5
0
static bool readFileNames( osgDB::InputStream& is, osg::ImageSequence& image )
{
    unsigned int files = 0; is >> files >> is.BEGIN_BRACKET;
    if (is.getOptions()) image.setReadOptions(new osgDB::Options(*is.getOptions()));
    for ( unsigned int i=0; i<files; ++i )
    {
        std::string filename; is.readWrappedString( filename );
        image.addImageFile( filename );
    }
    is >> is.END_BRACKET;
    return true;
}
Пример #6
0
static bool readFileNames( osgDB::InputStream& is, osg::ProxyNode& node )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        std::string value;
        is.readWrappedString( value );
        node.setFileName( i, value );
    }
    is >> is.END_BRACKET;
    return true;
}
Пример #7
0
static bool readShaderSource( osgDB::InputStream& is, osg::Shader& shader )
{
    std::string code;
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        std::string line;
        is.readWrappedString( line );
        code.append( line ); code.append( 1, '\n' );
    }
    is >> is.END_BRACKET;
    shader.setShaderSource( code );
    return true;
}
Пример #8
0
static bool readLayers( osgDB::InputStream& is, osgTerrain::CompositeLayer& layer )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        std::string type;
        is >> type;
        if ( type=="Object" )
        {
            osgTerrain::Layer* child = dynamic_cast<osgTerrain::Layer*>( is.readObject() );
            if ( child ) layer.addLayer( child );
        }
        else if ( type=="File" )
        {
            std::string compoundname;
            is.readWrappedString( compoundname );
            layer.addLayer( compoundname );
        }
    }
    is >> is.END_BRACKET;
    return true;
}
Пример #9
0
static bool readLightingMap( osgDB::InputStream& is, osgFX::AnisotropicLighting& effect )
{
    std::string fileName; is.readWrappedString( fileName );
    effect.setLightingMap( osgDB::readImageFile(fileName) );
    return true;
}