[osg-users] Left handed scene

Antoine Rennuit antoinerennuit at hotmail.com
Mon Aug 8 23:31:07 PDT 2016


Hi Sam,


I have tested this solution and it solves for the geometry inversion, but it does not solve the behavior inversion problem. This means that when the trackball is moved up the scene actually goes down (either in rotation or in pan).


________________________________
From: osg-users <osg-users-bounces at lists.openscenegraph.org> on behalf of Sam Brkopac <brkopac at gmail.com>
Sent: 08 August 2016 23:54
To: OpenSceneGraph Users
Subject: Re: [osg-users] Left handed scene

If you need to rotate your entire scene you can add a single transform to the root node and do the rotation. Then can treat that transform as the new root node.

On Aug 2, 2016, at 10:27, Antoine Rennuit <antoinerennuit at hotmail.com<mailto:antoinerennuit at hotmail.com>> wrote:


Hi all,


My problem is solved my I flip my FrameBuffer vertically (in Qt), which I should not be doing.


So anyone has an idea of what can flip my OSG view vertically?


Thanks,


Antoine.


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


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,


Antoine.


________________________________
From: osg-users <osg-users-bounces at lists.openscenegraph.org<mailto:osg-users-bounces at lists.openscenegraph.org>> on behalf of Antoine Rennuit <antoinerennuit at hotmail.com<mailto:antoinerennuit at hotmail.com>>
Sent: 02 August 2016 14:36
To: osg-users at lists.openscenegraph.org<mailto: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->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
    m_viewer->setSceneData(m_sceneRoot);
    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_viewer->home();

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

    m_window = new FrameBufferWindow(this);
    updateSize();

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

    update();
}


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


Thanks,


Antoine.


_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org<mailto:osg-users at lists.openscenegraph.org>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160809/7a34824a/attachment-0003.htm>


More information about the osg-users mailing list