Quantcast

Draw Ribbon

classic Classic list List threaded Threaded
3 messages Options
Daven Hem Daven Hem
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Draw Ribbon

How are you, Mr. Glenn!
I want to draw 3D ribbon which is made from given 3D path. I think I can use feature.
This ribbon should be created along the path and the path should be laid on center of this ribbon.

- Create a path which is defined by N vertices.(solved)
- Create a ribbon which is defined by path. It can have width and color attributes.
  Users can change its width.

Just for your information, I've attached screenshot. The green solid geometry is ribbon, and red line is path in the middle of that.
How can I draw ribbon from path by using feature? or by other technique? Where can I find sample code?
Please help me.
Thanks for your time.
Kind regards.
Daven Hem.

Daven Hem Daven Hem
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Draw Ribbon

Hello, everybody!
I tried to render this ribbon by using Feature Node of osgEarth but one issue was occurred.
I want to match green ribbon to red line (3D path) but z value of all vertices of this feature segment was 0(geom). Please look attached images.
How can I fix it?
My code:

//in *.h file
Public:
FeatureNode* getFeatureNode2() {return _featureNode2;}
Private:
        osg::ref_ptr< FeatureNode > _featureNode2;

//in *.cpp file
        LineString* line = new LineString();

        Feature* feature = new Feature(line, _mapNode->getMapSRS(), Style(), s_fid++);
        _featureNode = new FeatureNode(_mapNode, feature);

        const SpatialReference* geoSRS = getCurSRS();
        const SpatialReference* wgs = SpatialReference::get("wgs84");
        GeoPoint ptWGS;
               
        for (int i = 0; i < vecPathData.size(); i++)
        {
                ptWGS.set(wgs, pathItem.y, pathItem.x, pathItem.z, ALTMODE_ABSOLUTE);
                GeoPoint ptCur = wsg2CurSRS(ptWGS);
                Feature* feature = _featureNode->getFeatures().front();
                feature->getGeometry()->push_back(ptCur.vec3d());
                ptCur = lonlat2Metric(ptWGS);
        }
       
BufferParameters bp;
        osg::ref_ptr<Symbology::Geometry> geom;
        bp._capStyle = BufferParameters::CAP_ROUND;
        line->buffer(0.0001, geom, bp);
       
Style geomStyle;
        geomStyle.getOrCreate<LineSymbol>()->stroke()->color() = Color::Green;
        geomStyle.getOrCreate<LineSymbol>()->stroke()->width() = 5.0f;
        geomStyle.getOrCreate<PolygonSymbol>()->fill()->color() = Color(Color::Green, 0.7);
       
        Feature* feature2 = new Feature(geom, _mapNode->getMapSRS(), geomStyle);
        _featureNode2 = new FeatureNode(_mapNode, feature2);
        _featureNode2->init();
_root->addChild(getFeatureNode2());

Please teach me.
Thanks.




Daven Hem Daven Hem
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Draw Ribbon

In reply to this post by Daven Hem
Help me, Glenn...
Loading...