Closed wddl closed 1 year ago
Need more information please: Version? Earth file? Command line?
Need more information please: Version? Earth file? Command line?
@gwaldron thanks to relpy! The master branch I tested around July and osg version3.3 both had this problem, and the other versions were not tested.The problem is more obvious when the camera is very close to the ground. I load a simple image layer with code. The code is as follows:
/**
* How to create a simple osgEarth map and display it.
*/
void initCamera(double longitude , double latitude , double height = 1000.0 , double time = 0)
{
EarthManipulator* em = dynamic_cast<EarthManipulator*>(s_pViewer->getCameraManipulator());
if (em == NULL) {
std::cout << "error in EarthFun::gotoViewpoint: The EarthManipulator ptr is NULL";
return;
}
osgEarth::Viewpoint vp("", longitude, latitude, 0, 0, -90.0, height*2);
em->setViewpoint(vp , time);
}
int main(int argc, char** argv)
{
osgEarth::initialize();
osgViewer::Viewer viewer;
s_pViewer = &viewer;
osgEarth::ProfileOptions profileOpts;
viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
//osg::setNotifyLevel(osg::INFO);
// create the empty map.
Map* map = new Map();
MapNode::Options opt;
//MapNode* node = new MapNode(map, opt);
MapNode* node = new MapNode(map,opt);
s_pMapNode = node;
if (!node)
return -1;
osgEarth::URI uri("http://webst03.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}");
XYZImageLayer* pImageLayerXyz = new XYZImageLayer();
pImageLayerXyz->setName("image");
pImageLayerXyz->setURL(uri);
pImageLayerXyz->setMaxDataLevel(18);
pImageLayerXyz->setProfile(Profile::create("spherical-mercator"));
map->addLayer(pImageLayerXyz);
osg::Camera* cam = viewer.getCamera();
EarthManipulator* pEm = new EarthManipulator;
viewer.setCameraManipulator(pEm);
initSky();
viewer.getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
viewer.setSceneData(node);
viewer.realize();
osgViewer::GraphicsWindow* pWnd = dynamic_cast<osgViewer::GraphicsWindow*>(viewer.getCamera()->getGraphicsContext());
if (pWnd) {
pWnd->setWindowRectangle(500, 100, 1024, 768);
pWnd->setWindowDecoration(true);
}
// add some stock OSG handlers:
MapNodeHelper().configureView(&viewer);
initCamera(116.45391148594297, 39.937132385701631, 20000000);
int r = viewer.run();
return r;
}
I had the same problem. Try the logarithmic depth buffer. See osgearth_city example.
@devil-darkside is right, you probably need the LogarithmicDepthBuffer installed.
osgEarth::Util::LogarithmicDepthBuffer logDepth;
logDepth.install( viewer.getCamera() );
@gwaldron @devil-darkside Thank you very much. The problem has been solved
How to solve this problem?Thanks