GeometryFactory create ellipse render not correct

classic Classic list List threaded Threaded
7 messages Options
jawbreaker jawbreaker
Reply | Threaded
Open this post in threaded view
|

GeometryFactory create ellipse render not correct

    When i use GeometryFactory  to create a ellipse geometry and show the ellipse geometry on the map by featureNode . i found if the radiusminor less than the radiusmajor a lot(for example  radiusminor = 20000 m and radiusmajor  =  150000 m), then the ellispe show not correct like cut a part off. as  picture shows.  but when the radiusminor and  radiusmajor are same length the render look like correct;
 my code following:
 osgEarth::Symbology::GeometryFactory* geometry_factory = new osgEarth::Symbology::GeometryFactory(gGetMapNode()->getMapSRS());
        osgEarth::Geometry* geometry2 = geometry_factory->createEllipse(osg::Vec3d(116.4, 40.9, 1500), osgEarth::Linear(150000, osgEarth::Units::METERS), osgEarth::Linear(20000, osgEarth::Units::METERS),(40.0f));
        osgEarth::Features::Feature * feature = new osgEarth::Features::Feature(geometry2, gGetMapNode()->getMapSRS());
        osgEarth::Symbology::LineSymbol * line = feature->style()->getOrCreate<osgEarth::Symbology::LineSymbol>();
        line->stroke()->color() = osg::Vec4(1, 1, 0, 1);
        line->stroke()->width() = 5;
        line->stroke()->smooth() = false;
  feature->style()->getOrCreate<AltitudeSymbol>()->clamping() = AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN;
  feature->style()->getOrCreate<AltitudeSymbol>()->technique() = AltitudeSymbol::TECHNIQUE_MAP;
         feature->style()->getOrCreate<AltitudeSymbol>()->binding() = osgEarth::Symbology::AltitudeSymbol::BINDING_VERTEX;
         feature->style()->getOrCreate<AltitudeSymbol>()->clampingResolution() = 0.001f;
         feature->style()->getOrCreate<osgEarth::Symbology::PolygonSymbol>()->fill()->color() = osg::Vec4(1,0,0,0.5);
         feature->style()->getOrCreate<RenderSymbol>()->depthOffset()->enabled() = true;
        line->tessellation() = 125;
        osgEarth::Annotation::FeatureNode * featureNode = new osgEarth::Annotation::FeatureNode(feature);
        gGetSceneRoot()->addChild(featureNode);

radiusminor = 20000 m and radiusmajor  =  150000 m effect like this

radiusminor = 50000m and radiusmajor  =  150000 m effect like this

extremely situation  radiusminor =2000m and radiusmajor  =  150000 m effect like this


i found another fault when i use GeometryFactory  to create a circle geometry .and the radius very short at the same time the tessellation i set 5  .when i zoom in the camera i found the circle with a lot of zigzag.
as  picture shows .when i set  tessellation = 1 show correct.
remoe remoe
Reply | Threaded
Open this post in threaded view
|

Re: GeometryFactory create ellipse render not correct

Hi

Interesting. Which version of osgEarth do you use, 2.10 ? Do you have tried to debug the code:

https://github.com/gwaldron/osgearth/blob/9198f04fa569464046b5137209b82148b58b8887/src/osgEarth/GeometryFactory.cpp#L152

Try to reproduce it with the latest osgEarth 3.0. Can you provide an earth file?

Cheers,
Remo Eichenberger, Switzerland
jawbreaker jawbreaker
Reply | Threaded
Open this post in threaded view
|

Re: GeometryFactory create ellipse render not correct

really appreciate .i used osg3.6 and osgearth2.10 . i used RELEASE version now.i will try again by use debug version.could you give me more advice if i dont update to osgearh 3.0 .thanks
here is my earthfile
<?xml version="1.0" encoding="utf8" ?>
<map name="readymap.org" type="geocentric" version="2">
        <options>
      <profile>global-geocentric</profile>
      <terrain >
        <lighting>true</lighting>
               
               
               
               
        <loading_policy mode="preempitve" loading_threads_per_core="2"/>
       
       
        <surface_node_mask>1</surface_node_mask>
        <skirt_node_mask>2</skirt_node_mask>
      </terrain>
     
        <overlay_blending>false</overlay_blending>
        <cache type="filesystem"> 
        <path>.\osgearthCache0_10</path> 
        <format>png</format> 
        </cache> 
    </options>
    <image name="world1" driver="tms">
      <url>.\tms\world\tms.xml</url>
            <cache_policy usage="read_write" /> 
    </image>
       
       
    <image name="world" driver="tms">
      <url>.\tms\world0_10\tms.xml</url>
            <cache_policy usage="read_write" /> 
    </image>
 <elevation driver="gdal" enabled="true" is2d3d="map_3d" name="chinadem" url="C:\software\earthdata\tif\chinadem.TIF">
    <cache_policy usage="read_write" />
  </elevation>
   <shaders>
        <shader name="cloudAlpha">
            <code>
             
<![CDATA[
                #pragma vp_location   fragment_coloring
                #pragma vp_entryPoint cloudAlpha
                
                void cloudAlpha(inout vec4 color) {
                    color.a = color.r;
                }
              ]]>

            </code>
        </shader>
    </shaders>
</map>
remoe remoe
Reply | Threaded
Open this post in threaded view
|

Re: GeometryFactory create ellipse render not correct

Hi, I mean an earth file with all of your ellipse styles.
Remo Eichenberger, Switzerland
jawbreaker jawbreaker
Reply | Threaded
Open this post in threaded view
|

Re: GeometryFactory create ellipse render not correct

sorry i am a beginerï¼›what mean of the earth file you mentioned.
remoe remoe
Reply | Threaded
Open this post in threaded view
|

Re: GeometryFactory create ellipse render not correct

This post was updated on .
Hi, no problem, you can try to create your geometry directly with an earth-file like:

https://github.com/gwaldron/osgearth/blob/2.10/tests/annotation.earth

without any c++ coding.
Remo Eichenberger, Switzerland
jawbreaker jawbreaker
Reply | Threaded
Open this post in threaded view
|

Re: GeometryFactory create ellipse render not correct

Hi I found it is my mistake.I always use GeometryFactory::createEllipse to create Ellipse geometry by the defaut parameter numSegments = 0.After i debug the code ,i found that if the numSegments  = 0,by calculate inside the numSegments are always equal to 51.so when the minoraxis short a lot than the majraxis,the edge of the ellipse geometry are very sharp .when i change   numSegments  equal to 400 ,the ellispe geometry show normaly. thanks