bool ScalarProperty_readLocalData(osg::Object& obj, osgDB::Input &fr)
{
    osgVolume::ScalarProperty& sp = static_cast<osgVolume::ScalarProperty&>(obj);

    bool itrAdvanced = false;

    float value=0; 
    if (fr.read("value",value))
    {
        itrAdvanced = true;
        sp.setValue(value);
    }

    return itrAdvanced;
}
Example #2
0
bool SwitchProperty_readLocalData(osg::Object& obj, osgDB::Input &fr)
{
    osgVolume::SwitchProperty& sp = static_cast<osgVolume::SwitchProperty&>(obj);

    bool itrAdvanced = false;

    int value=0;
    if (fr.read("activeProperty",value))
    {
        itrAdvanced = true;
        sp.setActiveProperty(value);
    }

    return itrAdvanced;
}
Example #3
0
bool SwitchLayer_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
    osgTerrain::SwitchLayer &layer = static_cast<osgTerrain::SwitchLayer&>(obj);

    bool itrAdvanced = false;

    int i;

    if (fr.read("ActiveLayer", i))
    {
        layer.setActiveLayer(i);
        itrAdvanced = true;
    }

    ;

    return itrAdvanced;
}
Example #4
0
bool CompositeLayer_readLocalData(osg::Object& obj, osgDB::Input &fr)
{
    osgTerrain::CompositeLayer& layer = static_cast<osgTerrain::CompositeLayer&>(obj);

    bool itrAdvanced = false;

    osg::ref_ptr<osgTerrain::Locator> locator = 0;

    do
    {
        itrAdvanced = false;

        osg::ref_ptr<osg::Object> readObject = fr.readObjectOfType(osgDB::type_wrapper<osgTerrain::Locator>());
        locator = dynamic_cast<osgTerrain::Locator*>(readObject.get());
        if (readObject.valid()) itrAdvanced = true;

        unsigned int minLevel=0;
        if (fr.read("MinLevel",minLevel))
        {
            itrAdvanced = true;
        }

        unsigned int maxLevel = MAXIMUM_NUMBER_OF_LEVELS;
        if (fr.read("MaxLevel",maxLevel))
        {
            itrAdvanced = true;
        }

        if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
        {
            layer.addLayer(fr[1].getStr());
            fr += 2;

            itrAdvanced = true;
        }
        else if (fr.matchSequence("ProxyLayer %s") || fr.matchSequence("ProxyLayer %w"))
        {
            std::string setname;
            std::string filename;
            osgTerrain::extractSetNameAndFileName(fr[1].getStr(),setname, filename);
            if (!filename.empty())
            {
                osgTerrain::ProxyLayer* proxyLayer = new osgTerrain::ProxyLayer;
                proxyLayer->setFileName(filename);
                proxyLayer->setName(setname);

                if (locator.valid()) proxyLayer->setLocator(locator.get());
                if (minLevel!=0) proxyLayer->setMinLevel(minLevel);
                if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) proxyLayer->setMaxLevel(maxLevel);


                layer.addLayer(proxyLayer);
            }

            fr += 2;

            itrAdvanced = true;
        }
        else
        {
            osg::ref_ptr<osg::Object> readObject = fr.readObjectOfType(osgDB::type_wrapper<osgTerrain::Layer>());
            osgTerrain::Layer* readLayer = dynamic_cast<osgTerrain::Layer*>(readObject.get());
            if (readLayer)
            {
                if (locator.valid())
                {
                    readLayer->setLocator(locator.get());
                    locator = 0;
                }

                if (minLevel!=0) readLayer->setMinLevel(minLevel);
                if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) readLayer->setMaxLevel(maxLevel);

                layer.addLayer(readLayer);
            }

            if (readObject.valid()) itrAdvanced = true;
        }

    } while (itrAdvanced);

    if (locator.valid()) layer.setLocator(locator.get());

    return itrAdvanced;
}
Example #5
0
bool View_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
    osgViewer::View &view            = dynamic_cast<osgViewer::View&>(obj);
    bool            iteratorAdvanced = false;

    bool matchedFirst = false;

    if ((matchedFirst = fr.matchSequence("setUpViewFor3DSphericalDisplay {")) ||
        fr.matchSequence("setUpViewForPanoramicSphericalDisplay {"))
    {
        double                   radius          = 1.0;
        double                   collar          = 0.45;
        unsigned int             screenNum       = 0;
        unsigned int             intensityFormat = 8;
        osg::Matrix              matrix;
        std::string              filename;
        osg::ref_ptr<osg::Image> intensityMap;
        int                      entry = fr[0].getNoNestedBrackets();

        fr += 2;

        while (!fr.eof() && fr[0].getNoNestedBrackets() > entry)
        {
            bool local_itrAdvanced = false;
            if (fr.read("radius", radius))
                local_itrAdvanced = true;

            if (fr.read("collar", collar))
                local_itrAdvanced = true;

            if (fr.read("screenNum", screenNum))
                local_itrAdvanced = true;

            if (fr.read("intensityFile", filename))
                local_itrAdvanced = true;

            if (fr.matchSequence("intensityMap {"))
                intensityMap = readIntensityImage(fr, local_itrAdvanced);

            if (fr.read("intensityFormat", intensityFormat))
                local_itrAdvanced = true;

            if (readMatrix(matrix, fr, "projectorMatrix"))
                local_itrAdvanced = true;

            if (!local_itrAdvanced)
                ++fr;
        }

        // skip trailing '}'
        ++fr;

        iteratorAdvanced = true;

        if (!filename.empty())
        {
            intensityMap = osgDB::readRefImageFile(filename);
        }

        if (intensityMap.valid())
        {
            if (intensityFormat == 16)
                intensityMap->setInternalTextureFormat(GL_LUMINANCE16F_ARB);
            else if (intensityFormat == 32)
                intensityMap->setInternalTextureFormat(GL_LUMINANCE32F_ARB);

            // else intensityMap->setInternalTextureFormat(image->getPixelFormat());
        }


        if (matchedFirst)
            view.setUpViewFor3DSphericalDisplay(radius, collar, screenNum, intensityMap.get(), matrix);
        else
            view.setUpViewForPanoramicSphericalDisplay(radius, collar, screenNum, intensityMap.get(), matrix);
    }

    int          x         = 0;
    int          y         = 0;
    int          width     = 128;
    int          height    = 1024;
    unsigned int screenNum = 0;

    if (fr.read("setUpViewOnSingleScreen", screenNum))
    {
        view.setUpViewOnSingleScreen(screenNum);
        iteratorAdvanced = true;
    }

    if (fr.read("setUpViewAcrossAllScreens"))
    {
        view.setUpViewAcrossAllScreens();
        iteratorAdvanced = true;
    }

    if (fr.read("setUpViewInWindow", x, y, width, height, screenNum))
    {
        view.setUpViewInWindow(x, y, width, height, screenNum);
    }

    if (fr.read("setUpViewInWindow", x, y, width, height))
    {
        view.setUpViewInWindow(x, y, width, height);
    }


    osg::ref_ptr<osg::Object> readObject;

    while ((readObject = fr.readObjectOfType(osgDB::type_wrapper<osg::Camera>())).valid())
    {
        view.setCamera(static_cast<osg::Camera*>(readObject.get()));
        iteratorAdvanced = true;
    }

    if (fr.matchSequence("Slaves {"))
    {
        int entry = fr[0].getNoNestedBrackets();

        fr += 2;

        while (!fr.eof() && fr[0].getNoNestedBrackets() > entry)
        {
            readObject = fr.readObjectOfType(osgDB::type_wrapper<osg::Camera>());
            if (readObject.valid())
                view.addSlave(static_cast<osg::Camera*>(readObject.get()));
            else
                ++fr;
        }

        // skip trailing '}'
        ++fr;

        iteratorAdvanced = true;
    }

    return iteratorAdvanced;
}