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

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM