Exemple #1
0
void
parseCommandLine( int argc, char** argv )
{
	osgGIS::Registry* registry = osgGIS::Registry::instance();

    osg::ArgumentParser arguments( &argc, argv );

    std::string str;

    // the input vector file that we will compile:
    while( arguments.read( "--input", input_file ) );

    // terrain:
    while( arguments.read( "--terrain", terrain_file ) );

    // Color of the output geometry:
    while( arguments.read( "--color", str ) )
        sscanf( str.c_str(), "%f,%f,%f,%f", &color.x(), &color.y(), &color.z(), &color.a() );

    while( arguments.read( "--random-colors" ) )
        color.a() = 0.0;

    //while( arguments.read( "--buffer", str ) )
    //    sscanf( str.c_str(), "%f", &buffer );

    // validate arguments:
    if ( input_file.empty() ) //|| terrain_file.empty() )
    {
        arguments.getApplicationUsage()->write(
            std::cout,
            osg::ApplicationUsage::COMMAND_LINE_OPTION );
        exit(-1);
    }
}
ColorGradient::ColorGradient(osg::Vec4f color,int rank)
{
	float off = (1.0-0.1)/(rank-1);
	colors = new osg::Vec4f[rank];
	for(int i=0;i<rank;i++)
	{
		float f = 1-off*i;
		osg::Vec4f tm(color.r()*f,color.g()*f,color.b()*f,f);
		colors[i] = tm;
	}
}
Exemple #3
0
void
parseCommandLine( int argc, char** argv )
{
	osgGIS::Registry* registry = osgGIS::Registry::instance();

    osg::ArgumentParser arguments( &argc, argv );
    
    arguments.getApplicationUsage()->setApplicationName( arguments.getApplicationName() );
    arguments.getApplicationUsage()->setDescription( arguments.getApplicationName() + " clamps vector data to a terrain dataset." );
    arguments.getApplicationUsage()->setCommandLineUsage( arguments.getApplicationName() + " [--input vector_file [options..]");
    arguments.getApplicationUsage()->addCommandLineOption( "-h or --help", "Display all available command line paramters");

    // request for help:
    if ( arguments.read( "-h" ) || arguments.read( "--help" ) )
    {
        usage( arguments.getApplicationName().c_str(), 0 );
        exit(-1);
    }

    std::string str;

    // the input vector file that we will compile:
    while( arguments.read( "--input", input_file ) );

    // output file for vector geometry:
    while( arguments.read( "--output", output_file ) );

    // Color of the output geometry:
    while( arguments.read( "--color", str ) )
        sscanf( str.c_str(), "%f,%f,%f,%f", &color.x(), &color.y(), &color.z(), &color.a() );

    while( arguments.read( "--random-colors" ) )
        color.a() = 0.0;

    while( arguments.read( "--fade-lods" ) )
        fade_lods = true;

    while( arguments.read( "--buffer", str ) )
        sscanf( str.c_str(), "%f", &buffer );

    // validate arguments:
    if ( input_file.length() == 0 )
    {
        arguments.getApplicationUsage()->write(
            std::cout,
            osg::ApplicationUsage::COMMAND_LINE_OPTION );
        exit(-1);
    }
}
Exemple #4
0
    void Storage::fixColour (osg::Vec4f& color, int cellX, int cellY, int col, int row)
    {
        if (col == ESM::Land::LAND_SIZE-1)
        {
            ++cellY;
            col = 0;
        }
        if (row == ESM::Land::LAND_SIZE-1)
        {
            ++cellX;
            row = 0;
        }
        ESM::Land* land = getLand(cellX, cellY);
        if (land && land->mDataTypes&ESM::Land::DATA_VCLR)
        {
            color.r() = land->mLandData->mColours[col*ESM::Land::LAND_SIZE*3+row*3] / 255.f;
            color.g() = land->mLandData->mColours[col*ESM::Land::LAND_SIZE*3+row*3+1] / 255.f;
            color.b() = land->mLandData->mColours[col*ESM::Land::LAND_SIZE*3+row*3+2] / 255.f;
        }
        else
        {
            color.r() = 1;
            color.g() = 1;
            color.b() = 1;
        }

    }
Exemple #5
0
osgGIS::FilterGraph*
createFilterGraph()
{
	osgGIS::Registry* registry = osgGIS::Registry::instance();

    // The FilterGraph is a series of filters that will transform the GIS
    // feature data into a scene graph.
    osgGIS::FilterGraph* graph = new osgGIS::FilterGraph();

    // Buffer if necessary:
    if ( buffer != 0.0f )
        graph->appendFilter( new osgGIS::BufferFilter( buffer ) );

    // Construct osg::Drawable's from the incoming feature batches:
    osgGIS::BuildGeomFilter* gf = new osgGIS::BuildGeomFilter();
    gf->setColor( color );
    if ( color.a() == 0 )
        gf->setColorScript( new osgGIS::Script( "vec4(math.random(),math.random(),math.random(),1)" ) );
    //gf->setRandomizeColors( color.a() == 0 );
    graph->appendFilter( gf );

    // Bring all the drawables into a single collection so that they
    // all fall under the same osg::Geode.
    graph->appendFilter( new osgGIS::CollectionFilter() );

    // Construct a Node that contains the drawables and adjust its state set.
    osgGIS::BuildNodesFilter* bnf = new osgGIS::BuildNodesFilter();
    //bnf->setDisableLighting( true );

    bnf->setAlphaBlending( true );
    bnf->setOptimize( false );

    graph->appendFilter( bnf );

    return graph;
}