1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merged in filnet/librepilot/LP-32_osgearth_follow_up (pull request #268)

LP-32_osgearth_follow_up
This commit is contained in:
Alessio Morale 2016-07-09 14:31:38 +02:00
commit 79764f7392
21 changed files with 622 additions and 211 deletions

View File

@ -2,7 +2,7 @@
# copy osg and osgearth libraries and data to build dir
#
OSG_VERSION = 3.5.1
OSG_VERSION = 3.5.3
contains(QT_ARCH, x86_64) {
LIB_DIR_NAME = lib64
@ -209,6 +209,7 @@ osgearth:win32 {
mingw_osgdb_osgearth_engine_mp$${DS}.dll \
mingw_osgdb_osgearth_sky_simple$${DS}.dll \
mingw_osgdb_osgearth_tms$${DS}.dll \
mingw_osgdb_osgearth_xyz$${DS}.dll \
mingw_osgdb_osgearth_cache_filesystem$${DS}.dll
osgearth_extra:OSGEARTH_PLUGINS += \

View File

@ -123,6 +123,7 @@ public:
if (mapNode) {
geoPoint = osgQtQuick::toGeoPoint(mapNode->getTerrain()->getSRS(), position);
} else {
qWarning() << "OSGGeoTransformNode::onChildNodeChanged - no map node";
geoPoint = osgQtQuick::toGeoPoint(position);
}
if (clampToTerrain && mapNode) {

View File

@ -68,6 +68,9 @@ public:
case ShapeType::Axis:
node = ShapeUtils::create3DAxis();
break;
case ShapeType::Rhombicuboctahedron:
node = ShapeUtils::createRhombicuboctahedron();
break;
}
self->setNode(node);
}

View File

@ -35,7 +35,7 @@ namespace osgQtQuick {
class ShapeType : public QObject {
Q_OBJECT
public:
enum Enum { Cube, Sphere, Torus, Axis };
enum Enum { Cube, Sphere, Torus, Axis, Rhombicuboctahedron };
Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5
};

View File

@ -35,14 +35,13 @@
#include <osg/Node>
#include <osg/Vec4>
#include <osg/DeleteHandler>
#include <osg/GLObjects>
#include <osg/ApplicationUsage>
#include <osgDB/WriteFile>
#include <osgViewer/CompositeViewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/StateSetManipulator>
#include <osgGA/CameraManipulator>
#include <osgUtil/IncrementalCompileOperation>
#include <QOpenGLContext>
#include <QQuickWindow>
@ -53,6 +52,8 @@
#include <QDebug>
#include <iterator>
/*
Debugging tips
- export OSG_NOTIFY_LEVEL=DEBUG
@ -98,10 +99,67 @@
*/
namespace osgQtQuick {
// enum DirtyFlag { Scene = 1 << 0, Camera = 1 << 1 };
// enum DirtyFlag { Scene = 1 << 0, Camera = 1 << 1, Manipulator = 1 << 2, UpdateMode = 1 << 3, IncrementalCompile = 1 << 4 };
class ViewportRenderer;
class MyViewer : public osgViewer::CompositeViewer {
public:
MyViewer() : osgViewer::CompositeViewer()
{}
virtual bool checkNeedToDoFrame()
{
if (_requestRedraw) {
return true;
}
if (_requestContinousUpdate) {
return true;
}
for (RefViews::iterator itr = _views.begin(); itr != _views.end(); ++itr) {
osgViewer::View *view = itr->get();
if (view) {
// If the database pager is going to update the scene the render flag is
// set so that the updates show up
if (view->getDatabasePager()->getDataToCompileListSize() > 0) {
return true;
}
if (view->getDatabasePager()->getDataToMergeListSize() > 0) {
return true;
}
// if (view->getDatabasePager()->requiresUpdateSceneGraph()) return true;
// if (view->getDatabasePager()->getRequestsInProgress()) return true;
// if there update callbacks then we need to do frame.
if (view->getCamera()->getUpdateCallback()) {
return true;
}
if (view->getSceneData() && view->getSceneData()->getUpdateCallback()) {
return true;
}
if (view->getSceneData() && view->getSceneData()->getNumChildrenRequiringUpdateTraversal() > 0) {
return true;
}
}
}
// check if events are available and need processing
if (checkEvents()) {
return true;
}
if (_requestRedraw) {
return true;
}
if (_requestContinousUpdate) {
return true;
}
return false;
}
};
struct OSGViewport::Hidden : public QObject {
Q_OBJECT
@ -114,6 +172,8 @@ private:
int frameTimer;
int frameCount;
osg::ref_ptr<osg::GraphicsContext> gc;
public:
@ -127,15 +187,27 @@ public:
UpdateMode::Enum updateMode;
bool incrementalCompile;
bool busy;
static osg::ref_ptr<osg::GraphicsContext> dummyGC;
static QtKeyboardMap keyMap;
Hidden(OSGViewport *self) : QObject(self), self(self), window(NULL), frameTimer(-1),
sceneNode(NULL), cameraNode(NULL), manipulator(NULL), updateMode(UpdateMode::OnDemand), busy(false)
Hidden(OSGViewport *self) : QObject(self), self(self), window(NULL), frameTimer(-1), frameCount(0),
sceneNode(NULL), cameraNode(NULL), manipulator(NULL),
updateMode(UpdateMode::OnDemand), incrementalCompile(false), busy(false)
{
OsgEarth::initialize();
// workaround to avoid using GraphicsContext #0
// when switching tabs textures are not rebound (see https://librepilot.atlassian.net/secure/attachment/11500/lost_textures.png)
// so we create and retain GraphicsContext #0 so it won't be used elsewhere
if (!dummyGC.valid()) {
dummyGC = createGraphicsContext();
}
createViewer();
connect(self, &OSGViewport::windowChanged, this, &Hidden::onWindowChanged);
@ -143,34 +215,58 @@ public:
~Hidden()
{
disconnect(self);
stopTimer();
destroyViewer();
disconnect(self);
}
public slots:
private slots:
void onWindowChanged(QQuickWindow *window)
{
// qDebug() << "OSGViewport::onWindowChanged" << window;
// osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "onWindowChanged");
if (window) {
// window->setClearBeforeRendering(false);
// connect(window, &QQuickWindow::sceneGraphInitialized, this, &Hidden::onSceneGraphInitialized, Qt::DirectConnection);
// connect(window, &QQuickWindow::sceneGraphAboutToStop, this, &Hidden::onSceneGraphAboutToStop, Qt::DirectConnection);
// connect(window, &QQuickWindow::sceneGraphInvalidated, this, &Hidden::onSceneGraphInvalidated, Qt::DirectConnection);
// connect(window, &QQuickWindow::visibleChanged, this, &Hidden::visibleChanged, Qt::DirectConnection);
// connect(window, &QQuickWindow::widthChanged, this, &Hidden::widthChanged, Qt::DirectConnection);
// connect(window, &QQuickWindow::heightChanged, this, &Hidden::heightChanged, Qt::DirectConnection);
} else {
// if (this->window) {
// disconnect(this->window);
// }
// when hiding the QQuickWidget (happens when switching tab or re-parenting) the renderer is destroyed and sceneGraphInvalidated is signaled
// same happens when deleting the QQuickWidget
// problem is that there is no way to distinguish a hide and a delete so there is no good place to release gl objects, etc.
// it can't be done from other destructors as the gl context is not active at that time
// so we must delete the gl objects when hiding (and release it again when showing)
// deletion of the osg viewer will happen when the QQuickWidget is deleted. the gl context will not be active but it is ok because the
// viewer has no more gl objects to delete (we hope...)
// bad side effect is that when showing the scene after hiding it there is delay (on heavy scenes) to realise again the gl context.
// this is not happening on a separate thread (because of a limitation of QQuickWidget and Qt on windows related limitations)
// a workaround would be to not invalidate the scene when hiding/showing but that is not working atm...
// see https://bugreports.qt.io/browse/QTBUG-54133 for more details
// window->setPersistentSceneGraph(true);
// connect(window, &QQuickWindow::sceneGraphInitialized, this, &Hidden::onSceneGraphInitialized, Qt::DirectConnection);
connect(window, &QQuickWindow::sceneGraphInvalidated, this, &Hidden::onSceneGraphInvalidated, Qt::DirectConnection);
// connect(window, &QQuickWindow::afterSynchronizing, this, &Hidden::onAfterSynchronizing, Qt::DirectConnection);
connect(window, &QQuickWindow::afterSynchronizing, this, &Hidden::onAfterSynchronizing, Qt::DirectConnection);
}
this->window = window;
}
// emitted from the scene graph rendering thread (gl context bound)
void onSceneGraphInitialized()
{
// qDebug() << "OSGViewport::onSceneGraphInitialized";
initializeResources();
}
// emitted from the scene graph rendering thread (gl context bound)
void onSceneGraphInvalidated()
{
// qDebug() << "OSGViewport::onSceneGraphInvalidated";
releaseResources();
}
// emitted from the scene graph rendering thread (gl context bound)
void onAfterSynchronizing()
{
// qDebug() << "OSGViewport::onAfterSynchronizing";
}
public:
bool acceptSceneNode(OSGNode *node)
{
@ -224,17 +320,21 @@ public:
return true;
}
private:
void initializeResources()
{
// qDebug() << "OSGViewport::Hidden::initializeResources";
// osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "OSGViewport::Hidden::initializeResources");
if (gc.valid()) {
// qWarning() << "OSGViewport::initializeResources - gc already created!";
return;
}
// qDebug() << "OSGViewport::initializeResources";
// setup graphics context and camera
gc = createGraphicsContext();
// connect(QOpenGLContext::currentContext(), &QOpenGLContext::aboutToBeDestroyed, this, &Hidden::onAboutToBeDestroyed, Qt::DirectConnection);
cameraNode->setGraphicsContext(gc);
// qDebug() << "OSGViewport::initializeResources - camera" << cameraNode->asCamera();
@ -254,7 +354,6 @@ public:
if (node) {
m->setNode(node);
}
view->home();
} else {
view->setCameraManipulator(NULL, false);
@ -262,24 +361,55 @@ public:
installHanders();
view->init();
viewer->realize();
startTimer();
}
void releaseResources()
void onAboutToBeDestroyed()
{
// qDebug() << "OSGViewport::releaseResources";
if (!gc.valid()) {
qWarning() << "OSGViewport::releaseResources - gc is not valid!";
return;
}
osg::deleteAllGLObjects(gc->getState()->getContextID());
// view->getSceneData()->releaseGLObjects(view->getCamera()->getGraphicsContext()->getState());
// view->getCamera()->releaseGLObjects(view->getCamera()->getGraphicsContext()->getState());
// view->getCamera()->getGraphicsContext()->close();
// view->getCamera()->setGraphicsContext(NULL);
qDebug() << "OSGViewport::Hidden::onAboutToBeDestroyed";
osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "OSGViewport::Hidden::onAboutToBeDestroyed");
// context is not current and don't know how to make it current...
}
// see https://github.com/openscenegraph/OpenSceneGraph/commit/161246d864ea0514543ed0493422e1bf0e99afb7#diff-91ee382a4d543072ea66aab422e5106f
// see https://github.com/openscenegraph/OpenSceneGraph/commit/3e0435febd677f14aae5f42ef1f43e81307fec41#diff-cadcd928403543a531cf42712a3d1126
void releaseResources()
{
// qDebug() << "OSGViewport::Hidden::releaseResources";
// osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "OSGViewport::Hidden::releaseResources");
if (!gc.valid()) {
qWarning() << "OSGViewport::Hidden::releaseResources - gc is not valid!";
return;
}
deleteAllGLObjects();
}
// there should be a simpler way to do that...
// for now, we mimic what is done in GraphicsContext::close()
// calling gc->close() and later gc->realize() does not work
void deleteAllGLObjects()
{
// TODO switch off the graphics thread (see GraphicsContext::close()) ?
// setGraphicsThread(0);
for (osg::GraphicsContext::Cameras::iterator itr = gc->getCameras().begin();
itr != gc->getCameras().end();
++itr) {
osg::Camera *camera = (*itr);
if (camera) {
OSG_INFO << "Releasing GL objects for Camera=" << camera << " _state=" << gc->getState() << std::endl;
camera->releaseGLObjects(gc->getState());
}
}
gc->getState()->releaseGLObjects();
osg::deleteAllGLObjects(gc->getState()->getContextID());
osg::flushAllDeletedGLObjects(gc->getState()->getContextID());
osg::discardAllGLObjects(gc->getState()->getContextID());
}
private:
void createViewer()
{
if (viewer.valid()) {
@ -288,9 +418,10 @@ private:
}
// qDebug() << "OSGViewport::createViewer";
viewer = new osgViewer::CompositeViewer();
viewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
viewer = new MyViewer();
// viewer = new osgViewer::CompositeViewer();
viewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
// disable the default setting of viewer.done() by pressing Escape.
viewer->setKeyEventSetsDone(0);
@ -300,17 +431,6 @@ private:
viewer->addView(view);
}
void destroyViewer()
{
if (!viewer.valid()) {
qWarning() << "OSGViewport::destroyViewer - viewer is not valid";
return;
}
// qDebug() << "OSGViewport::destroyViewer";
viewer = NULL;
}
osgViewer::View *createView()
{
// qDebug() << "OSGViewport::createView";
@ -382,12 +502,17 @@ private:
// if (traits->displayNum < 0) {
// traits->displayNum = 0;
// }
traits->windowingSystemPreference = "QT";
#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 3)
// The MyQt windowing system is registered in osgearth.cpp
traits->windowingSystemPreference = "MyQt";
#endif
traits->windowDecoration = false;
traits->x = 0;
traits->y = 0;
int dpr = self->window()->devicePixelRatio();
int dpr = self->window() ? self->window()->devicePixelRatio() : 1;
traits->width = self->width() * dpr;
traits->height = self->height() * dpr;
@ -406,7 +531,7 @@ private:
void startTimer()
{
if ((updateMode != UpdateMode::Continuous) && (frameTimer < 0)) {
if ((frameTimer < 0) && (updateMode != UpdateMode::Continuous)) {
// qDebug() << "OSGViewport::startTimer - starting timer";
frameTimer = QObject::startTimer(33, Qt::PreciseTimer);
}
@ -422,7 +547,6 @@ private:
}
protected:
void timerEvent(QTimerEvent *event)
{
if (event->timerId() == frameTimer) {
@ -435,7 +559,6 @@ protected:
private slots:
void onSceneNodeChanged(osg::Node *node)
{
qWarning() << "OSGViewport::onSceneNodeChanged - not implemented";
@ -453,15 +576,14 @@ class ViewportRenderer : public QQuickFramebufferObject::Renderer {
private:
OSGViewport::Hidden *const h;
int frameCount;
bool initFrame;
bool needToDoFrame;
public:
ViewportRenderer(OSGViewport::Hidden *h) : h(h), frameCount(0), needToDoFrame(false)
ViewportRenderer(OSGViewport::Hidden *h) : h(h), initFrame(true), needToDoFrame(false)
{
// qDebug() << "ViewportRenderer::ViewportRenderer";
// osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "ViewportRenderer::ViewportRenderer");
h->initializeResources();
}
@ -469,6 +591,7 @@ public:
{
// qDebug() << "ViewportRenderer::~ViewportRenderer";
// osgQtQuick::openGLContextInfo(QOpenGLContext::currentContext(), "ViewportRenderer::~ViewportRenderer");
// h->releaseResources();
}
// This function is the only place when it is safe for the renderer and the item to read and write each others members.
@ -487,16 +610,21 @@ public:
return;
}
// TODO this is not correct : switching workspaces in GCS will destroy and recreate the renderer (and frameCount is thus reset to 0).
if (frameCount == 0) {
h->view->init();
if (!h->viewer->isRealized()) {
h->viewer->realize();
}
if (initFrame) {
// workaround for https://bugreports.qt.io/browse/QTBUG-54073
// busy indicator starting to spin indefinitly when switching tabs
h->self->setBusy(true);
h->self->setBusy(false);
}
// we always want to draw the first frame
needToDoFrame = (frameCount == 0);
// NOTES:
// - needToDoFrame is always orred so "last" value is preserved. Make sure to set it to false if needed.
// - when switching tabs or re-parenting, the renderer is destroyed and recreated
// some special care is taken in case a renderer is (re)created;
// a new renderer will have initFrame set to true for the duration of the first frame
// draw first frame of freshly initialized renderer
needToDoFrame |= initFrame;
// if not on-demand then do frame
if (h->updateMode != UpdateMode::OnDemand) {
@ -505,44 +633,26 @@ public:
// check if viewport needs to be resized
// a redraw will be requested if necessary
osg::Viewport *viewport = h->view->getCamera()->getViewport();
// not really event driven...
int dpr = h->self->window()->devicePixelRatio();
int width = item->width() * dpr;
int height = item->height() * dpr;
if ((viewport->width() != width) || (viewport->height() != height)) {
// qDebug() << "*** RESIZE" << frameCount << viewport->width() << "x" << viewport->height() << "->" << width << "x" << height;
osg::Viewport *viewport = h->view->getCamera()->getViewport();
if (initFrame || (viewport->width() != width) || (viewport->height() != height)) {
// qDebug() << "*** RESIZE" << h->frameCount << << initFrame << viewport->width() << "x" << viewport->height() << "->" << width << "x" << height;
needToDoFrame = true;
// h->view->getCamera()->resize(width, height);
h->view->getCamera()->getGraphicsContext()->resized(0, 0, width, height);
h->gc->resized(0, 0, width, height);
h->view->getEventQueue()->windowResize(0, 0, width, height /*, resizeTime*/);
// trick to force a "home" on first few frames to absorb initial spurious resizes
if (frameCount <= 2) {
if (h->frameCount <= 2) {
h->view->home();
}
}
// refresh busy state
// TODO state becomes busy when scene is loading or downloading tiles (should do it only for download)
h->self->setBusy(h->view->getDatabasePager()->getRequestsInProgress());
// TODO also expose request list size to Qml
if (h->view->getDatabasePager()->getFileRequestListSize() > 0) {
// qDebug() << h->view->getDatabasePager()->getFileRequestListSize();
}
if (!needToDoFrame) {
needToDoFrame = h->viewer->checkNeedToDoFrame();
}
// workarounds to osg issues
if (!needToDoFrame) {
// issue 1 : if only root node has an update callback checkNeedToDoFrame should return true but does not
// a fix will be submitted to osg (current version is 3.5.1)
if (h->view->getSceneData()) {
needToDoFrame |= !(h->view->getSceneData()->getUpdateCallback() == NULL);
}
}
if (!needToDoFrame) {
// issue 2 : UI events don't trigger a redraw
// issue : UI events don't trigger a redraw
// this issue should be fixed here...
// event handling needs a lot of attention :
// - sometimes the scene is redrawing continuously (after a drag for example, and single click will stop continuous redraw)
@ -550,12 +660,21 @@ public:
// - in Earth View : continuous zoom (triggered by holding right button and moving mouse up/down) sometimes stops working when holding mouse still after initiating
needToDoFrame = !h->view->getEventQueue()->empty();
}
if (!needToDoFrame) {
needToDoFrame = h->viewer->checkNeedToDoFrame();
}
if (needToDoFrame) {
// qDebug() << "ViewportRenderer::synchronize - update scene" << frameCount;
// qDebug() << "ViewportRenderer::synchronize - update scene" << h->frameCount;
h->viewer->advance();
h->viewer->eventTraversal();
h->viewer->updateTraversal();
}
// refresh busy state
// TODO state becomes busy when scene is loading or downloading tiles (should do it only for download)
// TODO also expose request list size to Qml
h->self->setBusy(h->view->getDatabasePager()->getRequestsInProgress());
}
// This function is called when the FBO should be rendered into.
@ -571,11 +690,13 @@ public:
}
if (needToDoFrame) {
// qDebug() << "ViewportRenderer::render - render scene" << frameCount;
// qDebug() << "ViewportRenderer::render - render scene" << h->frameCount;
// needed to properly render models without terrain (Qt bug?)
QOpenGLContext::currentContext()->functions()->glUseProgram(0);
h->viewer->renderingTraversals();
needToDoFrame = false;
}
@ -584,7 +705,8 @@ public:
update();
}
++frameCount;
++(h->frameCount);
initFrame = false;
}
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size)
@ -602,6 +724,8 @@ public:
QtKeyboardMap OSGViewport::Hidden::keyMap = QtKeyboardMap();
osg::ref_ptr<osg::GraphicsContext> OSGViewport::Hidden::dummyGC;
/* class OSGViewport */
OSGViewport::OSGViewport(QQuickItem *parent) : Inherited(parent), h(new Hidden(this))
@ -668,7 +792,6 @@ OSGCameraManipulator *OSGViewport::manipulator() const
void OSGViewport::setManipulator(OSGCameraManipulator *manipulator)
{
if (h->acceptManipulator(manipulator)) {
// setDirty(Manipulator);
emit manipulatorChanged(manipulator);
}
}
@ -686,12 +809,28 @@ void OSGViewport::setUpdateMode(UpdateMode::Enum mode)
}
}
bool OSGViewport::incrementalCompile() const
{
return h->incrementalCompile;
}
void OSGViewport::setIncrementalCompile(bool incrementalCompile)
{
if (h->incrementalCompile != incrementalCompile) {
h->incrementalCompile = incrementalCompile;
// setDirty(IncrementalCompile);
// TODO not thread safe...
h->viewer->setIncrementalCompileOperation(incrementalCompile ? new osgUtil::IncrementalCompileOperation() : NULL);
emit incrementalCompileChanged(incrementalCompile);
}
}
bool OSGViewport::busy() const
{
return h->busy;
}
void OSGViewport::setBusy(const bool busy)
void OSGViewport::setBusy(bool busy)
{
if (h->busy != busy) {
h->busy = busy;
@ -711,12 +850,6 @@ QQuickFramebufferObject::Renderer *OSGViewport::createRenderer() const
return new ViewportRenderer(h);
}
void OSGViewport::releaseResources()
{
// qDebug() << "OSGViewport::releaseResources" << this;
Inherited::releaseResources();
}
void OSGViewport::classBegin()
{
// qDebug() << "OSGViewport::classBegin" << this;
@ -729,14 +862,6 @@ void OSGViewport::componentComplete()
Inherited::componentComplete();
}
QPointF OSGViewport::mousePoint(QMouseEvent *event)
{
qreal x = 2.0 * (event->x() - width() / 2) / width();
qreal y = 2.0 * (event->y() - height() / 2) / height();
return QPointF(x, y);
}
void OSGViewport::mousePressEvent(QMouseEvent *event)
{
int button = 0;
@ -751,26 +876,7 @@ void OSGViewport::mousePressEvent(QMouseEvent *event)
setKeyboardModifiers(event);
QPointF pos = mousePoint(event);
if (h->view.valid()) {
h->view.get()->getEventQueue()->mouseButtonPress(pos.x(), pos.y(), button);
}
}
void OSGViewport::setKeyboardModifiers(QInputEvent *event)
{
int modkey = event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier);
unsigned int mask = 0;
if (modkey & Qt::ShiftModifier) {
mask |= osgGA::GUIEventAdapter::MODKEY_SHIFT;
}
if (modkey & Qt::ControlModifier) {
mask |= osgGA::GUIEventAdapter::MODKEY_CTRL;
}
if (modkey & Qt::AltModifier) {
mask |= osgGA::GUIEventAdapter::MODKEY_ALT;
}
if (h->view.valid()) {
h->view.get()->getEventQueue()->getCurrentEventState()->setModKeyMask(mask);
h->view->getEventQueue()->mouseButtonPress(pos.x(), pos.y(), button);
}
}
@ -779,7 +885,7 @@ void OSGViewport::mouseMoveEvent(QMouseEvent *event)
setKeyboardModifiers(event);
QPointF pos = mousePoint(event);
if (h->view.valid()) {
h->view.get()->getEventQueue()->mouseMotion(pos.x(), pos.y());
h->view->getEventQueue()->mouseMotion(pos.x(), pos.y());
}
}
@ -797,7 +903,7 @@ void OSGViewport::mouseReleaseEvent(QMouseEvent *event)
setKeyboardModifiers(event);
QPointF pos = mousePoint(event);
if (h->view.valid()) {
h->view.get()->getEventQueue()->mouseButtonRelease(pos.x(), pos.y(), button);
h->view->getEventQueue()->mouseButtonRelease(pos.x(), pos.y(), button);
}
}
@ -809,7 +915,7 @@ void OSGViewport::wheelEvent(QWheelEvent *event)
(event->delta() > 0 ? osgGA::GUIEventAdapter::SCROLL_LEFT : osgGA::GUIEventAdapter::SCROLL_RIGHT);
if (h->view.valid()) {
h->view.get()->getEventQueue()->mouseScroll(motion);
h->view->getEventQueue()->mouseScroll(motion);
}
}
@ -818,7 +924,7 @@ void OSGViewport::keyPressEvent(QKeyEvent *event)
setKeyboardModifiers(event);
int value = h->keyMap.remapKey(event);
if (h->view.valid()) {
h->view.get()->getEventQueue()->keyPress(value);
h->view->getEventQueue()->keyPress(value);
}
// this passes the event to the regular Qt key event processing,
@ -836,7 +942,7 @@ void OSGViewport::keyReleaseEvent(QKeyEvent *event)
setKeyboardModifiers(event);
int value = h->keyMap.remapKey(event);
if (h->view.valid()) {
h->view.get()->getEventQueue()->keyRelease(value);
h->view->getEventQueue()->keyRelease(value);
}
}
@ -846,6 +952,39 @@ void OSGViewport::keyReleaseEvent(QKeyEvent *event)
// if( _forwardKeyEvents )
// Inherited::keyReleaseEvent(event);
}
QPointF OSGViewport::mousePoint(QMouseEvent *event)
{
qreal x, y;
if (h->view.valid() && h->view->getEventQueue()->getUseFixedMouseInputRange()) {
x = 2.0 * (event->x() - width() / 2) / width();
y = 2.0 * (event->y() - height() / 2) / height();
} else {
x = event->x();
y = event->y();
}
return QPointF(x, y);
}
void OSGViewport::setKeyboardModifiers(QInputEvent *event)
{
int modkey = event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier);
unsigned int mask = 0;
if (modkey & Qt::ShiftModifier) {
mask |= osgGA::GUIEventAdapter::MODKEY_SHIFT;
}
if (modkey & Qt::ControlModifier) {
mask |= osgGA::GUIEventAdapter::MODKEY_CTRL;
}
if (modkey & Qt::AltModifier) {
mask |= osgGA::GUIEventAdapter::MODKEY_ALT;
}
if (h->view.valid()) {
h->view->getEventQueue()->getCurrentEventState()->setModKeyMask(mask);
}
}
} // namespace osgQtQuick
#include "OSGViewport.moc"

