[osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth
Rodrigo Dias
rodrigo1406 at gmail.com
Mon Jan 7 14:23:00 PST 2019
Hi Chris,
following the example, I thought I could use directly a PNG instead of a .earth XML. Now I tried a XML.
My source code, main.cpp:
Code:
#include <iostream>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgEarth/ImageLayer>
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarthDrivers/tms/TMSOptions>
#include <osgEarthDrivers/gdal/GDALOptions>
using namespace std;
using namespace osgEarth;
using namespace osgEarth::Drivers;
int main (int argc, char** argv) {
// Create a Map and set it to Geocentric to display a globe
osg::ref_ptr<Map> map = new Map();
cout << 1;
// Add an imagery layer (blue marble from a TMS source)
{
TMSOptions tms;
tms.url() = "br.earth";
osg::ref_ptr<ImageLayer> layer = new ImageLayer( "NASA", tms );
layer->setOpacity(0.5);
printf("\nOpacity: %.2f\n",layer->getOpacity());
map->addLayer( layer );
}
cout << 2 << endl;
}
Compile line:
> g++ main.cpp -lOpenThreads -losg -losgDB -losgUtil -losgViewer -losgEarth -o main
>
The XML file:
> <map name="Brasil" type="projected">
> <image name="br" driver="png">
> <url>br.png</url>
> </image>
> </map>
>
How am I supposed to show you my XML if the tags disappear?
I have a br.png file in the same directory of the program. I don't know if I should specify "br" or "br.png" as the name of the "image" tag, if driver really can contain "png", and if the name of the image should be specified in the "url" tag instead (or both).
Now, when the code runs, it displays:
> 1
> Opacity: 0.50
> [osgEarth]* [TMS] Could not find root TileMap element
> 2
>
Thank you!
Cheers,
Rodrigo
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75405#75405
More information about the osg-users
mailing list