Can't you control the model property with the value of the model layer imported from the earth file?

classic Classic list List threaded Threaded
2 messages Options
newlife958 newlife958
Reply | Threaded
Open this post in threaded view
|

Can't you control the model property with the value of the model layer imported from the earth file?

Can't you control the model property with the value of the model layer imported from the earth file?


============my.earth file ======================
....
<model name="model_haze" driver="simple">
        <url>Z:DB/Model/haze.flt</url>
                        <location>128.087467 35.096586 7.49999</location>         
    </model>
....
===========================================

     ------------  my source code -------------------
if (layer == NULL){
        osgEarth::Layer* layer = _mapNode->getMap()->getLayerByName("model_haze");

     ---------- to control layer -----------------
osgEarth::Symbology::Style style;
style.getOrCreate<osgEarth::ModelSymbol>()->setModel(layer->getNode());

osgEarth::Annotation::ModelNode * model = new  osgEarth::Annotation::ModelNode(_mapNode, style);

       ----------- move model  ------------
model->setPosition(osgEarth::GeoPoint(osgEarth::SpatialReference::create("wgs84"),
                        128, 0, 100000,
                        osgEarth::AltitudeMode::ALTMODE_ABSOLUTE));


However, the position of MODEL does not change.
Is the way I did it wrong?




gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Can't you control the model property with the value of the model layer imported from the earth file?

You cannot do that with layer->getNode(). If you want to load a model and position it, just load it from disk with osgDB::readRefNodeFile and create your ModelNode from that.
Glenn Waldron / Pelican Mapping