setViewpoint question

classic Classic list List threaded Threaded
5 messages Options
jeladi jeladi
Reply | Threaded
Open this post in threaded view
|

setViewpoint question

I am attempting to save/restore viewpoints when the user of my application centers on a model object somewhere on the globe.  Before attaching to the model object I store the current viewpoint from the earth manipulator into a variable.  When the user detaches from the entity I then call setViewpoint on the manipulator to restore the old viewpoint.

However, what I am seeing is that the camera is returning to the original home position at application startup rather than the last saved viewpoint.  The data looks like this:

Viewpoint before attachment (using geodetic SRS)
x=139.245, y=32.2359, z=-1429.55, h=-63.4708, p=-17.739, d=2.98255e+006m, xo=0, yo=0, zo=0

Viewpoint after attachment (using ECEF SRS)
x=-3.95591e+006, y=3.35367e+006, z=3.70033e+006, h=0, p=-30, d=220000m, xo=0, yo=0, zo=0

Viewpoint after detachment (using geodetic SRS)
x=139.245, y=32.2359, z=-1429.55, h=-63.4708, p=-17.739, d=2.98255e+006m, xo=0, yo=0, zo=0

I have printed out the original viewpoint on application startup to verify that the viewpoints are different:

x=-90, y=0.000143905, z=-911.448, h=-2.58447e-020, p=-88.9999, d=1.91353e+007m, xo=0, yo=0, zo=0

Anyone know why the camera is returning to the home position instead of what I am specifying?

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: setViewpoint question

I am a bit confused by all this. Are you saying that you are calling setViewpoint() and it is going to the wrong place?
Glenn Waldron / Pelican Mapping
jeladi jeladi
Reply | Threaded
Open this post in threaded view
|

Re: setViewpoint question

Yes I am calling setViewpoint() and the camera pans to a different point then what is in the supplied viewpoint object.  Now if I take the same viewpoint data and call setViewpoint() immediately upon startup it goes to the right place.  I only see this after I have centered on a model object.

So when the user chooses to look at an object the code looks something like this:

m_untetheredViewpoint = osgEarthManipulator->getViewpoint();

// This is a viewpoint I constructed with the focal point the same as the center of the model
const osgEarth::Viewpoint* vp = modelObj->getViewpoint();

m_tetheredViewpoint = vp;

osgEarthManipulator->setViewpoint(*vp, 1.0);

And when I detach from an object the code looks like this:

if(NULL != m_tetheredViewpoint)
{
      osgEarthManipulator->setViewpoint(m_untetheredViewpoint, 1.0);
      m_tetheredViewpoint = NULL;
}



gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: setViewpoint question

OK. I was able to reproduce this in the osgearth_manip example. If you tether (with '8' or '9') and then go to a viewpoint, it goes to the wrong location. There must be an offset that doesn't get cleared.
Glenn Waldron / Pelican Mapping
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: setViewpoint question

ON second thought, I take that back. (That example had some built-in eyepoints that were overriding the XML viewpoints.) It actually does work as expected...
Glenn Waldron / Pelican Mapping