ModelSymbol are not loaded vertically to terrain!

classic Classic list List threaded Threaded
3 messages Options
MCA4213 MCA4213
Reply | Threaded
Open this post in threaded view
|

ModelSymbol are not loaded vertically to terrain!

Hi,
I have recently updated my osgEarth to 3.0, and I am facing some troubles in loading trees on polygon shapefile. my problem is that the trees are loaded inclined (not vertical to terrain) as in image.


my code is as follow:
        OGRFeatureSource* data = new OGRFeatureSource();
        data->setURL(path.toStdString());
        data->options().buildSpatialIndex() = true;
        data->open();

        Style style;
        style.setName("parks");

        ModelSymbol* model = style.getOrCreate<ModelSymbol>();
        model->url()->setLiteral(modelPath);
        model->placement() = model->PLACEMENT_RANDOM;
        model->density() = densite;
        model->scale() = scale;

        AltitudeSymbol* alt = style.getOrCreate<AltitudeSymbol>();
        alt->clamping() = alt->CLAMP_TO_TERRAIN;
        //alt->clampingResolution() = 0;

        RenderSymbol* render = style.getOrCreate<RenderSymbol>();
        render->transparent() = true;
        render->minAlpha() = 0.15f;

        FeatureDisplayLayout layout;
        layout.tileSizeFactor() = tilesize;
        layout.addLevel(FeatureLevel(minRange, maxRange, "parks"));

        FeatureModelLayer* layer = new FeatureModelLayer();
        layer->setFeatureSource(data);
        layer->options().layout() = layout;
        layer->setStyleSheet(new StyleSheet());
        layer->getStyleSheet()->addStyle(style);
        map->addLayer(layer);

Any help please to fix tha angle of the trees to be normal to the terrain?
Thanks.
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: ModelSymbol are not loaded vertically to terrain!

setMatrix(osg::Matrix::rotate(angle, -osg::Z_AXIS));

try setting this in your layer
MCA4213 MCA4213
Reply | Threaded
Open this post in threaded view
|

Re: ModelSymbol are not loaded vertically to terrain!

Hi, thanks for the reply, but there is no function like that for the layer, and it is not possible to set a specific position to a set of polygons. but thanks for your help.

I am still having this problem; any help will be very appreciated.
Thanks