You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#define NOMINMAX // To force windows.h to not define macros that interfere with std::min and std::max
#include <windows.h> // Needed by openGL
#include <osgDB/ReadFile>
#include <osgEarth/MapNode>
#include <osgEarth/EarthManipulator>
#include <osgViewer/Viewer>
#include <osgEarth/GLUtils>
int main()
{
osgEarth::setNotifyLevel(osg::INFO); // FATAL WARN NOTICE INFO DEBUG_INFO
std::string earthPath = "world_spherical_mercator.earth";
osgEarth::MapNode* mapNode = osgEarth::MapNode::get(osgDB::readNodeFile(earthPath));
// Setup viewer
osgViewer::Viewer* viewer = new osgViewer::Viewer();
osgEarth::GLUtils::setGlobalDefaults(viewer->getCamera()->getOrCreateStateSet());
viewer->setUpViewInWindow(0, 0, 1024, 768);
viewer->setSceneData(mapNode);
osg::ref_ptr<osg::Camera> camera = viewer->getCamera();
osgEarth::GLUtils::setGlobalDefaults(camera->getOrCreateStateSet());
camera->setDrawBuffer(GL_BACK);
camera->setReadBuffer(GL_BACK);
double left = 0.0;
double right = left + 1024.0;
double bottom = 0.0;
double top = bottom + 768.0;
double zNear = 1.0;
double zFar = 100000000.0; // Not sure what value is reasonable here to be able to zoom far out, but it doesn't seem to affect my problem
camera->setProjectionMatrixAsOrtho(left, right, bottom, top, zNear, zFar);
// Setup manipulator
osg::ref_ptr<osgEarth::EarthManipulator> manipulator = new osgEarth::EarthManipulator();
manipulator->getSettings()->setZoomToMouse(true); // For some reason this makes the map disappear when zooming out
viewer->setCameraManipulator(manipulator);
return viewer->run();
}
When zooming out too far the map disappears, but grabbing it with LMB and panning a bit makes it reappear. Commenting out the setZoomToMouse(true) line fixes the issue. The issue is only present when zooming out with the scroll wheel, zooming out with double right click works as intended.
If I skip defining my own projection matrix the map doesn't disappear, but instead locks up when zooming out too far, and doesn't let me zoom back in. Any ideas? Is there a problem with the calculations for zoom to mouse, or am I doing something wrong?
The text was updated successfully, but these errors were encountered:
There may be issues with zoom-to-mouse in orthographic mode. One workaround may be to call manipulator->setMinMaxDistance() to restrict how far out you can zoom.
We also pushed a patch that was preventing zoom-to-mouse from doing anything in ortho mode. It still doesn't seem to actually zoom to the mouse.
There may be issues with zoom-to-mouse in orthographic mode. One workaround may be to call manipulator->setMinMaxDistance() to restrict how far out you can zoom.
We also pushed a patch that was preventing zoom-to-mouse from doing anything in ortho mode. It still doesn't seem to actually zoom to the mouse.
Thanks! I'll just not use zoom to mouse for now.
Just to let you know it seems to zoom to mouse correctly with an orthographic matrix for me, using the latest released version of OSG Earth. I just have the disappearing issue..
Using the following earth file:
Using the following code:
When zooming out too far the map disappears, but grabbing it with LMB and panning a bit makes it reappear. Commenting out the
setZoomToMouse(true)
line fixes the issue. The issue is only present when zooming out with the scroll wheel, zooming out with double right click works as intended.If I skip defining my own projection matrix the map doesn't disappear, but instead locks up when zooming out too far, and doesn't let me zoom back in. Any ideas? Is there a problem with the calculations for zoom to mouse, or am I doing something wrong?
The text was updated successfully, but these errors were encountered: