About drapping of texture to the Bridges in osg

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

About drapping of texture to the Bridges in osg

Hi,Iam loading the Bridges using shape file where shape files contains polygons,iam adding the texture image to the polygons but images are not drapping to the polygon and polygons are appearing as white.Iam doing the code by below

   In Bridges.xml file iam reading the texture image file.

   #define BRIDGES_URL       "D:/Back_UP/cochin_bridges_old/cochin_bridges_utm43polygons.shp";
   #define BRIDGES_MODEL_URL "Resources/data/resources/textures_us/Bridges.xml"

       OGRFeatureOptions feature_opt;
        feature_opt.name()              = "Bridges";
        feature_opt.url()               = BRIDGES_URL;
         feature_opt.buildSpatialIndex() = true;

        Style style;
        style.setName("Bridges");
       
       ExtrusionSymbol* extrusion    = style.getOrCreate<ExtrusionSymbol>();
       extrusion->heightExpression() =  NumericExpression("20 +  (Math.random() * 21)");
       extrusion->flatten()          =  true;

       PolygonSymbol* poly = style.getOrCreate<PolygonSymbol>();
       poly->fill()->color() = Color::White;
       AltitudeSymbol* alt           = style.getOrCreate<AltitudeSymbol>();
       alt->clamping()               = alt->CLAMP_TO_TERRAIN;
       alt->binding()                = alt->BINDING_VERTEX;

       ResourceLibrary* reslib = new    ResourceLibrary("us_resources",BRIDGES_MODEL_URL);
       styleSheet->addResourceLibrary(reslib);

        FeatureGeomModelOptions fgm_opt;
        fgm_opt.featureOptions()  = feature_opt;
        fgm_opt.styles()          = new StyleSheet();
        fgm_opt.styles()->addStyle(style);
        fgm_opt.backfaceCulling() = true;
        fgm_opt.clusterCulling()  = true;
        map->addModelLayer(new ModelLayer("Bridges", fgm_opt));

Any Help is Appreciated.

Thanks & Regards,
R.Rambabu
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: About drapping of texture to the Bridges in osg

Putting textures on extruded polygons requires that you specify a wall style and/or a roof style. Please refer to the addBuildings() method in the osgearth_city.cpp example to see how this is done.
Glenn Waldron / Pelican Mapping