gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.52k stars 782 forks source link

Featurenode does not display! #1289

Closed zcwbnu closed 5 years ago

zcwbnu commented 5 years ago

I use osgDB::ReadNodefile read a earthfile and added the MapNode to root node,then I created a new featurenode and added it to the root node, however the featurenode is not shown on the earth. I think this is very unbelievable because it is OK in osgearth2.5. Why it don't work well in osgearth2.10? This is my code: osg::Node node = osgDB::ReadNodefile("test.earth"); MapNode mapNode = MapNode::findMapNode(node); root->addChild( mapNode );
Geometry* geom = new Polygon(); geom->push_back( osg::Vec3d(0, 40, 0) ); geom->push_back( osg::Vec3d(-60, 40, 0) ); geom->push_back( osg::Vec3d(-60, 60, 0) ); geom->push_back( osg::Vec3d(0, 60, 0) );

    Feature* feature = new Feature(geom, geoSRS);
    feature->geoInterp() = GEOINTERP_RHUMB_LINE;

    Style geomStyle;
    geomStyle.getOrCreate<LineSymbol>()->stroke()->color() = Color::Cyan;
    geomStyle.getOrCreate<LineSymbol>()->stroke()->width() = 5.0f;
    geomStyle.getOrCreate<LineSymbol>()->tessellationSize() = 75000;
    geomStyle.getOrCreate<AltitudeSymbol>()->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN;
    geomStyle.getOrCreate<AltitudeSymbol>()->technique() = AltitudeSymbol::TECHNIQUE_GPU;

    FeatureNode* fnode = new FeatureNode(feature, geomStyle);
    root->addChild(fnode );
zcwbnu commented 5 years ago

I found that if I use "osg::Node* node = MapNodeHelper().load(arguments, &viewer)" the featurenode can display on earth. What's the difference between osgDB::ReadNodefile and MapNodeHelper().load?

gwaldron commented 5 years ago

Don't forget to call GLUtils::setGlobalDefaults(stateset); Preferable on your camera's stateset.

zcwbnu commented 5 years ago

@gwaldron Thank you! It works.