Osg-OsgEarth设置视点(水平方位角、垂直俯仰角、焦距)

 垂直俯仰角

Osg焦距

 Osg水平方位角

相关资料:

https://blog.csdn.net/weixin_30604651/article/details/97294201

实例:

.h

    osg::ref_ptr<osgEarth::Util::EarthManipulator> m_pEarthManip;

.cpp

增加操作

    m_pEarthManip = new osgEarth::Util::EarthManipulator;
    m_pViewer->setCameraManipulator(m_pEarthManip);//必须在setViewpoint之前

修改位置

// 垂直俯仰角
void Widget::on_setplane(int value)
{
    qDebug() << "heading: " << m_pEarthManip->getViewpoint().heading()->getValue();
    qDebug() << "pitch: " << m_pEarthManip->getViewpoint().pitch()->getValue();
    qDebug() << "range: " << m_pEarthManip->getViewpoint().range()->getValue();

    osgEarth::Viewpoint vp( "", 107.85, 32.35, 0.0,
                            m_pEarthManip->getViewpoint().heading()->getValue() ,
                            value,
                            m_pEarthManip->getViewpoint().range()->getValue() );
    m_pEarthManip->setViewpoint( vp, 2 );
}
// 水平方位角
void Widget::on_setcourse(int value)
{
    osgEarth::Viewpoint vp( "", 107.85, 32.35, 0.0,
                            value ,
                            m_pEarthManip->getViewpoint().pitch()->getValue(),
                            m_pEarthManip->getViewpoint().range()->getValue() );
    m_pEarthManip->setViewpoint( vp, 2 );
}
// 焦距
void Widget::on_setrange(int value)
{
    osgEarth::Viewpoint vp( "", 107.85, 32.35, 0.0,
                            m_pEarthManip->getViewpoint().heading()->getValue() ,
                            m_pEarthManip->getViewpoint().pitch()->getValue(),
                            value );
    m_pEarthManip->setViewpoint( vp, 2 );
}

  

作者:疯狂Delphi
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.

欢迎关注我,一起进步!扫描下方二维码即可加我

原文地址:https://www.cnblogs.com/FKdelphi/p/15407889.html