Osg-OsgEarth设置视点(水平方位角、垂直俯仰角、焦距)(Qt5.14.2+osgEarht3.6.5+win10)

 垂直俯仰角

 

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 );
}

  

 

posted on 2021-10-14 18:09  疯狂delphi  阅读(1684)  评论(0编辑  收藏  举报

导航