Commit a50b0425 authored by James Goppert's avatar James Goppert

Hooked up map/vehicle buttons for osgearth.

parent 6ad0a690
......@@ -31,20 +31,34 @@ This file is part of the QGROUNDCONTROL project
#include "QMap3D.h"
#include <osgEarthUtil/EarthManipulator>
#include <stdexcept>
#include <QFileDialog>
QMap3D::QMap3D(QWidget * parent, const char * name, WindowFlags f) :
QWidget(parent,f)
{
setupUi(this);
osg::ref_ptr<osg::Node> map = osgDB::readNodeFile("data/yahoo_heightfield.earth");
if (!map) throw std::runtime_error("unable to load file");
graphicsView->updateCamera();
graphicsView->setCameraManipulator(new osgEarthUtil::EarthManipulator);
graphicsView->setSceneData(map);
graphicsView->setSceneData(new osg::Group);
graphicsView->updateCamera();
show();
}
QMap3D::~QMap3D()
{
}
void QMap3D::on_pushButton_map_clicked()
{
QString mapName = QFileDialog::getOpenFileName(this, tr("Select an OsgEarth map file"),
QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("OsgEarth file (*.earth);;"));
graphicsView->getSceneData()->asGroup()->addChild(osgDB::readNodeFile(mapName.toStdString()));
graphicsView->updateCamera();
}
void QMap3D::on_pushButton_vehicle_clicked()
{
QString vehicleName = QFileDialog::getOpenFileName(this, tr("Select a 3D model for your vehicle"),
QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("OsgEarth file (*.osg, *.ac, *.3ds);;"));
graphicsView->getSceneData()->asGroup()->addChild(osgDB::readNodeFile(vehicleName.toStdString()));
graphicsView->updateCamera();
}
......@@ -45,6 +45,9 @@ class QMap3D : public QWidget, private Ui::QMap3D
public:
QMap3D(QWidget * parent = 0, const char * name = 0, WindowFlags f = 0);
~QMap3D();
public slots:
void on_pushButton_map_clicked();
void on_pushButton_vehicle_clicked();
};
#endif // QMAP3D_H
......
......@@ -133,8 +133,7 @@ class ViewerQOSG : public osgViewer::Viewer, public QOSGWidget
void updateCamera()
{
getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
// we want an aspect ratio of 1.0, not: static_cast<double>(width())/static_cast<double>(height())
getCamera()->setProjectionMatrixAsPerspective(30.0f, 1.0f , 1.0f, 10000.0f);
getCamera()->setProjectionMatrixAsPerspective(30.0f, 1.0f , static_cast<double>(width())/static_cast<double>(height()), 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment