当前位置: 首页>>代码示例>>C++>>正文


C++ ImageLayer::addColorFilter方法代码示例

本文整理汇总了C++中ImageLayer::addColorFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLayer::addColorFilter方法的具体用法?C++ ImageLayer::addColorFilter怎么用?C++ ImageLayer::addColorFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageLayer的用法示例。


在下文中一共展示了ImageLayer::addColorFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

// main program.
int main(int argc, char** argv)
{
    // set up the viewer
    osg::ArgumentParser arguments(&argc,argv);
    osgViewer::Viewer viewer(arguments);

    // make sure we have a shape file.
    std::string shapefile;
    if ( !arguments.read("--shapefile", shapefile) )
        return usage("Missing required --shapefile argument");

    // install a motion model
    viewer.setCameraManipulator( new osgEarth::Util::EarthManipulator() );

    // create a visible imagery layer:
    ImageLayer* imagery = createImageryLayer();

    // create a masking layer using the shapefile:
    ImageLayer* sharedLayer = createSharedLayer( shapefile );

    // create a new map and add our two layers.
    MapNode* mapnode = new MapNode();
    mapnode->getMap()->addImageLayer( imagery );
    mapnode->getMap()->addImageLayer( sharedLayer );

    // make a custom color-filter shader that will modulate the imagery
    // using the texture from the shared layer. (Using a ColorFilter 
    // will apply the effect to just one layer; if you want to apply it
    // to all layers, you can just create a VirtualProgram and apply that
    // the the mapnode->getTerrainEngine() state set.)
    ColorFilter* filter = new MyColorFilter( sharedLayer );
    imagery->addColorFilter( filter );

    // done!
    viewer.setSceneData( mapnode );
    MapNodeHelper().configureView(&viewer);
    return viewer.run();
}
开发者ID:FeastForU,项目名称:osgearth,代码行数:39,代码来源:osgearth_sharedlayer.cpp

示例2: arguments

int
main(int argc, char** argv)
{
    osg::ArgumentParser arguments(&argc,argv);

    // Which filter?
    bool useHSL   = arguments.read("--hsl");
    bool useRGB   = arguments.read("--rgb");
    bool useCMYK  = arguments.read("--cmyk");
    bool useBC    = arguments.read("--bc");
    bool useGamma = arguments.read("--gamma");
    bool useChromaKey = arguments.read("--chromakey");

    if ( !useHSL && !useRGB && !useCMYK && !useBC && !useGamma && !useChromaKey )
    {
        return usage( "Please select one of the filter options!" );
    }

    osgViewer::Viewer viewer(arguments);
    viewer.setCameraManipulator( new EarthManipulator() );

    // load an earth file
    osg::Node* node = MapNodeHelper().load(arguments, &viewer);
    if ( !node )
        return usage( "Unable to load map from earth file!" );
    viewer.setSceneData( node );

    //Create the control panel
    Container* box = createControlPanel(&viewer);
    
    osgEarth::MapNode* mapNode = osgEarth::MapNode::findMapNode( node );
    if ( node )
    {   
        if (mapNode->getMap()->getNumImageLayers() == 0)
        {
            return usage("Please provide a map with at least one image layer.");
        }

        // attach color filter to each layer.
        unsigned numLayers = mapNode->getMap()->getNumImageLayers();
        for( unsigned i=0; i<numLayers; ++i )
        {
            ImageLayer* layer = mapNode->getMap()->getImageLayerAt( i );

            if ( layer->getEnabled() && layer->getVisible() )
            {
                if ( useHSL )
                {
                    HSLColorFilter* filter = new HSLColorFilter();
                    layer->addColorFilter( filter );
                    HSL::addControls( filter, box, i );
                }
                else if ( useRGB )
                {
                    RGBColorFilter* filter = new RGBColorFilter();
                    layer->addColorFilter( filter );
                    RGB::addControls( filter, box, i );
                }
                else if ( useCMYK )
                {
                    CMYKColorFilter* filter = new CMYKColorFilter();
                    layer->addColorFilter( filter );
                    CMYK::addControls( filter, box, i );
                }
                else if ( useBC )
                {
                    BrightnessContrastColorFilter* filter = new BrightnessContrastColorFilter();
                    layer->addColorFilter( filter );
                    BC::addControls( filter, box, i );
                }
                else if ( useGamma )
                {
                    GammaColorFilter* filter = new GammaColorFilter();
                    layer->addColorFilter( filter );
                    GAMMA::addControls( filter, box, i );
                }
                else if ( useChromaKey )
                {
                    ChromaKeyColorFilter* filter = new ChromaKeyColorFilter();
                    layer->addColorFilter( filter );
                    CHROMAKEY::addControls( filter, box , i );
                }
            }
        }
    }
    

    return viewer.run();
}
开发者ID:rhabacker,项目名称:osgearth,代码行数:89,代码来源:osgearth_colorfilter.cpp


注:本文中的ImageLayer::addColorFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。