[osg-users] Left handed scene

Antoine Rennuit antoinerennuit at hotmail.com
Tue Aug 2 09:37:34 PDT 2016

Hi all,

Going a bit forward with my left handedness problem...

My viewport actually appears upside down vertically: the HUD coordinate system on the left is up when it should be down and the text is also written upside (see joined picture). It behaves as if the viewport had its y origin at the bottom of the viewport (and not at the top as usual).

Any idea?

Kind regards,


From: osg-users <osg-users-bounces at lists.openscenegraph.org> on behalf of Antoine Rennuit <antoinerennuit at hotmail.com>
Sent: 02 August 2016 14:36
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] Left handed scene

Hi all,

I have a QtWidget app which I am converting to QtQuick. My app works well with QtWidget but after transitioning to QtQuick I have observed that the whole scene is now left handed: not only the geometry is left handed (the z axis is down when it should be up - check joined file) but also the TrackballManipulator behavior (e.g. when I pan up with the mouse the scene goes down, and it's the same opposite reaction for rotate).

I do not understand where this is coming from. I was able to easily put the geometry back right handed using a scale -1 on Z but I should not have to do that and this does not solve the TrackballManipulator behavior.

I have used https://bitbucket.org/leon_manukyan/qtquick2osgitem as a starting point and my code does the following:

I have a RendererImpl class, created by an OsgItem and which is responsible for maintaining the osgViewer::Viewer and the osgViewer::GraphicsWindow, here is its init method:

void RendererImpl::init()
    m_sceneRoot = new osg::Group();

    m_viewer = new osgViewer::Viewer;
    m_viewer->setCameraManipulator(new osgGA::TrackballManipulator);
    m_viewer->getCameraManipulator()->setHomePosition(osg::Vec3d(4.0, -4.0, 2.0), osg::Vec3d(0.0, 0.0, 1.0), osg::Vec3d(0.0, 0.0, 1.0));

    m_sceneRoot->addChild(setupGrid(6.0f, 2.0f));

    m_window = new FrameBufferWindow(this);

    osg::Camera* camera = m_viewer->getCamera();
    camera->setGraphicsContext( m_window.get() );

    camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );

And its update method on window size change:

void RendererImpl::updateSize()
    m_window->getEventQueue()->windowResize(0, 0, osgItem().width(), osgItem().height() );
    m_window->resized(0, 0, osgItem().width(), osgItem().height());

    osg::Camera& camera = *m_viewer->getCamera();
    const osg::GraphicsContext::Traits& t = *m_window->getTraits();
    camera.setViewport( 0, 0, t.width, t.height );
    double aspectRatio = t.height ? (double)t.width / (double)t.height : 1.0;
    camera.setProjectionMatrixAsPerspective(30.0f, aspectRatio, 1.0f, 10000.0f );

And I have an item which streams the events to the window, e.g.:

void OsgItem::mouseMoveEvent(QMouseEvent *event)
    m_renderer->m_window->getEventQueue()->mouseMotion(event->x(), event->y());


Does anyone have an idea of what is wrong in my code? I have looked for days and I am stuck!



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160802/4afa3487/attachment-0003.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot from 2016-08-02 18:34:23.png
Type: image/png
Size: 8929 bytes
Desc: Screenshot from 2016-08-02 18:34:23.png
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160802/4afa3487/attachment-0003.png>

More information about the osg-users mailing list