[osg-users] [3rdparty] FirstPersonManipulator doesn't seem to work with flat map

Rodrigo Dias rodrigo1406 at gmail.com
Tue Jan 15 12:48:07 PST 2019


Hi,

I'm using a projected (flat) map in osgEarth, and TrackballManipulator to move the map with the mouse. In the beginning I see nothing, because the flat map is 0 pixels thick. After I click and push the screen down, I see the map turning towards me, and then I start to see the TIFF texture (br_modified.tif in the code below).

I want to use the keyboard to move the camera around. I've read here and there to try osgGA/FirstPersonManipulator, but when I type in the keyboard (arrows or WASD) I see nothing, the flat map stays 0 pixels thick, and thus invisible. That's the code that works:


Code:
#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;
}




What exactly should I change (beyond substitute TrackballManipulator with FirstPersonManipulator) so that I can move around, as if in a spaceship? (Actually I want to define my own controls, like floating around, change altitude, turn around with the mouse, etc, but I need to grasp the basics first, right?)

Thank you!

Cheers,
Rodrigo

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







More information about the osg-users mailing list