Quantcast

NOTICE: Refactor to the osgEarthSplat layers

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

NOTICE: Refactor to the osgEarthSplat layers

Friends,

If anyone here uses the osgEarthSplat library or the "splat" extension, please be aware that we have just refactored it and pushed those changes to the master branch.

There are new examples in the tests folder, all starting with the "splat" prefix, so feel free to check those out if you need to upgrade your own earth files to use the new format.

As always... if you have any questions just ask!
Glenn Waldron / Pelican Mapping
diabear diabear
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

I didn't use the Earth file. How do I create this new splat with code ?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

We dont' have a code example yet, but it's on the (long) to-do list. Were you creating splat layers in code before?
Glenn Waldron / Pelican Mapping
diabear diabear
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

Yes, I created it before. But now, I'm trying to use the new method, create the new layer,

LandCoverLayer
SplatLayer
GroundCoverLayer

Can't see anything .
diabear diabear
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

Here is the code segment.

_CreateLandCover
{
        GDALOptions sLCOpts;
        sLCOpts.url() = sNode.GetPropStr("url");
        sLCOpts.coverage() = true;

        LandCoverCoverageLayerOptions sCoverOpts;
        sCoverOpts.name() = "Land_Cover";
        sCoverOpts.cachePolicy() = CachePolicy::USAGE_NO_CACHE;
        sCoverOpts.driver() = sLCOpts;
        sCoverOpts.warp() = sNode.GetPropFloat("warp", 0.01f);
        sCoverOpts.minLevel() = sNode.GetPropUInt("base_lod", 10);

        LandCoverDictionaryOptions sLCDOpts;

        CXmlNode sMapNode = hXMLLegend.GetChild("mappings");
        if (!sMapNode.IsEmpty())
        {
                VXmlNodeVec vMapNode = sMapNode.GetChildren("mapping");
                for (auto& it : vMapNode)
                {
                        LandCoverValueMapping* pLCVM = new LandCoverValueMapping;
                        pLCVM->setValue(it.GetPropInt("value"));
                        pLCVM->setLandCoverClassName(it.GetPropStr("class"));
                        sCoverOpts.mappings().push_back(pLCVM);

                        LandCoverClass* pLCC = new LandCoverClass;
                        pLCC->setName(pLCVM->getLandCoverClassName());
                        pLCC->setValue(pLCVM->getValue());
                        sLCDOpts.classes().push_back(pLCC);
                }
        }

        m_pKernelData->pMap->addLayer(new LandCoverDictionary(sLCDOpts));

        LandCoverLayerOptions sLCLOpts;
        sLCLOpts.name() = g_strLandCoverName;
        sLCLOpts.cachePolicy() = CachePolicy::USAGE_NO_CACHE;
        sLCLOpts.coverages().push_back(sCoverOpts);
        sLCLOpts.maxDataLevel() = sNode.GetPropUInt("max_data_level", 15);
        sLCLOpts.shareTexUniformName() = "SplatTex";
        sLCLOpts.shareTexMatUniformName() = "SplatTex_matrix";

        m_sGround.pLandCoverLayer = new LandCoverLayer(sLCLOpts);
        m_pKernelData->pMap->addLayer(m_sGround.pLandCoverLayer);
}


_CreateSplat()
{
        SplatLayerOptions sSplatOpts;
        sSplatOpts.name() = g_strSplatName;
        sSplatOpts.cachePolicy() = CachePolicy::USAGE_NO_CACHE;
        sSplatOpts.landCoverLayer() = g_strLandCoverName;
        for (auto& itZone : sNode.GetChildren("zone"))
        {
                ZoneOptions sZoneOpts;
                sZoneOpts.name() = itZone.GetPropStr("name");

                CXmlNode sNodeTemp = itZone.GetChild("surface");
                if (sNodeTemp.IsEmpty())
                        continue;
                SurfaceOptions sSFOpts;
                sSFOpts.catalogURI() = sNodeTemp.GetPropStr("catalog");
                sZoneOpts.surface() = sSFOpts;

                sSplatOpts.zones().push_back(sZoneOpts);
        }

        m_sGround.pSplatLayer = new SplatLayer(sSplatOpts);
        m_pKernelData->pMap->addLayer(m_sGround.pSplatLayer);
}

_CreateGroundCover()
{

        for (auto& itZone : sNode.GetChildren("zone"))
        {
                ZoneOptions sZoneOpts;
                sZoneOpts.name() = itZone.GetPropStr("name");

                CXmlNode sNodeLC = itZone.GetChild("land_cover");
                if (sNodeLC.IsEmpty())
                        continue;
                for (auto& itLayer : sNodeLC.GetChildren("layer"))
                {
                        GroundCoverOptions sLCOpts;
                        sLCOpts.name() = itLayer.GetPropStr("name");
                        sLCOpts.lod() = itLayer.GetPropUInt("lod", 14);
                        sLCOpts.maxDistance() = itLayer.GetPropFloat("max_distance", 5000);
                        sLCOpts.density() = itLayer.GetPropFloat("density", 1);
                        sLCOpts.fill() = itLayer.GetPropFloat("fill", 0.5f);
                        sLCOpts.wind() = itLayer.GetPropFloat("wind");
                        sLCOpts.brightness() = itLayer.GetPropFloat("brightness", 1);
                        sLCOpts.contrast() = itLayer.GetPropFloat("contrast", 1);

                        for (auto& itBiome : itLayer.GetChildren("biome"))
                        {
                                GroundCoverBiomeOptions sGCBOpts;
                                sGCBOpts.biomeClasses() = itBiome.GetPropStr("classes");
                                for (auto& itBB : itBiome.GetChildren("billboard"))
                                {
                                        osg::ref_ptr<BillboardSymbol> pBS = new BillboardSymbol;
                                        pBS->url() = itBB.GetPropStr("url");
                                        pBS->width() = itBB.GetPropFloat("width", 1);
                                        pBS->height() = itBB.GetPropFloat("height", 1);
                                        sGCBOpts.symbols().push_back(pBS);
                                }
                                sLCOpts.biomes().push_back(sGCBOpts);
                        }
                        sZoneOpts.groundCover() = sLCOpts;

                        GroundCoverLayerOptions sGCLOpts;
                        sGCLOpts.cachePolicy() = CachePolicy::USAGE_NO_CACHE;
                        sGCLOpts.landCoverLayer() = g_strLandCoverName;
                        sGCLOpts.name() = g_strGroundCoverName + sZoneOpts.name().get() + "_" + sLCOpts.name().get();
                        sGCLOpts.castShadows() = itLayer.GetPropBool("cast_shadows", true);
                        sGCLOpts.lod() = itLayer.GetPropUInt("lod", 14);
                        sGCLOpts.zones().push_back(sZoneOpts);

                        osgEarth::Splat::GroundCoverLayer* pGroundCoverLayer = new GroundCoverLayer(sLCOpts);
                        m_sGround.pGroundCoverLayer.push_back(pGroundCoverLayer);
                        m_pKernelData->pMap->addLayer(pGroundCoverLayer);
                }
        }
}
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

In reply to this post by diabear
OK. I will try to work up an example shortly.
Glenn Waldron / Pelican Mapping
diabear diabear
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

Many thanks.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

Example is up, in osgearth_splat.cpp.
Glenn Waldron / Pelican Mapping
diabear diabear
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NOTICE: Refactor to the osgEarthSplat layers

OK, I can see that. The main problem with my code is "LandCoverDictionary".
Thx for your help.
Loading...