View File

@ -55,6 +55,7 @@ class OSGQTQUICK_EXPORT OSGViewport : public QQuickFramebufferObject {
Q_PROPERTY(osgQtQuick::OSGCamera * camera READ cameraNode WRITE setCameraNode NOTIFY cameraNodeChanged)
Q_PROPERTY(osgQtQuick::OSGCameraManipulator * manipulator READ manipulator WRITE setManipulator NOTIFY manipulatorChanged)
Q_PROPERTY(osgQtQuick::UpdateMode::Enum updateMode READ updateMode WRITE setUpdateMode NOTIFY updateModeChanged)
Q_PROPERTY(bool incrementalCompile READ incrementalCompile WRITE setIncrementalCompile NOTIFY incrementalCompileChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
typedef QQuickFramebufferObject Inherited;
@ -77,25 +78,29 @@ public:
UpdateMode::Enum updateMode() const;
void setUpdateMode(UpdateMode::Enum mode);
bool busy() const;
void setBusy(const bool busy);
bool incrementalCompile() const;
void setIncrementalCompile(bool busy);
Renderer *createRenderer() const;
void releaseResources();
bool busy() const;
void setBusy(bool busy);
osgViewer::View *asView() const;
Renderer *createRenderer() const;
signals:
void sceneNodeChanged(OSGNode *node);
void cameraNodeChanged(OSGCamera *node);
void manipulatorChanged(OSGCameraManipulator *manipulator);
void updateModeChanged(UpdateMode::Enum mode);
void sceneNodeChanged(OSGNode *);
void cameraNodeChanged(OSGCamera *);
void manipulatorChanged(OSGCameraManipulator *);
void updateModeChanged(UpdateMode::Enum);
void incrementalCompileChanged(bool);
void busyChanged(bool busy);
protected:
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
QSGNode *updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *nodeData) override;
#endif
// QQmlParserStatus
void classBegin();
void componentComplete();
// QQuickItem
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@ -104,16 +109,17 @@ protected:
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void setKeyboardModifiers(QInputEvent *event);
QPointF mousePoint(QMouseEvent *event);
// QQmlParserStatus
void classBegin();
void componentComplete();
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
// QQuickFramebufferObject
QSGNode *updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *nodeData) override;
#endif
private:
struct Hidden;
Hidden *const h;
void setKeyboardModifiers(QInputEvent *event);
QPointF mousePoint(QMouseEvent *event);
};
} // namespace osgQtQuick

