[osg-users] setViewMatrixAsLookAt not working to set the initial camera position

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Tue May 12 02:14:32 PDT 2020

Hi Rodrigo, 

are you sure about the values of your eye point. As you say your map is
georeferenced but it is certanly projected. So you should check the
projection system used by your map (maybe have a look at
https://epsg.io/?q=Brazil%20kind%3APROJCRS). I think the main problem
may be there. Have you tried maybe by opening your map with an modified
osgviewer and check what the eye position is by default ? 



Le 2020-05-12 11:04, OpenSceneGraph Users a écrit :

> Back at it again... 
> I'm using a Brazil georeferenced map, so I know what coordinates are good enough to be above the country, high enough to see it all, looking down: 
> (...) 
> osgViewer::Viewer viewer;
> viewer.setSceneData( root.get() );
> osg::ref_ptr<OVNIController> controller = new OVNIController(&viewer); // my own WASD flying controller
> viewer.setCameraManipulator(controller);
> viewer.getCamera()->setViewMatrixAsLookAt( osg::Vec3(-55.0f,-15.0f,50.0f), osg::Vec3(), osg::Y_AXIS ); // eye (lon, lat, alt), center, up
> viewer.getCameraManipulator()->home(1);
> viewer.realize();
> while ( !viewer.done() ) { viewer.frame(); }
> return 0;
> I don't know if setViewMatrixAsLookAt() and home() should go before or after realize(). Played with the axis as 3rd parameter for setViewMatrixAsLookAt, but the camera just won't move! Any help, please? 
> On Tuesday, January 8, 2019 at 1:39:53 AM UTC-2, sam wrote: 
> After you set the home position try: viewer.getCameraManipulator()->home(1); 
> Sorry I'm not right in front of my computer right now. 
> On Mon, Jan 7, 2019 at 7:26 PM Rodrigo Dias <rodri... at gmail.com [1]> wrote: Hi Sam,
> By "home" I think you mean
> Code:
> viewer.getCameraManipulator()->setHomePosition( eye, center, up );
> This really changed camera's position, though it's totally freaking out now (I'm still fiddling with the values in eye, center and up).
> But I have no idea what you meant by "delta time", something to go inside the loop?
> Thank you!
> Cheers,
> Rodrigo
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75413#75413 [2]
> _______________________________________________
> osg-users mailing list
> osg-... at lists.openscenegraph.org [1]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org [3]

You received this message because you are subscribed to the Google
Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit
osg-users mailing list
osg-users at lists.openscenegraph.org

[1] http://webmail.onera.fr/./#NOP
[2] http://forum.openscenegraph.org/viewtopic.php?p=75413#75413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200512/03328907/attachment.html>

More information about the osg-users mailing list