Exemple #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;
}
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;
}
Exemple #3
0
static bool readMask( osgDB::InputStream& is, osg::PolygonStipple& attr )
{
    char mask[128] = {0};
    if ( is.isBinary() )
    {
        unsigned int size; is >> size;
        is.readCharArray( mask, size );
    }
Exemple #4
0
static bool readImages( osgDB::InputStream& is, osg::ImageSequence& image )
{
    unsigned int images = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<images; ++i )
    {
        osg::Image* img = dynamic_cast<osg::Image*>( is.readObject() );
        if ( img ) image.addImage( img );
    }
    is >> is.END_BRACKET;
    return true;
}
static bool readImages( osgDB::InputStream& is, osg::ImageSequence& image )
{
    unsigned int images = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<images; ++i )
    {
        osg::ref_ptr<osg::Image> img = is.readImage();
        if ( img ) image.addImage( img );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #6
0
static bool readAnimations( osgDB::InputStream& is, osgAnimation::AnimationManagerBase& manager )
{
    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgAnimation::Animation* ani = dynamic_cast<osgAnimation::Animation*>( is.readObject() );
        if ( ani ) manager.registerAnimation( ani );
    }
    is >> osgDB::END_BRACKET;
    return true;
}
Exemple #7
0
static bool readShaders( osgDB::InputStream& is, osg::Program& attr )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osg::Shader* shader = dynamic_cast<osg::Shader*>( is.readObject() );
        if ( shader ) attr.addShader( shader );
    }
    is >> is.END_BRACKET;
    return true;
}
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;
}
Exemple #9
0
static bool readLocatorCallbacks( osgDB::InputStream& is, osgVolume::Locator& locator )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgVolume::Locator::LocatorCallback* cb =
            dynamic_cast<osgVolume::Locator::LocatorCallback*>( is.readObject() );
        if ( cb ) locator.addCallback( cb );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #10
0
static bool readStackedTransforms( osgDB::InputStream& is, osgAnimation::UpdateMatrixTransform& obj )
{
    osgAnimation::StackedTransform& transform = obj.getStackedTransforms();
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgAnimation::StackedTransformElement* element =
            dynamic_cast<osgAnimation::StackedTransformElement*>( is.readObject() );
        if ( element ) transform.push_back( element );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #11
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;
}
Exemple #12
0
static bool readFont(osgDB::InputStream &is, osgText::TextBase &text)
{
    std::string fontName; is.readWrappedString(fontName);

    text.setFont(osgText::readFontFile(fontName));
    return true;
}
Exemple #13
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;
}
Exemple #14
0
//------------------------------------------------------------------------------
static bool readResources( osgDB::InputStream& is, osgCuda::Computation& computation )
{
    unsigned int numRes = 0;
    is >> numRes >> osgDB::BEGIN_BRACKET;

    for( unsigned int i=0; i<numRes; ++i )
    {
        osg::Object* newRes = is.readObject();
        if( newRes != NULL )
        {
            osgCompute::GLMemoryAdapter* ioo = dynamic_cast<osgCompute::GLMemoryAdapter*>( newRes );
            if( ioo != NULL )
            {
                computation.addResource( *ioo->getMemory() );
            }
            else
            {
                osgCompute::Resource* curRes = dynamic_cast<osgCompute::Resource*>( newRes );
                if( curRes != NULL ) computation.addResource( *curRes );
            }

        }
    }

    is >> osgDB::END_BRACKET;
    return true;
}
Exemple #15
0
static bool readTransformUpdating( osgDB::InputStream& is, osgManipulator::Dragger& dragger )
{
    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        std::string name; is >> name >> osgDB::BEGIN_BRACKET;
        if ( name=="DraggerTransformCallback" )
        {
            osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>( is.readObject() );
            if ( transform ) dragger.addTransformUpdating( transform );
        }
        is >> osgDB::END_BRACKET;
    }
    is >> osgDB::END_BRACKET;
    return true;
}
Exemple #16
0
static bool readClearMask( osgDB::InputStream& is, osg::ClearNode& node )
{
    GLbitfield mask = GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT;
    if ( is.isBinary() )
    {
        int maskValue;
        is >> maskValue;
        mask = (GLbitfield)maskValue;
    }
Exemple #17
0
static bool readChildren( osgDB::InputStream& is, osg::Group& 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;
}
Exemple #18
0
static bool readLayers( osgDB::InputStream& is, osgVolume::CompositeLayer& layer )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgVolume::Layer* child = dynamic_cast<osgVolume::Layer*>( is.readObject() );
        if ( child ) layer.addLayer( child );
    }
    is >> is.END_BRACKET;
    return true;
}
static bool readValues( osgDB::InputStream& is, osgSim::MultiSwitch& node )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        is >> is.PROPERTY("SwitchSet");
        unsigned int valueSize = is.readSize(); is >> is.BEGIN_BRACKET;

        osgSim::MultiSwitch::ValueList values;
        for ( unsigned int j=0; j<valueSize; ++j )
        {
            bool value; is >> value;
            values.push_back( value );
        }
        node.setValueList( i, values );
        is >> is.END_BRACKET;
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #20
0
    virtual void objectRead(osgDB::InputStream& is, osg::Object& obj)
    {
        osg::ProxyNode& proxyNode = static_cast<osg::ProxyNode&>(obj);

        if (proxyNode.getLoadingExternalReferenceMode() == osg::ProxyNode::LOAD_IMMEDIATELY)
        {
            for(unsigned int i=0; i<proxyNode.getNumFileNames(); i++)
            {
                if(i >= proxyNode.getNumChildren() && !proxyNode.getFileName(i).empty())
                {
                    osgDB::FilePathList& fpl = ((osgDB::ReaderWriter::Options*)is.getOptions())->getDatabasePathList();
                    fpl.push_front( fpl.empty() ? osgDB::getFilePath(proxyNode.getFileName(i)) : fpl.front()+'/'+ osgDB::getFilePath(proxyNode.getFileName(i)));
                    osg::Node* node = osgDB::readNodeFile(proxyNode.getFileName(i), is.getOptions());
                    fpl.pop_front();
                    if(node)
                        proxyNode.insertChild(i, node);
                }
            }
        }
    }
Exemple #21
0
static bool readTextureWeights( osgDB::InputStream& is, osgFX::MultiTextureControl& ctrl )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        float weight = 0.0f; is >> weight;
        ctrl.setTextureWeight( i, weight );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #22
0
static bool readShaders( osgDB::InputStream& is, osg::Program& attr )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osg::ref_ptr<osg::Shader> shader = is.readObjectOfType<osg::Shader>();
        if ( shader ) attr.addShader( shader );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #23
0
static bool readOperators( osgDB::InputStream& is, osgParticle::ModularProgram& prog )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgParticle::Operator* op = dynamic_cast<osgParticle::Operator*>( is.readObject() );
        if ( op ) prog.addOperator( op );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #24
0
static bool readDraggers( osgDB::InputStream& is, osgManipulator::CompositeDragger& dragger )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgManipulator::Dragger* child = dynamic_cast<osgManipulator::Dragger*>( is.readObject() );
        if ( child ) dragger.addDragger( child );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #25
0
static bool readProperties( osgDB::InputStream& is, osgVolume::CompositeProperty& prop )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgVolume::Property* child = dynamic_cast<osgVolume::Property*>( is.readObject() );
        if ( child ) prop.addProperty( child );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #26
0
static bool readChildren( osgDB::InputStream& is, osg::CompositeShape& shape )
{
    unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osg::Shape* child = dynamic_cast<osg::Shape*>( is.readObject() );
        if ( child ) shape.addChild( child );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #27
0
static bool readPlacers( osgDB::InputStream& is, osgParticle::CompositePlacer& cp )
{
    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osgParticle::Placer* p = dynamic_cast<osgParticle::Placer*>( is.readObject() );
        if ( p ) cp.addPlacer( p );
    }
    is >> osgDB::END_BRACKET;
    return true;
}
Exemple #28
0
static bool readPositionList( osgDB::InputStream& is, osg::Billboard& node )
{
    unsigned int size = is.readSize();
    is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osg::Vec3d pos; is >> pos;
        node.setPosition( i, pos );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #29
0
static bool readMatrices( osgDB::InputStream& is, osg::VertexProgram& vp )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        unsigned int key; osg::Matrixd value;
        is >> key >> value;
        vp.setMatrix( key, value );
    }
    is >> is.END_BRACKET;
    return true;
}
Exemple #30
0
static bool readRangeList( osgDB::InputStream& is, osg::LOD& node )
{
    unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        float min, max;
        is >> min >> max;
        node.setRange( i, min, max );
    }
    is >> is.END_BRACKET;
    return true;
}