[osg-users] How to get current position of osgViewer camera

1,358 views
Skip to first unread message

Paul Leopard

unread,
Aug 22, 2012, 2:21:20 PM8/22/12
to osg-...@lists.openscenegraph.org
I want to query osgViewer to get the current camera position (Note: not the home position). As I move around in a scene I want to know the current coordinates of my eyepoint so that I can save it to a configuration file so that the next time I run my app I can read that position and set it as the home position.

How can I simply get the current eye position (same coordinate frame as the home position is specified in).

Thanks in advance,
Paul

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





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Sergey Polischuk

unread,
Aug 22, 2012, 3:07:27 PM8/22/12
to osg-...@lists.openscenegraph.org
Hi

check if getViewMatrixAsLookAt(...) on viewer camera is sufficient for your needs

Cheers.

22.08.2012, 22:21, "Paul Leopard" <paul.l...@gmail.com>:

Paul Leopard

unread,
Aug 22, 2012, 3:37:17 PM8/22/12
to osg-...@lists.openscenegraph.org
Absolutely perfect.

Thanks so much!
Paul

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

Rodrigo Dias

unread,
May 12, 2020, 4:52:49 AM5/12/20
to OpenSceneGraph Users
I managed to do that inside the `handle` method:

    osg::Vec3d eyePos;
    osg::Matrix matrix = _viewer->getCameraManipulator()->getMatrix();
    eyePos = matrix.getTrans();
    lat = eyePos.y();
    lon = eyePos.x();
    alt = eyePos.z();

Reply all
Reply to author
Forward
0 new messages