View File

@ -38,6 +38,7 @@
#include <osgEarth/GeoData>
#include <osgEarth/MapNode>
#include <osgEarth/Terrain>
#include <QDebug>
@ -208,7 +209,9 @@ void MyManipulator::updateCamera(osg::Camera & camera)
/* class OSGGeoTransformManipulator */
OSGGeoTransformManipulator::OSGGeoTransformManipulator(QObject *parent) : Inherited(parent), h(new Hidden(this))
{}
{
setDirty(Position | Attitude | Clamp);
}
OSGGeoTransformManipulator::~OSGGeoTransformManipulator()
{

View File

@ -98,8 +98,8 @@ void OsgEarth::initialize()
// setenv("OSG_ASSIGN_PBO_TO_IMAGES", "on", 0);
// Number of threads in the DatbasePager set up, inclusive of the number of http dedicated threads.
osg::DisplaySettings::instance()->setNumOfDatabaseThreadsHint(6);
osg::DisplaySettings::instance()->setNumOfHttpDatabaseThreadsHint(3);
osg::DisplaySettings::instance()->setNumOfDatabaseThreadsHint(8);
osg::DisplaySettings::instance()->setNumOfHttpDatabaseThreadsHint(4);
initializePathes();
@ -128,27 +128,19 @@ void OsgEarth::initializePathes()
void OsgEarth::initializeCache()
{
#ifdef USE_OSGEARTH
QString cachePath = Utils::GetStoragePath() + "osgearth/cache";
osgEarth::Drivers::FileSystemCacheOptions cacheOptions;
qputenv("OSGEARTH_CACHE_PATH", cachePath.toLatin1());
cacheOptions.rootPath() = cachePath.toStdString();
const osgEarth::CachePolicy cachePolicy(osgEarth::CachePolicy::USAGE_READ_WRITE);
osg::ref_ptr<osgEarth::Cache> cache = osgEarth::CacheFactory::create(cacheOptions);
if (cache->isOK()) {
// set cache
osgEarth::Registry::instance()->setCache(cache.get());
// The default cache policy used when no policy is set elsewhere
osgEarth::Registry::instance()->setDefaultCachePolicy(cachePolicy);
// set cache policy
const osgEarth::CachePolicy cachePolicy(osgEarth::CachePolicy::USAGE_READ_WRITE);
// The override cache policy (overrides all others if set)
// osgEarth::Registry::instance()->setOverrideCachePolicy(cachePolicy);
// The default cache policy used when no policy is set elsewhere
osgEarth::Registry::instance()->setDefaultCachePolicy(cachePolicy);
// The override cache policy (overrides all others if set)
// osgEarth::Registry::instance()->setOverrideCachePolicy(cachePolicy);
} else {
qWarning() << "OsgEarth::initializeCache - Failed to initialize cache";
}
#endif // ifdef USE_OSGEARTH
}
@ -229,7 +221,13 @@ void QtNotifyHandler::notify(osg::NotifySeverity severity, const char *message)
}
}
#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 3)
REGISTER_WINDOWINGSYSTEMINTERFACE(MyQt, QtWindowingSystem)
#endif
void OsgEarth::initWindowingSystem()
{
#if OSG_VERSION_LESS_THAN(3, 5, 3)
osg::GraphicsContext::setWindowingSystemInterface(QtWindowingSystem::getInterface());
#endif
}

