OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

FirstPersonManipulator doesn't seem to work with flat map


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [3rdparty]
View previous topic :: View next topic  
Author Message
Rodrigo
User


Joined: 01 Mar 2017
Posts: 24

PostPosted: Mon Jan 14, 2019 8:37 pm    Post subject:
FirstPersonManipulator doesn't seem to work with flat map
Reply with quote

Hi,

I'm using a projected 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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [3rdparty] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Mouse Events are impossible to work with Steal General 0 Fri Mar 15, 2019 4:02 pm View latest post
No new posts osgQt doesn't set a context ID AnyOldName3 General 2 Tue Mar 12, 2019 6:35 pm View latest post
No new posts FirstPersonManipulator doesn't seem t... Rodrigo General [3rdparty] 0 Tue Jan 15, 2019 8:48 pm View latest post
No new posts FirstPersonManipulator doesn't seem t... Rodrigo General [3rdparty] 0 Mon Jan 14, 2019 8:33 pm View latest post
No new posts FirstPersonManipulator doesn't seem t... Rodrigo General [3rdparty] 0 Mon Jan 14, 2019 8:31 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP