the visibility of undergroud model clamped to terrain

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

the visibility of undergroud model clamped to terrain

Hi,
    In my scene, there is a .ive model clamped to the terrain undergroundly(Actually, a hole modeled as a cylinder is dug into the ground).
So, I write the earth file as:
        <map name="test" type="geocentric" version="2"> 
                <options>
                        <terrain driver="mp" blending="false"/>
                </options>
                <image name="dom" driver="tms" opacity="0.2">
                        <url>D:\dom\tms.xml</url>
                        <tile_size>256</tile_size>
                </image>
                <elevation name="dem" driver="tms">
                        <url>D:\dem\tms.xml</url>
                        <tile_size>32</tile_size>
                </elevation>
                <model name="hole1" driver="simple">
                        <url>hole.ive.10,10,10.scale</url>
                        <location>99.534 27.414 4000</location>
                </model>
        </map>
And I get a reletivly acceptable result by adjusting (try many times) the Z value to 4000 in location element(b.t.w, the height of the hole(or cylinder) is 2000):

    So, my question is: Is there any way to handle my case without adjusting the Z value manually? Any hint will be appreciated.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: the visibility of undergroud model clamped to terrain

Peckham,
If you are trying to match the top of your model to the terrain, you might be better off with a Model annotation. Please refer to the annotation.earth example, here:

https://github.com/gwaldron/osgearth/blob/master/tests/annotation.earth#L162

In your case, you don't want the auto-scaling of course. But using a position with no Z coordinate should cause it to automatically "clamp" to the terrain at the model's origin (0,0,0) coordinate.

Good luck, hope this helps.
Glenn Waldron / Pelican Mapping
peckham peckham
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: the visibility of undergroud model clamped to terrain

Hi, gwaldron
    Thank you for your reply, I fellow you suggestion but get nothing, maybe I miss something. However, I try a programmic way to fix the problem with ModelNode:
        osg::ref_ptr<osg::Group> ive = dynamic_cast<osg::Group*>(osgDB::readNodeFile("hole1.ive"));
        Style style;
        style.getOrCreate<ModelSymbol>()->setModel(ive);
        ModelNode* modelNode = new ModelNode(mapNode, style);
        osg::Vec3f vecscale; vecscale = osg::Vec3f(10, 10, 0); modelNode->setScale(vecscale);
        modelNode->setPosition(GeoPoint(geoSRS, 99.534, 27.414, 0 osgEarth::ALTMODE_RELATIVE));
          modelNode->getOrCreateStateSet()->setRenderBinMode(osg::StateSet::INHERIT_RENDERBIN_DETAILS);
        pModelLayer->addChild(modelNode);
Loading...