View File

@ -15,14 +15,9 @@ contains(QT_ARCH, x86_64) {
}
osg {
win32 {
OSG_SDK_DIR = $$clean_path($$[QT_INSTALL_BINS]/..)
} else {
OSG_SDK_DIR = $$clean_path($$(OSG_SDK_DIR))
}
OSG_SDK_DIR = $$clean_path($$(OSG_SDK_DIR))
message(Using osg from here: $$OSG_SDK_DIR)
linux|macx {
INCLUDEPATH += $$OSG_SDK_DIR/include
LIBS += -L$$OSG_SDK_DIR/$$LIB_DIR_NAME
@ -37,14 +32,9 @@ osg {
}
osgearth {
win32 {
OSGEARTH_SDK_DIR = $$clean_path($$[QT_INSTALL_BINS]/..)
} else {
OSGEARTH_SDK_DIR = $$clean_path($$(OSGEARTH_SDK_DIR))
}
OSGEARTH_SDK_DIR = $$clean_path($$(OSGEARTH_SDK_DIR))
message(Using osgearth from here: $$OSGEARTH_SDK_DIR)
linux|macx {
INCLUDEPATH += $$OSGEARTH_SDK_DIR/include
LIBS += -L$$OSGEARTH_SDK_DIR/$$LIB_DIR_NAME

View File

@ -86,7 +86,6 @@ protected:
bool _initialized;
bool _valid;
bool _realized;
bool _closing;
bool _owned;
@ -98,7 +97,6 @@ GraphicsWindowQt::GraphicsWindowQt(osg::GraphicsContext::Traits *traits) :
_initialized(false),
_valid(false),
_realized(false),
_closing(false),
_owned(false),
_glContext(NULL),
_surface(NULL)
@ -111,13 +109,13 @@ GraphicsWindowQt::GraphicsWindowQt(osg::GraphicsContext::Traits *traits) :
GraphicsWindowQt::~GraphicsWindowQt()
{
// qDebug() << "GraphicsWindowQt::~GraphicsWindowQt";
close();
close(true);
}
void GraphicsWindowQt::init()
{
// qDebug() << "GraphicsWindowQt::init";
if (_closing || _initialized) {
if (_initialized) {
return;
}
@ -238,20 +236,18 @@ bool GraphicsWindowQt::realizeImplementation()
// make current
_realized = true;
bool result = makeCurrent();
_realized = false;
bool current = makeCurrent();
// fail if we do not have current context
if (!result) {
if (!current) {
// if ( savedContext )
// const_cast< QGLContext* >( savedContext )->makeCurrent();
//
qWarning() << "GraphicsWindowQt::realizeImplementation - can not make context current.";
_realized = false;
return false;
}
_realized = true;
// make sure the event queue has the correct window rectangle size and input range
#if OSG_VERSION_GREATER_OR_EQUAL(3, 4, 0)
getEventQueue()->syncWindowRectangleWithGraphicsContext();
@ -270,7 +266,7 @@ bool GraphicsWindowQt::realizeImplementation()
// if ( savedContext )
// const_cast< QGLContext* >( savedContext )->makeCurrent();
return true;
return _realized;
}
bool GraphicsWindowQt::isRealizedImplementation() const
@ -294,11 +290,15 @@ void GraphicsWindowQt::runOperations()
bool GraphicsWindowQt::makeCurrentImplementation()
{
if (!_glContext) {
qWarning() << "GraphicsWindowQt::makeCurrentImplementation() - no context.";
return false;
}
if (!_realized) {
qWarning() << "GraphicsWindowQt::makeCurrentImplementation() - not realized; cannot make current.";
return false;
}
if (_owned && _glContext) {
if (_owned) {
if (!_glContext->makeCurrent(_surface)) {
qWarning() << "GraphicsWindowQt::makeCurrentImplementation : failed to make context current";
return false;
@ -306,6 +306,7 @@ bool GraphicsWindowQt::makeCurrentImplementation()
}
if (_glContext != QOpenGLContext::currentContext()) {
qWarning() << "GraphicsWindowQt::makeCurrentImplementation : context is not current";
// abort();
return false;
}
return true;
@ -313,13 +314,20 @@ bool GraphicsWindowQt::makeCurrentImplementation()
bool GraphicsWindowQt::releaseContextImplementation()
{
if (!_glContext) {
qWarning() << "GraphicsWindowQt::releaseContextImplementation() - no context.";
return false;
}
if (_glContext != QOpenGLContext::currentContext()) {
qWarning() << "GraphicsWindowQt::releaseContextImplementation : context is not current";
return false;
}
if (_owned && _glContext) {
if (_owned) {
// qDebug() << "GraphicsWindowQt::releaseContextImplementation";
_glContext->doneCurrent();
if (_glContext == QOpenGLContext::currentContext()) {
qWarning() << "GraphicsWindowQt::releaseContextImplementation : context is still current";
}
}
return true;
}
@ -327,7 +335,6 @@ bool GraphicsWindowQt::releaseContextImplementation()
void GraphicsWindowQt::closeImplementation()
{
// qDebug() << "GraphicsWindowQt::closeImplementation";
_closing = true;
_initialized = false;
_valid = false;
_realized = false;

View File

@ -50,7 +50,6 @@ osg::Geode *createCube()
// Declare a instance of the geode class:
osg::Geode *geode = new osg::Geode();
// Add the unit cube drawable to the geode:
geode->addDrawable(unitCubeDrawable);
@ -239,6 +238,7 @@ osg::Geode *createTorus(float innerRadius, float outerRadius, float sweepCuts, f
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
geometry->setStateSet(stateset);
geometry->setVertexArray(vertices);
osg::Vec4Array *colors = new osg::Vec4Array;
@ -258,4 +258,190 @@ osg::Geode *createTorus(float innerRadius, float outerRadius, float sweepCuts, f
return geode.release();
}
osg::Geode *createRhombicuboctahedron()
{
// Top *
// Bottom o
// Front ^
// Stern v
// Left <
// Right >
const double alpha = 1; // 0.65;
const osg::Vec4 colors[] = {
osg::Vec4(0.7, 0.5, 0.7, alpha), // TFR
osg::Vec4(0.9, 0.9, 0.9, alpha), // T
osg::Vec4(0.5, 0.7, 0.7, alpha), // TFL
osg::Vec4(1.0, 0.7, 0.7, alpha), // TS
osg::Vec4(0.7, 0.7, 1.0, alpha), // TF
osg::Vec4(0.5, 0.0, 0.7, alpha), // BFR
osg::Vec4(0.5, 0.5, 1.0, alpha), // F
osg::Vec4(0.1, 0.5, 0.7, alpha), // BFL
osg::Vec4(0.9, 0.5, 0.9, alpha), // TR
osg::Vec4(0.5, 0.0, 0.5, alpha), // R
osg::Vec4(1.0, 0.5, 0.7, alpha), // TSR
osg::Vec4(0.2, 0.0, 0.2, alpha), // BR
osg::Vec4(0.2, 0.2, 1.0, alpha), // BF
osg::Vec4(0.7, 0.0, 0.2, alpha), // BSR
osg::Vec4(0.1, 0.1, 0.1, alpha), // B
osg::Vec4(0.5, 0.5, 0.2, alpha), // BSL
osg::Vec4(0.9, 0.0, 0.4, alpha), // SR
osg::Vec4(1.0, 0.2, 0.2, alpha), // BS
osg::Vec4(1.0, 0.5, 0.5, alpha), // S
osg::Vec4(0.7, 0.7, 0.5, alpha), // SL
osg::Vec4(0.5, 0.9, 0.5, alpha), // TL
osg::Vec4(0.5, 0.7, 0.5, alpha), // L
osg::Vec4(1.0, 1.0, 0.7, alpha), // TSL
osg::Vec4(0.2, 0.5, 0.2, alpha), // BL
osg::Vec4(0.5, 0.0, 0.8, alpha), // FR
osg::Vec4(0.5, 0.7, 1.0, alpha) // FL
};
const double no = -1.0;
const double po = 1.0f;
const double ps = 1.0 + sqrt(1.0);
const double ns = -ps;
const osg::Vec3 vertices[] = {
osg::Vec3(po, po, ps),
osg::Vec3(po, no, ps),
osg::Vec3(no, po, ps),
osg::Vec3(no, no, ps),
osg::Vec3(po, ps, po),
osg::Vec3(po, ps, no),
osg::Vec3(no, ps, po),
osg::Vec3(no, ps, no),
osg::Vec3(ps, po, po),
osg::Vec3(ps, po, no),
osg::Vec3(ps, no, po),
osg::Vec3(ps, no, no),
osg::Vec3(po, po, ns),
osg::Vec3(po, no, ns),
osg::Vec3(no, po, ns),
osg::Vec3(no, no, ns),
osg::Vec3(po, ns, po),
osg::Vec3(po, ns, no),
osg::Vec3(no, ns, po),
osg::Vec3(no, ns, no),
osg::Vec3(ns, po, po),
osg::Vec3(ns, po, no),
osg::Vec3(ns, no, po),
osg::Vec3(ns, no, no),
// bonus vertices to map unique colors
// we have only 24 regular vertices, but 26 faces
osg::Vec3(ps, po, no), // copy from vertex 9
osg::Vec3(no, ps, no) // copy from vertex 7
};
const unsigned int indices[] = {
// PITCH ROLL YAW
8, 4, 0, // TFR 45 -45
0, 2, 1, // T1 0 0
3, 2, 1, // T2
6, 20, 2, // TFL 45 45
1, 16, 3, // TS1 -45 0
18, 16, 3, // TS2
0, 2, 4, // TF1 45 0
6, 2, 4, // TF2
12, 9, 5, // BFR 45 -135
4, 5, 6, // F1 90 X
7, 5, 6, // F2
14, 21, 7, // BFL 45 135
0, 1, 8, // TR1 0 -45
10, 1, 8, // TR2
8, 10, 9, // R1 0 -90
11, 10, 9, // R2
1, 16, 10, // TSR -45 -45
// PITCH ROLL YAW
13, 12, 11, // BR1 0 -135
9, 12, 11, // BR2
5, 7, 12, // BF1 45 +-180
14, 7, 12, // BF2
11, 17, 13, // BSR -45 -135
12, 13, 14, // B1 0 +-180
15, 13, 14, // B2
19, 23, 15, // BSL -45 135
11, 17, 16, // SR1 -45 -90
11, 10, 16, // SR2
13, 15, 17, // BS1 -45 +-180
19, 15, 17, // BS2
16, 17, 18, // S1 -90 X
19, 17, 18, // S2
18, 22, 19, // SL -45 90
22, 23, 19, // SL
// PITCH ROLL YAW
2, 3, 20, // TL1 0 45
22, 3, 20, // TL2
20, 22, 21, // L1 0 90
23, 22, 21, // L2
3, 18, 22, // TSL -45 45
14, 15, 23, // BL1 0 135
14, 21, 23, // BL2
// last vertex is equal to vertex 9 to map a unique color
4, 5, 24, // FR 45 -90
4, 8, 24, // FR
// last vertex is equal to vertex 7 to map a unique color
6, 20, 25, // FL 45 90
21, 20, 25 // FL
};
osg::ShadeModel *shademodel = new osg::ShadeModel;
shademodel->setMode(osg::ShadeModel::FLAT);
osg::StateSet *stateset = new osg::StateSet;
stateset->setAttribute(shademodel);
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
geom->setStateSet(stateset);
unsigned int vertexCount = sizeof(vertices) / sizeof(vertices[0]);
osg::Vec3Array *vertexArray = new osg::Vec3Array(vertexCount, const_cast<osg::Vec3 *>(&vertices[0]));
geom->setVertexArray(vertexArray);
unsigned int indexCount = sizeof(indices) / sizeof(indices[0]);
geom->addPrimitiveSet(new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, indexCount, indices));
unsigned int colorCount = sizeof(colors) / sizeof(colors[0]);
osg::Vec4Array *colorArray = new osg::Vec4Array(colorCount, const_cast<osg::Vec4 *>(&colors[0]));
geom->setColorArray(colorArray);
geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
// geometry->setNormalArray(normals);
// geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(geom.get());
return geode.release();
}
}

View File

@ -16,6 +16,7 @@ osg::PositionAttitudeTransform *createArrow(const osg::Vec4 &color);
osg::Node *create3DAxis();
osg::Node *createOrientatedTorus(float innerRadius, float outerRadius);
osg::Geode *createTorus(float innerRadius, float outerRadius, float sweepCuts, float sphereCuts);
osg::Geode *createRhombicuboctahedron();
}
#endif /* SHAPE_UTILS_H */

View File

@ -0,0 +1,23 @@
<!--
Mircosoft Bing Maps example.
Usage of Bing Maps requires a key. Get a key here:
http://www.bing.com/developers/
Bing Maps Terms of Service:
http://www.microsoft.com/maps/product/terms.html
Supported imagery sets are Aerial, AerialWithLabels, and Road.
-->
<map>
<options>
<!--overlay_resolution_ratio="1.0"/-->
<terrain first_lod="0" min_lod="20" />
</options>
<image name="bing" driver="bing">
<key>As489Vq5Fma4_GfQvtBzpPgXqJFjB3v0ZNMICy7wDVDMeBZyK2PqH2_tYLfBhpKT</key>
<imagery_set>AerialWithLabels</imagery_set>
</image>
</map>

View File

@ -0,0 +1,25 @@
<!--
MapQuest - Open Aerial Map
LOD 1-12 worldwide; 12+ US-only.
http://developer.mapquest.com/web/products/open/map
NOTE: You are responsible for abiding by the provider's terms of service:
http://developer.mapquest.com/web/info/terms-of-use
TIP: set your OSG_NUM_HTTP_DATABASE_THREADS to 4 or more!
-->
<map name="MapQuest Open Aerial" type="geocentric" version="2">
<image name="mapquest_open_aerial" driver="xyz">
<url>http://oatile[1234].mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg</url>
<profile>spherical-mercator</profile>
<cache_policy usage="no_cache"/>
<nodata_image>http://oatile3.mqcdn.com/tiles/1.0.0/sat/13/636/6210.jpg</nodata_image>
</image>
<options>
<lighting>false</lighting>
</options>
</map>

View File

@ -0,0 +1,22 @@
<!--
MapQuest - OpenStreetMap
http://developer.mapquest.com/web/products/open/map
NOTE: You are responsible for abiding by the provider's terms of service:
http://developer.mapquest.com/web/info/terms-of-use
TIP: set your OSG_NUM_HTTP_DATABASE_THREADS to 4 or more!
-->
<map name="MapQuest OpenStreetMap" type="geocenwwtric" version="2">
<image name="mapquest_osm" driver="xyz">
<url>http://otile[1234].mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg</url>
<profile>global-mercator</profile>
</image>
<elevation name="ReadyMap.org - Elevation" driver="tms">
<url>http://readymap.org/readymap/tiles/1.0.0/9/</url>
</elevation>
</map>

View File

@ -35,6 +35,7 @@ Item {
sceneNode: skyNode
camera: camera
manipulator: earthManipulator
incrementalCompile: true
OSGCamera {
id: camera
@ -70,14 +71,4 @@ Item {
running: osgViewport.busy
}
BusyIndicator {
width: 24
height: 24
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 4
running: osgViewport.busy
}
}

View File

@ -36,6 +36,7 @@ Item {
sceneNode: skyNode
camera: camera
manipulator: nodeTrackerManipulator
//incrementalCompile: true
OSGCamera {
id: camera

View File

@ -43,6 +43,7 @@ OSGViewport {
sceneNode: skyNode
camera: camera
manipulator: geoTransformManipulator
//incrementalCompile: true
OSGCamera {
id: camera

13
make/3rdparty/osgearth/osg-3.5.3.patch vendored Normal file
View File

@ -0,0 +1,13 @@
diff --git a/src/osgPlugins/cfg/CMakeLists.txt b/src/osgPlugins/cfg/CMakeLists.txt
index 972675f..4f7062b 100644
--- a/src/osgPlugins/cfg/CMakeLists.txt
+++ b/src/osgPlugins/cfg/CMakeLists.txt
@@ -20,7 +20,7 @@ SET(TARGET_H
# lex/yacc generated files use register that causes warnings with CLang under OSX so disable this warnings.
IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
- SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wno-deprecated-register)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
ENDIF()
#

View File

@ -31,7 +31,7 @@ OSG_NAME_SUFIX := -qt-$(QT_VERSION)
#
################################
OSG_VERSION := 3.5.1
OSG_VERSION := 3.5.3
OSG_GIT_TAG := OpenSceneGraph-$(OSG_VERSION)
OSG_BASE_NAME := osg-$(OSG_VERSION)

View File

@ -94,7 +94,7 @@ ifeq ($(UNAME), Linux)
QT_SDK_ARCH := gcc_64
QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-linux-x64-$(QT_VERSION).run
QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
OSG_URL := $(TOOLS_URL)/osg-3.5.1-linux-x64-qt-$(QT_VERSION).tar.gz
OSG_URL := $(TOOLS_URL)/osg-3.5.3-linux-x64-qt-$(QT_VERSION).tar.gz
OSGEARTH_URL := $(TOOLS_URL)/osgearth-2.7-linux-x64-qt-$(QT_VERSION).tar.gz
else
# x32 for linux no longer provided as pre-built binaries.
@ -109,7 +109,7 @@ else ifeq ($(UNAME), Darwin)
QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-clang-$(QT_VERSION)/qt-opensource-mac-x64-clang-$(QT_VERSION).app/Contents/MacOS/qt-opensource-mac-x64-clang-$(QT_VERSION)
UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60.tar.gz
DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1.src.tar.gz
OSG_URL := $(TOOLS_URL)/osg-3.5.1-clang_64-qt-$(QT_VERSION).tar.gz
OSG_URL := $(TOOLS_URL)/osg-3.5.3-clang_64-qt-$(QT_VERSION).tar.gz
OSGEARTH_URL := $(TOOLS_URL)/osgearth-2.7-clang_64-qt-$(QT_VERSION).tar.gz
else ifeq ($(UNAME), Windows)
QT_SDK_ARCH := mingw492_32
@ -133,14 +133,14 @@ CCACHE_DIR := $(TOOLS_DIR)/ccache
ifeq ($(UNAME), Linux)
ifeq ($(ARCH), x86_64)
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.1-linux-x64-qt-$(QT_VERSION)
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-linux-x64-qt-$(QT_VERSION)
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-linux-x64-qt-$(QT_VERSION)
else
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.1-linux-x86-qt-$(QT_VERSION)
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-linux-x86-qt-$(QT_VERSION)
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-linux-x86-qt-$(QT_VERSION)
endif
else ifeq ($(UNAME), Darwin)
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.1-clang_64-qt-$(QT_VERSION)
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-clang_64-qt-$(QT_VERSION)
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-clang_64-qt-$(QT_VERSION)
else ifeq ($(UNAME), Windows)
ifeq ($(ARCH), x86_64)