Quantcast

Setting osg::Node to ModelSymbol

classic Classic list List threaded Threaded
1 message Options
bhanu406 bhanu406
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Setting osg::Node to ModelSymbol

I trying to setting osg::Node to ModelSymbol of setModel() function, model was not displaying on the screen.I tried with following code:
{
        osg::Node *node = osgDB::readNodeFile("data/tree.ive.1,2,3.scale");
       
        // create a feature source to load the shapefile.
        OGRFeatureOptions feature_opt;
        feature_opt.name() = "parks";
        feature_opt.url() = PARKS_URL;
        feature_opt.buildSpatialIndex() = true;

        // a style:
        Style style;
        style.setName("parks");

        ModelSymbol* model = style.getOrCreate<ModelSymbol>();
        model->setModel(node);//setting osgNode
        model->placement() = model->PLACEMENT_RANDOM;
        model->density() = 300.0f; // instances per sqkm

        AltitudeSymbol* alt = style.getOrCreate<AltitudeSymbol>();
        alt->clamping() = alt->CLAMP_TO_TERRAIN;
       
        // Since the tree model contains alpha components, we will discard any data
        // that's sufficiently transparent; this will prevent depth-sorting anomolies
        // common when rendering lots of semi-transparent objects.
        RenderSymbol* render = style.getOrCreate<RenderSymbol>();
        render->minAlpha() = 0.15f;

        // Set up a paging layout. The tile size factor and the visibility range combine
        // to determine the tile size, such that tile radius = max range / tile size factor.
        FeatureDisplayLayout layout;
        layout.tileSizeFactor() = 3.0f;
        layout.maxRange() = 2000.0f;
        layout.addLevel(FeatureLevel(0, 20000, "parks"));

        // create a model layer that will render the buildings according to our style sheet.
        FeatureGeomModelOptions fgm_opt;
        fgm_opt.featureOptions() = feature_opt;
        fgm_opt.layout() = layout;
        fgm_opt.styles() = new StyleSheet();
        fgm_opt.styles()->addStyle(style);
        fgm_opt.compilerOptions().instancing() = true;

        osgEarth::ModelLayer *modelLayer = new osgEarth::ModelLayer("parks", fgm_opt);
        modelLayer->setVisible(true);
        map->addModelLayer(modelLayer);
}
Is there anything wrong in mycode ?
Loading...