[osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth

Rodrigo Dias rodrigo1406 at gmail.com
Tue Jan 8 03:32:27 PST 2019


Hi,

Sorry, I didn't post the updated code:


Code:
#include <iostream>
#include <osg/Camera>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <osgViewer/Viewer>
#include <osgEarth/ImageLayer>
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarthDrivers/gdal/GDALOptions>

using namespace std;
using namespace osg;
using namespace osgEarth;
using namespace osgEarth::Drivers;

int main (int argc, char** argv) {
	MapOptions mapOpt;
	mapOpt.coordSysType() = MapOptions::CSTYPE_PROJECTED;
	mapOpt.profile() = ProfileOptions("plate-carre");
	osg::ref_ptr<Map> map = new Map(mapOpt);
	{
		GDALOptions gdal;
		gdal.url() = "br_modified.tif";
		osg::ref_ptr<ImageLayer> layer = new ImageLayer( "BR", gdal );
		map->addLayer( layer );
	}
	{
		GDALOptions gdal;
		gdal.url() = "BRalt.tif";
		osg::ref_ptr<ElevationLayer> layer = new ElevationLayer( "SRTM", gdal );
		map->addLayer( layer );
	}
	osg::ref_ptr<MapNode> mapNode = new MapNode( map );
	osgViewer::Viewer viewer;
	viewer.setSceneData( mapNode.get() );
	viewer.setCameraManipulator( new osgGA::TrackballManipulator );
	while ( !viewer.done() ) {
		viewer.frame();
	}
	return 0;
}




As you can see, I guess I should be seeing some elevation by now, since my image is a square around Brazil, and it includes a good portion of the Andes mountain range (with higher pixels closer to white, and sea level in black).

The texture file is 4392x4392 pixels (1.6 MB on PNG/4-bit-depth and 2.6 MB on TIFF/LZW/8-bit-depth, the difference seems due to bit depth, and I'm not sure if I can use a 4-bit TIFF, but that's ok by now; I'll also try tiling later). The elevation file is 588x588 pixels (70 kB). Both TIFFs are GeoTIFFs.

What I'm trying to accomplish is this: https://www.youtube.com/watch?v=vVm_qWeB9wg

Thank you!

Cheers,
Rodrigo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75423#75423







More information about the osg-users mailing list