Creating an ocean

classic Classic list List threaded Threaded
6 messages Options
adrianj adrianj
Reply | Threaded
Open this post in threaded view
|

Creating an ocean

Hello,

I have upgraded my osgEarth version to 2.9.0 and I am trying to create an ocean layer. I have image and elevation layers working correctly but I just can't figure out the syntax to get the ocean layer to appear. I am currently doing this:


Config simpleOcean;
Config simpleOceanAlt("max_altitude", "20000");
Config simpleOceanBathy("use_bathymetry", "true");
simpleOcean.add(simpleOceanAlt);
simpleOcean.add(simpleOceanBathy);

SimpleOceanLayerOptions simpleOceanOptions(simpleOcean);

SimpleOceanLayer *_ocean = new SimpleOceanLayer(simpleOceanOptions);

_map->addLayer(_ocean);


Nothing is displayed.

What am I doing wrong? Many thanks for your help!!!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Creating an ocean

Adrian,
Never use Config objects directly. Use the SimpleOceanLayerOptions API.

Did you zoom in below the max altitude? A quick test works for me.
Glenn Waldron / Pelican Mapping
adrianj adrianj
Reply | Threaded
Open this post in threaded view
|

Re: Creating an ocean

Hi Glen,

Thank you for your response. So I removed the config code and used the API directly. It still doesn't work for me. Here is my code. Am I doing something wrong? I am above the scene looking down and not above the max altitude. The bathymetry and image are working fine.

TMSOptions tmsOptBaseImg;
tmsOptBaseImg.url() = "http://readymap.org/readymap/tiles/1.0.0/22/";
ImageLayerOptions layerOpt("Base Imagery", tmsOptBaseImg);
_baseImageryLayer = new ImageLayer(layerOpt);

GDALOptions gdalOptBaseElevation;
gdalOptBaseElevation.url() = "C:\Temp\topo15.grd"
gdalOptBaseElevation.profile()->srsString() = "+proj=longlat +ellps=WGS84 +datum=WGS84";
_baseElevationLayer = new ElevationLayer("Base Elevation", gdalOptBaseElevation);

SimpleOceanLayerOptions simpleOceanOptions;
simpleOceanOptions.color() = Color::Blue;
simpleOceanOptions.useBathymetry() = true;
simpleOceanOptions.enabled() = true;
simpleOceanOptions.maxAltitude() = 20000;
simpleOceanOptions.visible() = true;
simpleOceanOptions.name() = "Ocean";
simpleOceanOptions.opacity() = 0.5;

SimpleOceanLayer *_ocean = new SimpleOceanLayer(simpleOceanOptions);

_map->addLayer(_baseImageryLayer);
_map->addLayer(_baseElevationLayer);
_map->addLayer(_ocean);

MapNodeOptions mapNodeOptions;
mapNodeOptions.enableLighting() = false;

osgEarth::TerrainOptions terrainOptions;
terrainOptions.enableBlending() = true;
mapNodeOptions.setTerrainOptions(terrainOptions);

_mapNode = new MapNode(_map, mapNodeOptions);


Can you point me in the direction of any documentation or example code for this?

Many thanks for your help!
adrianj adrianj
Reply | Threaded
Open this post in threaded view
|

Re: Creating an ocean

Can anybody help me with this? Let me know what I'm doing wrong, point me in the right direction, give me some example code? Anything would be a great help.

Thank you for your help! :)
adrianj adrianj
Reply | Threaded
Open this post in threaded view
|

Re: Creating an ocean

Hello,

Can anybody advise me what I might be doing wrong? Is this working for anybody else? Would you be able to give me an example of your working code?

Many thanks for your help!

Cheers

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

Re: Creating an ocean

Adrian,
I dropped this code into osgearth_map.cpp and it worked fine. OSG 3.6, osgEarth master branch, GLCORE profile.

    SimpleOceanLayerOptions simpleOceanOptions;
    simpleOceanOptions.color() = Color::Blue;
    simpleOceanOptions.useBathymetry() = true;
    simpleOceanOptions.enabled() = true;
    simpleOceanOptions.maxAltitude() = 20000;
    simpleOceanOptions.visible() = true;
    simpleOceanOptions.name() = "Ocean";
    simpleOceanOptions.opacity() = 0.9;
    SimpleOceanLayer* ocean = new SimpleOceanLayer(simpleOceanOptions);
    map->addLayer(ocean);

Glenn Waldron / Pelican Mapping