OSG学习之示例遇到的问题二图形不能显示网格模式

6 篇文章 0 订阅
 

代码中加了

viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));

 

但是不能显示成网格模式

解决方法:

W键切换显示模式,如果不行,注意自己是否有输入法错误。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
要在osgEarth中显示模式,您需要使用2D地图视图。以下是一些实现此目的的步骤: 1. 首先,您需要创建一个osgEarth::Map对象,并将其添加到osgViewer::Viewer中。 2. 接下来,您需要创建一个osgEarth::Util::Controls::ControlCanvas对象,并将其添加到osgViewer::Viewer中。 3. 然后,您需要创建一个osgEarth::Util::EarthManipulator对象,并使用setViewpoint方法设置其视点。这将使相机进入2D模式。 4. 最后,您需要创建一个osgEarth::Util::Controls::MapControl对象,并将其添加到ControlCanvas中。这将显示维地图。 以下是示例代码: ``` #include <osgEarth/Map> #include <osgEarth/MapNode> #include <osgEarthUtil/EarthManipulator> #include <osgEarthUtil/Controls> int main(int argc, char** argv) { // 创建Map对象 osg::ref_ptr<osgEarth::Map> map = new osgEarth::Map(); // 创建MapNode对象 osg::ref_ptr<osgEarth::MapNode> mapNode = new osgEarth::MapNode(map); // 创建Viewer对象 osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(); // 将MapNode添加到Viewer中 viewer->setSceneData(mapNode); // 创建ControlCanvas对象 osg::ref_ptr<osgEarth::Util::Controls::ControlCanvas> canvas = new osgEarth::Util::Controls::ControlCanvas(viewer, "HUD"); // 创建EarthManipulator对象,并设置视点 osg::ref_ptr<osgEarth::Util::EarthManipulator> manipulator = new osgEarth::Util::EarthManipulator(); manipulator->setViewpoint(osgEarth::Viewpoint("2D View", 0.0, 0.0, 0.0, 0.0, -90.0, 5000000.0)); // 将EarthManipulator添加到Viewer中 viewer->setCameraManipulator(manipulator); // 创建MapControl对象,并将其添加到ControlCanvas中 osg::ref_ptr<osgEarth::Util::Controls::MapControl> mapControl = new osgEarth::Util::Controls::MapControl(mapNode); canvas->addControl(mapControl); // 运行Viewer return viewer->run(); } ``` 这将显示一个简单的维地图视图。您可以使用osgEarth的其他功能来添加图层、标注等。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值